Commit 7103cd44 authored by Geoff Simmons's avatar Geoff Simmons

Add a helm version of the example/test for Service type NodePort.

parent c43e20e4
......@@ -32,11 +32,57 @@ mkdir := $(dir $(mkpath))
TESTDIR=$(mkdir)/../../test
CHARTDIR=$(mkdir)/../../charts
GEN_SECRET=head -c32 /dev/urandom | base64 | tr +/ -_
# For the klarlack image: make VARNISH=klarlack ...
ifndef VARNISH
VARNISH=varnish
endif
CI_REPO_PFX=registry.gitlab.com/uplex/varnish/k8s-ingress/varnish-ingress
# For tests using the local docker registry: make TEST=local ...
# For tests using images from the CI pipeline: make TEST=ci ...
ifeq ($(TEST),local)
VARNISH_IMAGE=varnish-ingress/$(VARNISH)
VARNISH_TAG=latest
HAPROXY_IMAGE=varnish-ingress/haproxy
HAPROXY_TAG=latest
else ifeq ($(TEST),ci)
VARNISH_IMAGE=$(CI_REPO_PFX)/$(VARNISH)
VARNISH_TAG=master
HAPROXY_IMAGE=$(CI_REPO_PFX)/haproxy
HAPROXY_TAG=master
endif
# If not specified, pull the latest "official" images from dockerhub.
LATEST=0.1.0
ifndef VARNISH_IMAGE
VARNISH_IMAGE=uplex/viking-$(VARNISH)
endif
ifndef VARNISH_TAG
VARNISH_TAG=$(LATEST)
endif
ifndef HAPROXY_IMAGE
HAPROXY_IMAGE=uplex/viking-haproxy
endif
ifndef HAPROXY_TAG
HAPROXY_TAG=$(LATEST)
endif
all: deploy
deploy-nodeport-helm:
@helm install viking-service-nodeport $(CHARTDIR)/viking-service \
--values values-nodeport.yaml \
--set vikingService.secrets.admin=$(shell $(GEN_SECRET)) \
--set vikingService.secrets.dataplaneapi=$(shell $(GEN_SECRET)) \
--set vikingService.varnish.image.repository=$(VARNISH_IMAGE) \
--set vikingService.varnish.image.tag=$(VARNISH_TAG) \
--set vikingService.haproxy.image.repository=$(HAPROXY_IMAGE) \
--set vikingService.haproxy.image.tag=$(HAPROXY_TAG)
@helm install viking-ingress-nodeport $(CHARTDIR)/viking-test-app \
--values values-nodeport.yaml
--values values.yaml
deploy-lb-helm:
@helm install viking-ingress-lb $(CHARTDIR)/viking-test-app \
......@@ -57,16 +103,19 @@ verify:
$(mkdir)/verify.sh
wait:
@echo Waiting until varnish-ingress Pods are not configured for Ingress
$(TESTDIR)/wait.sh app=varnish-ingress
wait-delete:
$(TESTDIR)/wait_delete.sh app=varnish-ingress,example=svctypes
undeploy-nodeport-helm:
@helm uninstall viking-ingress-nodeport
$(MAKE) wait
@helm uninstall viking-service-nodeport
$(MAKE) wait-delete
undeploy-loadbalancer-helm:
@helm uninstall viking-ingress-lb
$(MAKE) wait
$(MAKE) wait-delete
undeploy-cafe-kubectl:
@kubectl delete -f $(mkdir)/../hello/cafe-ingress.yaml
......
nameOverride: svctypes-example
fullnameOverride: svctypes-example
vikingService:
service:
type: NodePort
## Name of the ingress class to route through this controller
##
ingressClass: varnish
replicaCount: 1
# labels to add to the pod container metadata
podLabels:
app: varnish-ingress
example: svctypes
apps:
coffee:
image: nginxdemos/hello:plain-text
replicas: 2
tea:
image: nginxdemos/hello:plain-text
replicas: 3
ingress:
name: cafe-ingress-varnish
rules:
- host: cafe.example.com
paths:
- path: /tea
app: tea
- path: /coffee
app: coffee
vikingAdmSvc: svctypes-example-admin
......@@ -6,8 +6,22 @@ source ${MYDIR}/../../test/utils.sh
IP=${IP:-127.0.0.1}
LOCALPORT=${LOCALPORT:-8888}
wait_until_ready app=varnish-ingress
wait_until_configured app=varnish-ingress
# Wait for configuration by waiting for the loadBalancer IP in the
# Ingress to be set.
N=0
timeout=120
while true; do
ip=$(kubectl get ing cafe-ingress-varnish -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
if [[ -n ${ip} ]]; then
break
fi
if [ $N -ge ${timeout} ]; then
echo "Timed out waiting for Ingress to be configured"
exit 1
fi
sleep 1
N=$(( N + 1 ))
done
NODEPORT=$(kubectl get svc svctypes-example -o jsonpath='{.spec.ports[0].nodePort}')
EXTERNALIP=$(kubectl get svc svctypes-example -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
......@@ -30,7 +44,22 @@ else
PORT=${LOCALPORT}
kubectl port-forward svc/svctypes-example ${PORT}:80 >/dev/null &
trap 'kill $(jobs -p)' EXIT
wait_for_port ${PORT}
fi
set +e
N=0
while true; do
cat < /dev/null > /dev/tcp/${IP}/${PORT}
if [ $? -eq 0 ]; then
break
fi
if [ $N -ge ${timeout} ]; then
echo "Timed out waiting for listener at ${IP}:${PORT}"
exit 1
fi
sleep 1
N=$(( N + 1 ))
done
set -e
varnishtest ${TESTOPTS} -Dport=${PORT} -Dip=${IP} cafe.vtc
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