diff --git a/IngressRoute/ingressRoute_nginx.yaml b/IngressRoute/ingressRoute_nginx.yaml new file mode 100644 index 0000000000000000000000000000000000000000..fff4d46200262827a231917a90df2aa7ff63b4b4 --- /dev/null +++ b/IngressRoute/ingressRoute_nginx.yaml @@ -0,0 +1,34 @@ +apiVersion: traefik.containo.us/v1alpha1 +kind: Middleware +metadata: + name: nginx-strip-path-prefix +spec: + stripPrefix: + prefixes: + - /nginx-green + - /nginx-blue +--- +apiVersion: traefik.containo.us/v1alpha1 +kind: IngressRoute +metadata: + name: ingressroute-nginx +spec: + entryPoints: + - websecure + routes: + - match: Host(`dev-storage.informatik.fh-nuernberg.de`) && Path(`/nginx-green`) + kind: Rule + middlewares: + - name: nginx-strip-path-prefix + services: + - name: nginx-service-green + port: 8080 + - match: Host(`dev-storage.informatik.fh-nuernberg.de`) && Path(`/nginx-blue`) + kind: Rule + middlewares: + - name: nginx-strip-path-prefix + services: + - name: nginx-service-blue + port: 8080 + + diff --git a/IngressRoute/ingressRoute_whoami.yaml b/IngressRoute/ingressRoute_whoami.yaml new file mode 100644 index 0000000000000000000000000000000000000000..839e6a229a841958c947161173c16580f6513735 --- /dev/null +++ b/IngressRoute/ingressRoute_whoami.yaml @@ -0,0 +1,14 @@ +apiVersion: traefik.containo.us/v1alpha1 +kind: IngressRoute +metadata: + name: ingressroute-who-svc +spec: + entryPoints: + - websecure + routes: + - match: Host(`dev-storage.informatik.fh-nuernberg.de`) && Path(`/who`) + kind: Rule + services: + - name: whoami-svc + port: 80 + diff --git a/IngressRoute/nginx-deploy-blue.yaml b/IngressRoute/nginx-deploy-blue.yaml new file mode 100644 index 0000000000000000000000000000000000000000..5f2575d48b1e7b6a165d627ab57db447b3b6e0a8 --- /dev/null +++ b/IngressRoute/nginx-deploy-blue.yaml @@ -0,0 +1,52 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: nginx + name: nginx-deploy-blue +spec: + replicas: 1 + selector: + matchLabels: + app: nginx-blue + template: + metadata: + labels: + app: nginx-blue + spec: + volumes: + - name: webdata + emptyDir: {} + initContainers: + - name: web-content + image: busybox + volumeMounts: + - name: webdata + mountPath: "/webdata" + command: ["/bin/sh", "-c", 'echo "<h1>I am <font color=blue>BLUE</font></h1>" > /webdata/index.html'] + containers: + - image: nginx + name: nginx + volumeMounts: + - name: webdata + mountPath: "/usr/share/nginx/html" + +--- +apiVersion: v1 +kind: Service +metadata: + name: nginx-service-blue +spec: + type: ClusterIP + ports: + - name: http + protocol: TCP + port: 8080 + targetPort: 80 + - name: https + protocol: TCP + port: 8443 + targetPort: 443 + selector: + app: nginx-blue + diff --git a/IngressRoute/nginx-deploy-green.yaml b/IngressRoute/nginx-deploy-green.yaml new file mode 100644 index 0000000000000000000000000000000000000000..10899c16d21dccbe9915d106d31e37a87b007748 --- /dev/null +++ b/IngressRoute/nginx-deploy-green.yaml @@ -0,0 +1,53 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: nginx + name: nginx-deploy-green +spec: + replicas: 1 + selector: + matchLabels: + app: nginx-green + template: + metadata: + labels: + app: nginx-green + spec: + volumes: + - name: webdata + emptyDir: {} + initContainers: + - name: web-content + image: busybox + volumeMounts: + - name: webdata + mountPath: "/webdata" + command: ["/bin/sh", "-c", 'echo "<h1>I am <font color=green>GREEN</font></h1>" > /webdata/index.html'] + containers: + - image: nginx + name: nginx + volumeMounts: + - name: webdata + mountPath: "/usr/share/nginx/html" + +--- +apiVersion: v1 +kind: Service +metadata: + name: nginx-service-green +spec: + type: ClusterIP + ports: + - name: http + protocol: TCP + port: 8080 + targetPort: 80 + - name: https + protocol: TCP + port: 8443 + targetPort: 443 + selector: + app: nginx-green + + diff --git a/IngressRoute/test-ingressroutes.sh b/IngressRoute/test-ingressroutes.sh new file mode 100755 index 0000000000000000000000000000000000000000..f6c453052cfba849aa5a1a7d0e0649bf0024086a --- /dev/null +++ b/IngressRoute/test-ingressroutes.sh @@ -0,0 +1,28 @@ +#!/bin/bash +ingresshost="dev-storage.informatik.fh-nuernberg.de" +echo "Setup for ingressRoute host: ${ingresshost}" +kubectl delete namespace testing +kubectl create namespace testing +# +# Create Pods / Serives +kubectl -n testing apply -f nginx-deploy-green.yaml +kubectl -n testing apply -f nginx-deploy-blue.yaml +kubectl -n testing apply -f whoami-deploy.yaml +# +# Create ingressRoutes +kubectl -n testing apply -f ingressRoute_whoami.yaml +kubectl -n testing apply -f ingressRoute_nginx.yaml + +# Validate with curl - wait untill pods are availabe +# +sleep curl -v --insecure https://dev-storage.informatik.fh-nuernberg.de/who +5 +# +kubectl -n testing get all +# +curl -v --insecure https://dev-storage.informatik.fh-nuernberg.de/nginx-green +curl -v --insecure https://dev-storage.informatik.fh-nuernberg.de/nginx-blue +curl -v --insecure https://dev-storage.informatik.fh-nuernberg.de/who + +echo "Test following URL in your browser " +echo diff --git a/IngressRoute/whoami-deploy.yaml b/IngressRoute/whoami-deploy.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ba56d86cc90e51102aaeed966158ed370865e02d --- /dev/null +++ b/IngressRoute/whoami-deploy.yaml @@ -0,0 +1,41 @@ +kind: Deployment +apiVersion: apps/v1 +metadata: + name: whoami-pod + labels: + app: whoami--deployment +spec: + replicas: 1 + selector: + matchLabels: + app: whoami + template: + metadata: + labels: + app: whoami + spec: + containers: + - name: whoami-container + image: containous/whoami + ports: + - containerPort: 80 +--- +apiVersion: v1 +kind: Service +metadata: + name: whoami-svc + labels: + app: whoami +spec: + type: NodePort + ports: + - port: 80 + name: whoami + targetPort: 80 + # Optional field + # By default and for convenience, the Kubernetes control plane will allocate a port from a range (default: 30000-32767) + nodePort: 30331 + protocol: TCP + selector: + app: whoami +