diff --git a/Traefik/IngressRoute/ingressRoute_nginx.yaml b/Traefik/IngressRoute/dev-storage/ingressRoute_nginx.yaml similarity index 100% rename from Traefik/IngressRoute/ingressRoute_nginx.yaml rename to Traefik/IngressRoute/dev-storage/ingressRoute_nginx.yaml diff --git a/Traefik/IngressRoute/ingressRoute_whoami.yaml b/Traefik/IngressRoute/dev-storage/ingressRoute_whoami.yaml similarity index 100% rename from Traefik/IngressRoute/ingressRoute_whoami.yaml rename to Traefik/IngressRoute/dev-storage/ingressRoute_whoami.yaml diff --git a/Traefik/IngressRoute/ingressRoute_nginx_template.yaml b/Traefik/IngressRoute/ingressRoute_nginx_template.yaml new file mode 100644 index 0000000000000000000000000000000000000000..63317f10c1cdd62b4526bed0818ebf0c13015fa7 --- /dev/null +++ b/Traefik/IngressRoute/ingressRoute_nginx_template.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(`_INGRESS_HOST_`) && 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/Traefik/IngressRoute/ingressRoute_whoami_template.yaml b/Traefik/IngressRoute/ingressRoute_whoami_template.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9e3825a371032e5da21a0a4ba90b4803922abbe9 --- /dev/null +++ b/Traefik/IngressRoute/ingressRoute_whoami_template.yaml @@ -0,0 +1,14 @@ +apiVersion: traefik.containo.us/v1alpha1 +kind: IngressRoute +metadata: + name: ingressroute-who-svc +spec: + entryPoints: + - websecure + routes: + - match: Host(`_INGRESS_HOST_`) && Path(`/who`) + kind: Rule + services: + - name: whoami-svc + port: 80 + diff --git a/Traefik/IngressRoute/install_ingressroutes.sh b/Traefik/IngressRoute/install_ingressroutes.sh new file mode 100755 index 0000000000000000000000000000000000000000..93665d1a27a4e32366332d990125cc3409220e78 --- /dev/null +++ b/Traefik/IngressRoute/install_ingressroutes.sh @@ -0,0 +1,45 @@ +#!/bin/bash +if [ -z "$1" ]; then + echo "Error : Missing Ingress-Host parameter" + echo "Sample: $0 dev-storage.informatik.fh-nuernberg.de" + exit 1 +fi +#INGRESS_HOST="dev-storage.informatik.fh-nuernberg.de" +INGRESS_HOST=$1 +echo $INGRESS_HOST +HOSTNAME=$(echo $INGRESS_HOST | awk -v FS='.' '{print $1}') +echo "Hostname" : $HOSTNAME +echo "IingressRoute hosti : ${INGRESS_HOST}" +rm -rf $HOSTNAME +mkdir $HOSTNAME +kubectl delete namespace testing +kubectl create namespace testing +# +# Create Pods / Servies +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 from template Files +cd $HOSTNAME +cat ../ingressRoute_nginx_template.yaml | sed "s/_INGRESS_HOST_/$INGRESS_HOST/g" > ingressRoute_nginx.yaml +cat ../ingressRoute_whoami_template.yaml | sed "s/_INGRESS_HOST_/$INGRESS_HOST/g" > ingressRoute_whoami.yaml +kubectl -n testing apply -f ingressRoute_whoami.yaml +kubectl -n testing apply -f ingressRoute_nginx.yaml + +# Validate with curl - wait some time until pods become availabe +# +sleep 5 +# +kubectl -n testing get all +# +curl -v --insecure https://${INGRESS_HOST}/nginx-green +curl -v --insecure https://${INGRESS_HOST}/nginx-blue +curl -v --insecure https://${INGRESS_HOST}/who + +echo "Test following URL in your browser " +echo " https://${INGRESS_HOST}/nginx-green" +echo " https://${INGRESS_HOST}/nginx-blue" +echo " https://${INGRESS_HOST}/who" + + diff --git a/Traefik/IngressRoute/test-ingressroutes.sh b/Traefik/IngressRoute/test-ingressroutes.sh deleted file mode 100755 index 18b911a9bbc38a4ae0a51386d7e511606b2b0506..0000000000000000000000000000000000000000 --- a/Traefik/IngressRoute/test-ingressroutes.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/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 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