Commit 86fe0429 authored by Geoff Simmons's avatar Geoff Simmons

Add helm deployments and a Makefile for the multi-controller test.

parent d863bea2
# 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))
CHARTDIR=$(mkdir)/../../../charts
TESTDIR=$(mkdir)/../../../test
# 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)
CONTROLLER_IMAGE=varnish-ingress/controller
CONTROLLER_TAG=latest
VARNISH_IMAGE=varnish-ingress/$(VARNISH)
VARNISH_TAG=latest
HAPROXY_IMAGE=varnish-ingress/haproxy
HAPROXY_TAG=latest
else ifeq ($(TEST),ci)
CONTROLLER_IMAGE=$(CI_REPO_PFX)/controller
CONTROLLER_TAG=master
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.0.2
ifndef CONTROLLER_IMAGE
CONTROLLER_IMAGE=uplex/viking-controller
endif
ifndef CONTROLLER_TAG
CONTROLLER_TAG=$(LATEST)
endif
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-helm:
@kubectl apply -f namespace.yaml
@helm install viking-controller-coffee $(CHARTDIR)/viking-controller \
--values values-controller.yaml --namespace kube-system \
--set vikingController.image.repository=$(CONTROLLER_IMAGE) \
--set vikingController.image.tag=$(CONTROLLER_TAG)
@helm install viking-service-tea $(CHARTDIR)/viking-service \
--values values-varnish.yaml --namespace cafe \
--set nameOverride=varnish-tea \
--set fullnameOverride=varnish-tea \
--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-service-coffee $(CHARTDIR)/viking-service \
--values values-varnish.yaml --namespace cafe \
--set nameOverride=varnish-coffee \
--set fullnameOverride=varnish-coffee \
--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 coffee-ingress $(CHARTDIR)/viking-test-app \
--values values-coffee.yaml --namespace cafe
@helm install tea-ingress $(CHARTDIR)/viking-test-app \
--values values-tea.yaml --namespace cafe
deploy-kubectl:
@kubectl apply -f controller.yaml
@kubectl apply -f namespace.yaml
@kubectl apply -f rbac.yaml
@kubectl apply -f coffee.yaml
@kubectl apply -f tea.yaml
@kubectl apply -f adm-secret-tea.yaml
@kubectl apply -f admin-svc-tea.yaml
@kubectl apply -f nodeport-tea.yaml
@kubectl apply -f varnish-tea.yaml
@kubectl apply -f adm-secret-coffee.yaml
@kubectl apply -f admin-svc-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
deploy:
ifeq ($(DEPLOY),kubectl)
deploy: deploy-kubectl
else
deploy: deploy-helm
endif
# TESTOPTS are passed to varnishtest, e.g.: make TESTOPTS=-v verify
verify:
$(mkdir)/verify.sh
undeploy-helm:
@helm uninstall tea-ingress --namespace cafe
@helm uninstall coffee-ingress --namespace cafe
@helm uninstall viking-service-coffee --namespace cafe
@helm uninstall viking-service-tea --namespace cafe
@helm uninstall viking-controller-coffee --namespace kube-system
$(TESTDIR)/wait_delete.sh app=varnish-ingress-controller,example=coffee \
kube-system
@kubectl delete -f namespace.yaml
undeploy-kubectl:
@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 admin-svc-coffee.yaml
@kubectl delete -f adm-secret-coffee.yaml
@kubectl delete -f varnish-tea.yaml
@kubectl delete -f nodeport-tea.yaml
@kubectl delete -f admin-svc-tea.yaml
@kubectl delete -f adm-secret-tea.yaml
@kubectl delete -f tea.yaml
@kubectl delete -f coffee.yaml
@kubectl delete -f rbac.yaml
@kubectl delete -f namespace.yaml
@kubectl delete -f controller.yaml
$(TESTDIR)/wait_delete.sh app=varnish-ingress-controller,example=coffee \
kube-system
undeploy:
ifeq ($(DEPLOY),kubectl)
undeploy: undeploy-kubectl
else
undeploy: undeploy-helm
endif
.PHONY: all $(MAKECMDGOALS)
apps:
coffee:
image: nginxdemos/hello:plain-text
replicas: 2
ingress:
name: coffee-ingress
class: varnish-coffee
rules:
- host: coffee.example.com
paths:
- app: coffee
vikingAdmSvc: varnish-coffee-admin
vikingController:
## Name of the ingress class to route through this controller
##
ingressClass: varnish-coffee
# labels to add to the pod container metadata
podLabels:
app: varnish-ingress-controller
example: coffee
apps:
tea:
image: nginxdemos/hello:plain-text
replicas: 3
ingress:
name: tea-ingress
rules:
- host: tea.example.com
paths:
- app: tea
vikingAdmSvc: varnish-tea-admin
vikingService:
## Name of the ingress class to route through this controller
##
ingressClass: varnish
# labels to add to the pod container metadata
podLabels:
app: varnish-ingress
......@@ -30,6 +30,7 @@ mkpath := $(abspath $(lastword $(MAKEFILE_LIST)))
mkdir := $(dir $(mkpath))
CHARTDIR=$(mkdir)/../../charts
TESTDIR=$(mkdir)/../../test
# For the klarlack image: make VARNISH=klarlack ...
ifndef VARNISH
......@@ -138,34 +139,34 @@ undeploy-cli-args-kubectl:
@kubectl delete -f cli-args.yaml
@kubectl delete -f cafe-ingress.yaml
@kubectl delete -f ../hello/cafe.yaml
$(mkdir)/wait_delete.sh app=varnish-ingress,example=cli-args
$(TESTDIR)/wait_delete.sh app=varnish-ingress,example=cli-args
undeploy-proxy-kubectl:
@kubectl delete -f proxy.yaml
@kubectl delete -f cafe-ingress.yaml
@kubectl delete -f ../hello/cafe.yaml
$(mkdir)/wait_delete.sh app=varnish-ingress,example=proxy
$(TESTDIR)/wait_delete.sh app=varnish-ingress,example=proxy
undeploy-env-kubectl:
@kubectl delete -f env.yaml
@kubectl delete -f cafe-ingress.yaml
@kubectl delete -f ../hello/cafe.yaml
$(mkdir)/wait_delete.sh app=varnish-ingress,example=env
$(TESTDIR)/wait_delete.sh app=varnish-ingress,example=env
undeploy-cli-args-helm:
@helm uninstall viking-ingress-cli-args
@helm uninstall viking-service-cli-args
$(mkdir)/wait_delete.sh app=varnish-ingress,example=cli-args
$(TESTDIR)/wait_delete.sh app=varnish-ingress,example=cli-args
undeploy-proxy-helm:
@helm uninstall viking-ingress-proxy
@helm uninstall viking-service-proxy
$(mkdir)/wait_delete.sh app=varnish-ingress,example=proxy
$(TESTDIR)/wait_delete.sh app=varnish-ingress,example=proxy
undeploy-env-helm:
@helm uninstall viking-ingress-env
@helm uninstall viking-service-env
$(mkdir)/wait_delete.sh app=varnish-ingress,example=env
$(TESTDIR)/wait_delete.sh app=varnish-ingress,example=env
deploy-cli-args:
......
......@@ -6,6 +6,6 @@ if [ -z "$1" ] || [ "$#" -gt 3 ]; then
fi
MYDIR=$(dirname ${BASH_SOURCE[0]})
source ${MYDIR}/../../test/utils.sh
source ${MYDIR}/utils.sh
wait_until_deleted "$@"
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