Commit dc9463a9 authored by Geoff Simmons's avatar Geoff Simmons

Add helm deployments and a Makefile for the "cluster-wide" example/test.

parent 08d28456
# 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
# 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.0.2
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-service-clusterwide $(CHARTDIR)/viking-service \
--values values-varnish.yaml --namespace kube-system \
--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 coffee
@helm install tea-ingress $(CHARTDIR)/viking-test-app \
--values values-tea.yaml --namespace tea
@helm install other-ingress $(CHARTDIR)/viking-test-app \
--values values-other.yaml --namespace other
deploy-kubectl:
@kubectl apply -f namespace.yaml
@kubectl apply -f rbac.yaml
@kubectl apply -f coffee.yaml
@kubectl apply -f tea.yaml
@kubectl apply -f other.yaml
@kubectl apply -f adm-secret.yaml
@kubectl apply -f admin-svc.yaml
@kubectl apply -f nodeport.yaml
@kubectl apply -f varnish.yaml
@kubectl apply -f coffee-ingress.yaml
@kubectl apply -f tea-ingress.yaml
@kubectl apply -f other-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 other-ingress --namespace other
@helm uninstall tea-ingress --namespace tea
@helm uninstall coffee-ingress --namespace coffee
@helm uninstall viking-service-clusterwide --namespace kube-system
@kubectl delete -f namespace.yaml
undeploy-kubectl:
@kubectl delete -f other-ingress.yaml
@kubectl delete -f tea-ingress.yaml
@kubectl delete -f coffee-ingress.yaml
@kubectl delete -f varnish.yaml
@kubectl delete -f nodeport.yaml
@kubectl delete -f admin-svc.yaml
@kubectl delete -f adm-secret.yaml
@kubectl delete -f other.yaml
@kubectl delete -f tea.yaml
@kubectl delete -f coffee.yaml
@kubectl delete -f rbac.yaml
@kubectl delete -f namespace.yaml
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
rules:
- host: coffee.example.com
paths:
- app: coffee
vikingAdmSvc: kube-system/varnish-ingress-admin
apps:
other:
image: nginxdemos/hello:plain-text
replicas: 2
ingress:
name: other-ingress
defaultApp:
app: other
vikingAdmSvc: kube-system/varnish-ingress-admin
apps:
tea:
image: nginxdemos/hello:plain-text
replicas: 3
ingress:
name: tea-ingress
rules:
- host: tea.example.com
paths:
- app: tea
vikingAdmSvc: kube-system/varnish-ingress-admin
nameOverride: varnish-ingress
fullnameOverride: varnish-ingress
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
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