diff --git a/README.md b/README.md index 5f3ef14..a8add39 100644 --- a/README.md +++ b/README.md @@ -152,7 +152,7 @@ This repository contains a [Tiltfile](https://tilt.dev/) that can be used for lo make setup ``` -To bind up a tilt development enviornment do: +To bring up a tilt development enviornment run `tilt up` or: ``` make up @@ -162,25 +162,46 @@ Some test resources can be added to the k8s cluster with: ``` # ingress and service resources -kubectl apply -f ./test/test.yml +kubectl apply -f ./test/ingress-services.yml # gateway API resources kubectl apply -f ./test/gateway-api/resources.yml + +# nginxinc's VirtualService resources +kubectl apply -f test/nginxinc-kubernetes-ingress/resources.yaml ``` Test queries can be sent to the exposed CoreDNS service like this: ``` $ ip=$(kubectl get nodes -o jsonpath='{.items[0].status.addresses[0].address}') + +# ingress resource $ dig @$ip -p 32553 myservicea.foo.org +short -192.168.224.2 +198.51.100.0 + +# loadBalancer $ dig @$ip -p 32553 test.default.foo.org +short -192.168.223.129 +198.51.100.3 + +# HTTPRoute/gateway-API $ dig @$ip -p 32553 myservicea.gw.foo.org +short -192.168.223.130 +198.51.100.4 +$ dig @$ip -p 32553 myserviceb.gw.foo.org +short +198.51.100.4 + +# multi-gateway HTTPRoute $ dig @$ip -p 32553 myserviced.gw.foo.org +short -192.168.223.130 -192.168.223.131 +198.51.100.5 +198.51.100.4 + +# nginxinc's Ingress +$ dig @$ip -p 32553 myserviceb.foo.org +short +198.51.100.1 + +# nginxinc's VirtualServer +$ dig @$ip -p 32553 virtualservera.foo.org +short +198.51.100.1 ``` To cleanup local environment do: diff --git a/Tiltfile b/Tiltfile index c2eac75..5df993e 100644 --- a/Tiltfile +++ b/Tiltfile @@ -51,8 +51,9 @@ helm_remote('metallb', k8s_kind('VirtualServer', api_version='k8s.nginx.org/v1') helm_remote('nginx-ingress', version="0.12.0", + release_name="nginxinc", repo_name='nginx-stable', - values=['./test/nginx-kubernetes-ingress/values.yaml'], + values=['./test/nginxinc-kubernetes-ingress/values.yaml'], repo_url='https://helm.nginx.com/stable') diff --git a/charts/k8s-gateway/Chart.yaml b/charts/k8s-gateway/Chart.yaml index 03981bb..c450fa8 100644 --- a/charts/k8s-gateway/Chart.yaml +++ b/charts/k8s-gateway/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: k8s-gateway description: A Helm chart for the k8s_gateway CoreDNS plugin type: application -version: 1.1.1 -appVersion: 0.2.1 +version: 1.1.2 +appVersion: 0.2.2 maintainers: - email: mmkashin@gmail.com name: Michael diff --git a/charts/k8s-gateway/templates/rbac.yaml b/charts/k8s-gateway/templates/rbac.yaml index 758612e..cc32a57 100644 --- a/charts/k8s-gateway/templates/rbac.yaml +++ b/charts/k8s-gateway/templates/rbac.yaml @@ -25,6 +25,9 @@ rules: - apiGroups: ["gateway.networking.k8s.io"] resources: ["*"] verbs: ["watch", "list"] +- apiGroups: ["k8s.nginx.org"] + resources: ["*"] + verbs: ["watch", "list"] --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding diff --git a/test/gateway-api/resources.yml b/test/gateway-api/resources.yml index 0268954..ee50733 100644 --- a/test/gateway-api/resources.yml +++ b/test/gateway-api/resources.yml @@ -2,7 +2,23 @@ apiVersion: gateway.networking.k8s.io/v1alpha2 kind: Gateway metadata: - name: gateway + name: gateway-one + namespace: default +spec: + gatewayClassName: "istio" + listeners: + - name: default + hostname: "*.gw.foo.org" + port: 80 + protocol: HTTP + allowedRoutes: + namespaces: + from: All +--- +apiVersion: gateway.networking.k8s.io/v1alpha2 +kind: Gateway +metadata: + name: gateway-two namespace: default spec: gatewayClassName: "istio" @@ -22,7 +38,7 @@ metadata: namespace: default spec: parentRefs: - - name: gateway + - name: gateway-one hostnames: ["myservicea.gw.foo.org"] rules: - matches: @@ -41,7 +57,7 @@ metadata: namespace: kube-system spec: parentRefs: - - name: gateway + - name: gateway-one namespace: default hostnames: ["myserviceb.gw.foo.org"] rules: @@ -74,29 +90,13 @@ spec: port: 80 --- apiVersion: gateway.networking.k8s.io/v1alpha2 -kind: Gateway -metadata: - name: gateway-two - namespace: default -spec: - gatewayClassName: "istio" - listeners: - - name: default - hostname: "*.gw.foo.org" - port: 80 - protocol: HTTP - allowedRoutes: - namespaces: - from: All ---- -apiVersion: gateway.networking.k8s.io/v1alpha2 kind: HTTPRoute metadata: name: myserviced namespace: default spec: parentRefs: - - name: gateway + - name: gateway-one - name: gateway-two hostnames: ["myserviced.gw.foo.org"] rules: diff --git a/test/ingress-services.yml b/test/ingress-services.yml index bd4127b..a4ff124 100644 --- a/test/ingress-services.yml +++ b/test/ingress-services.yml @@ -18,25 +18,6 @@ spec: port: number: 80 --- -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: ingress-myserviceb - namespace: default -spec: - ingressClassName: nginx - rules: - - host: myserviceb.foo.org - http: - paths: - - path: / - pathType: Prefix - backend: - service: - name: ingress - port: - number: 80 ---- apiVersion: apps/v1 kind: Deployment metadata: diff --git a/test/nginxinc-kubernetes-ingress/resources.yaml b/test/nginxinc-kubernetes-ingress/resources.yaml index adb4902..027da1b 100644 --- a/test/nginxinc-kubernetes-ingress/resources.yaml +++ b/test/nginxinc-kubernetes-ingress/resources.yaml @@ -1,25 +1,6 @@ --- apiVersion: networking.k8s.io/v1 kind: Ingress -metadata: - name: ingress-nginx-test-a - namespace: default -spec: - ingressClassName: nginxinc - rules: - - host: myservicea.foo.org - http: - paths: - - path: / - pathType: Prefix - backend: - service: - name: nginx-test-a - port: - number: 80 ---- -apiVersion: networking.k8s.io/v1 -kind: Ingress metadata: name: ingress-nginx-test-b namespace: default @@ -47,79 +28,3 @@ spec: - name: nginx-test-a service: nginx-test-a port: 80 ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - app: nginx-test-a - name: nginx-test-a - namespace: default -spec: - replicas: 1 - selector: - matchLabels: - app: nginx-test-a - template: - metadata: - labels: - app: nginx-test-a - spec: - containers: - - image: nginx - imagePullPolicy: Always - name: nginx ---- -apiVersion: v1 -kind: Service -metadata: - name: nginx-test-a - namespace: default -spec: - ports: - - name: http-80 - port: 80 - protocol: TCP - targetPort: 80 - selector: - app: nginx-test-a - sessionAffinity: None - type: ClusterIP ---- -apiVersion: v1 -kind: Service -metadata: - name: nginx-test-b - namespace: default -spec: - ports: - - name: http-80 - port: 80 - protocol: TCP - targetPort: 80 - selector: - app: nginx-test-b - sessionAffinity: None - type: LoadBalancer ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - app: nginx-test-b - name: nginx-test-b - namespace: default -spec: - replicas: 1 - selector: - matchLabels: - app: nginx-test-b - template: - metadata: - labels: - app: nginx-test-b - spec: - containers: - - image: nginx - imagePullPolicy: Always - name: nginx