Commit ded4b7fa authored by Geoff Simmons's avatar Geoff Simmons

Automate un-/deployment & test of the multi-controller example.

parent fd5f3373
# looks like -*- vcl -*-
varnishtest "cafe example, multiple Ingress controllers"
client c1 -connect "${localhost} ${coffeeport}" {
txreq -url /foo -hdr "Host: coffee.example.com"
rxresp
expect resp.status == 200
expect resp.body ~ "(?m)^Server name: coffee-[a-z0-9]+-[a-z0-9]+$"
txreq -url /foo -hdr "Host: tea.example.com"
rxresp
expect resp.status == 404
} -run
client c1 -connect "${localhost} ${teaport}" {
txreq -url /bar -hdr "Host: tea.example.com"
rxresp
expect resp.status == 200
expect resp.body ~ "(?m)^Server name: tea-[a-z0-9]+-[a-z0-9]+$"
txreq -url /bar -hdr "Host: coffee.example.com"
rxresp
expect resp.status == 404
} -run
......@@ -12,6 +12,7 @@ spec:
metadata:
labels:
app: varnish-ingress-controller
example: coffee
spec:
serviceAccountName: varnish-ingress-controller
containers:
......
#! /bin/bash -ex
# Assumes that the kube-system controller as configured in deploy/ is
# already deployed.
kubectl apply -f controller.yaml
kubectl apply -f namespace.yaml
kubectl apply -f coffee.yaml
kubectl apply -f tea.yaml
kubectl apply -f adm-secret-tea.yaml
kubectl apply -f nodeport-tea.yaml
kubectl apply -f varnish-tea.yaml
kubectl apply -f adm-secret-coffee.yaml
kubectl apply -f nodeport-coffee.yaml
kubectl apply -f varnish-coffee.yaml
kubectl apply -f coffee-ingress.yaml
kubectl apply -f tea-ingress.yaml
#! /bin/bash -ex
kubectl delete -f tea-ingress.yaml
kubectl delete -f coffee-ingress.yaml
kubectl delete -f varnish-coffee.yaml
kubectl delete -f nodeport-coffee.yaml
kubectl delete -f adm-secret-coffee.yaml
kubectl delete -f varnish-tea.yaml
kubectl delete -f nodeport-tea.yaml
kubectl delete -f adm-secret-tea.yaml
kubectl delete -f tea.yaml
kubectl delete -f coffee.yaml
kubectl delete -f namespace.yaml
kubectl delete -f controller.yaml
kubectl wait --timeout=2m pod -l app=varnish-ingress-controller,example=coffee \
-n kube-system --for=delete
#! /bin/bash -ex
function killcoffee {
kill $COFFEEPID
}
function killcafe {
kill $COFFEEPID
kill $TEAPID
}
COFFEEPORT=${COFFEEPORT:-8888}
TEAPORT=${TEAPORT:-9999}
kubectl wait -n kube-system --timeout=2m pod -l app=varnish-ingress-controller \
--for=condition=Ready
kubectl wait -n cafe --timeout=2m pod -l app=varnish-ingress \
--for=condition=Ready
kubectl port-forward -n cafe svc/varnish-coffee ${COFFEEPORT}:80 >/dev/null &
COFFEEPID=$!
trap killcoffee EXIT
kubectl port-forward -n cafe svc/varnish-tea ${TEAPORT}:80 >/dev/null &
TEAPID=$!
trap killcafe EXIT
sleep 1
varnishtest ${TESTOPTS} -Dcoffeeport=${COFFEEPORT} -Dteaport=${TEAPORT} cafe.vtc
# Parse the tea controller log for these lines:
# Ingress class:varnish
# Ingress cafe/tea-ingress configured for Varnish Service cafe/varnish-tea
# Ignoring Ingress cafe/coffee-ingress, Annotation 'kubernetes.io/ingress.class' absent or is not 'varnish'
# Get the name of the tea controller Pod
CTLPOD=$(kubectl get pods -n kube-system -l app=varnish-ingress-controller,example!=coffee -o jsonpath={.items[0].metadata.name})
# Match the logs
kubectl logs -n kube-system $CTLPOD | grep -q 'Ingress class:varnish'
kubectl logs -n kube-system $CTLPOD | grep -q 'Ingress cafe/tea-ingress configured for Varnish Service cafe/varnish-tea'
kubectl logs -n kube-system $CTLPOD | grep -q "Ignoring Ingress cafe/coffee-ingress, Annotation 'kubernetes.io/ingress.class' absent or is not 'varnish'"
# Parse the coffee controller log for these lines
# Ingress class:varnish-coffee
# Ingress cafe/coffee-ingress configured for Varnish Service cafe/varnish-coffee
# Ignoring Ingress cafe/tea-ingress, Annotation 'kubernetes.io/ingress.class' absent or is not 'varnish-coffee'
# Get the name of the tea controller Pod
CTLPOD=$(kubectl get pods -n kube-system -l app=varnish-ingress-controller -l example=coffee -o jsonpath={.items[0].metadata.name})
# Match the logs
kubectl logs -n kube-system $CTLPOD | grep -q 'Ingress class:varnish-coffee'
kubectl logs -n kube-system $CTLPOD | grep -q 'Ingress cafe/coffee-ingress configured for Varnish Service cafe/varnish-coffee'
kubectl logs -n kube-system $CTLPOD | grep -q "Ignoring Ingress cafe/tea-ingress, Annotation 'kubernetes.io/ingress.class' absent or is not 'varnish-coffee'"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment