Commit b3341410 authored by Geoff Simmons's avatar Geoff Simmons

Add an example/test for public Service type NodePort using kubectl/yaml.

parent 7cfd8898
# Copyright (c) 2020 UPLEX Nils Goroll Systemoptimierung
# All rights reserved
#
# Author: Geoffrey Simmons <geoffrey.simmons@uplex.de>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
# GNU make is required.
mkpath := $(abspath $(lastword $(MAKEFILE_LIST)))
mkdir := $(dir $(mkpath))
TESTDIR=$(mkdir)/../../test
CHARTDIR=$(mkdir)/../../charts
all: deploy
deploy-nodeport-helm:
@helm install viking-ingress-nodeport $(CHARTDIR)/viking-test-app \
--values values-nodeport.yaml
deploy-lb-helm:
@helm install viking-ingress-lb $(CHARTDIR)/viking-test-app \
--values values-lb.yaml
deploy-cafe-kubectl:
@kubectl apply -f $(mkdir)/../hello/cafe.yaml
@kubectl apply -f $(mkdir)/../hello/cafe-ingress.yaml
deploy-nodeport-kubectl: deploy-cafe-kubectl
@kubectl apply -f nodeport.yaml
deploy-lb-kubectl: deploy-cafe-kubectl
@kubectl apply -f loadbalancer.yaml
# TESTOPTS are passed to varnishtest, e.g.: make TESTOPTS=-v verify
verify:
$(mkdir)/verify.sh
wait:
@echo Waiting until varnish-ingress Pods are not configured for Ingress
$(TESTDIR)/wait.sh app=varnish-ingress
undeploy-nodeport-helm:
@helm uninstall viking-ingress-nodeport
$(MAKE) wait
undeploy-loadbalancer-helm:
@helm uninstall viking-ingress-lb
$(MAKE) wait
undeploy-cafe-kubectl:
@kubectl delete -f $(mkdir)/../hello/cafe-ingress.yaml
@kubectl delete -f $(mkdir)/../hello/cafe.yaml
undeploy-nodeport-kubectl:
@kubectl delete -f nodeport.yaml
$(MAKE) undeploy-cafe-kubectl
$(MAKE) wait
undeploy-lb-kubectl:
@kubectl delete -f loadbalancer.yaml
$(MAKE) undeploy-cafe-kubectl
$(MAKE) wait
ifeq ($(DEPLOY),kubectl)
deploy-nodeport: deploy-nodeport-kubectl
undeploy-nodeport: undeploy-nodeport-kubectl
deploy-lb: deploy-lb-kubectl
undeploy-lb: undeploy-lb-kubectl
else
deploy-nodeport: deploy-nodeport-helm
undeploy-nodeport: undeploy-nodeport-helm
deploy-lb: deploy-lb-helm
undeploy-lb: undeploy-lb-helm
endif
ifeq ($(EXAMPLE),nodeport)
deploy: deploy-nodeport
undeploy: undeploy-nodeport
else ifeq ($(EXAMPLE),lb)
deploy: deploy-lb
undeploy: undeploy-lb
else
deploy undeploy:
$(error EXAMPLE must be set to nodeport or lb)
endif
.PHONY: all $(MAKECMDGOALS)
../hello/cafe.vtc
\ No newline at end of file
apiVersion: v1
kind: Service
metadata:
name: svctypes-example
labels:
app: varnish-ingress
viking.uplex.de/svc: public
spec:
type: NodePort
ports:
- port: 80
targetPort: 8888
protocol: TCP
name: http
- port: 443
targetPort: 4443
protocol: TCP
name: tls
selector:
app: varnish-ingress
#! /bin/bash -ex
MYDIR=$(dirname ${BASH_SOURCE[0]})
source ${MYDIR}/../../test/utils.sh
LOCALPORT=${LOCALPORT:-8888}
wait_until_ready app=varnish-ingress
wait_until_configured app=varnish-ingress
kubectl port-forward svc/svctypes-example ${LOCALPORT}:80 >/dev/null &
trap 'kill $(jobs -p)' EXIT
wait_for_port ${LOCALPORT}
varnishtest ${TESTOPTS} -Dlocalport=${LOCALPORT} 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