Skip to content
Snippets Groups Projects
Commit 7c415d43 authored by hutzlerhe's avatar hutzlerhe
Browse files

implemneted templates for each Ingresshost

parent 734122b7
No related branches found
No related tags found
No related merge requests found
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
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
#!/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"
#!/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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment