Commit 8b61abca authored by Elisabetta Giani's avatar Elisabetta Giani
Browse files

k8s-configuration: first step to implement chart/subchart in CSP.LMC

parent 452d0a0c
Loading
Loading
Loading
Loading
Loading
+20 −36
Original line number Diff line number Diff line
@@ -20,36 +20,17 @@ delete_namespace: ## delete the kubernetes namespace
	kubectl describe namespace $(KUBE_NAMESPACE) && kubectl delete namespace $(KUBE_NAMESPACE); \
	fi

deploy: namespace mkcerts  ## deploy the helm chart
	@helm template $(HELM_RELEASE) charts/$(HELM_CHART)/ \
deploy: namespace mkcerts depends ## deploy the helm chart
	@helm install $(HELM_RELEASE) charts/$(HELM_CHART)/ \
		--namespace $(KUBE_NAMESPACE) \
		--set xauthority="$(XAUTHORITYx)" \
		--set display="$(DISPLAY)" \
		--set ingress.hostname=$(INGRESS_HOST) \
		--set helmTests=false \
		 | kubectl -n $(KUBE_NAMESPACE) apply -f -
		--set tango-base.enabled=$(TANGO_BASE_ENABLED) \
		--set helmTests=false 

deploy_all: namespace mkcerts ## deploy ALL of the helm chart
	@for i in charts/*; do \
	helm template $(HELM_RELEASE) $$i \
				 --namespace $(KUBE_NAMESPACE) \
	             --set display="$(DISPLAY)" \
	             --set xauthority="$(XAUTHORITYx)" \
				 --set ingress.hostname=$(INGRESS_HOST) \
				 --set ingress.nginx=$(USE_NGINX) \
	             --set tangoexample.debug="$(REMOTE_DEBUG)" | kubectl apply -f - ; \
	done

delete_all: ## delete ALL of the helm chart release
	@for i in charts/*; do \
	helm template $(HELM_RELEASE) $$i \
				 --namespace $(KUBE_NAMESPACE) \
	             --set display="$(DISPLAY)" \
	             --set xauthority="$(XAUTHORITYx)" \
				 --set ingress.hostname=$(INGRESS_HOST) \
				 --set ingress.nginx=$(USE_NGINX) \
	             --set tangoexample.debug="$(REMOTE_DEBUG)" | kubectl delete -f - ; \
	done
delete: ## delete the helm chart release
	@helm uninstall $(HELM_RELEASE) --namespace $(KUBE_NAMESPACE)

install: namespace mkcerts  ## install the helm chart
	@helm install $(HELM_RELEASE) charts/$(HELM_CHART)/ \
@@ -59,7 +40,7 @@ install: namespace mkcerts ## install the helm chart
		--set ingress.hostname=$(INGRESS_HOST)

show: mkcerts ## show the helm chart
	@helm $(HELM_RELEASE) charts/$(HELM_CHART)/ \
	@helm template $(HELM_RELEASE) charts/$(HELM_CHART)/ \
		--namespace $(KUBE_NAMESPACE) \
		--set xauthority="$(XAUTHORITYx)" \
		--set display="$(DISPLAY)" \
@@ -72,15 +53,6 @@ chart_lint: ## lint check the helm chart
		--set xauthority="$(XAUTHORITYx)" \
		--set display="$(DISPLAY)" \

delete: ## delete the helm chart release (without Tiller)
	@helm template $(HELM_RELEASE) charts/$(HELM_CHART)/ \
		--namespace $(KUBE_NAMESPACE) \
		--set xauthority="$(XAUTHORITYx)" \
		--set display="$(DISPLAY)" \
		--set ingress.hostname=$(INGRESS_HOST) \
		--set helmTests=false \
		 | kubectl -n $(KUBE_NAMESPACE) delete -f -

helm_delete: ## delete the helm chart release (with Tiller)
	@helm delete $(HELM_RELEASE) --purge \

@@ -193,6 +165,13 @@ kubeconfig: ## export current KUBECONFIG as base64 ready for KUBE_CONFIG_BASE64
	echo "appended to: PrivateRules.mak"; \
	echo -e "\n\n# base64 encoded from: kubectl config view --flatten\nKUBE_CONFIG_BASE64 = $${KUBE_CONFIG_BASE64}" >> PrivateRules.mak

wait:
	@echo "Waiting for device servers to be ready"
	@date
	@kubectl -n $(KUBE_NAMESPACE) get pods -l tangoServer
	@kubectl -n $(KUBE_NAMESPACE) wait --for=condition=ready --timeout=120s -l cspServer pods
	@date

#
# defines a function to copy the ./test-harness directory into the K8s TEST_RUNNER
# and then runs the requested make target in the container.
@@ -215,7 +194,7 @@ k8s_test = tar -c test-harness/ | \
# base64 payload is given a boundary "~~~~BOUNDARY~~~~" and extracted using perl
# clean up the run to completion container
# exit the saved status
k8s_test: ## test the application on K8s
k8s_test: deploy show wait## test the application on K8s
	$(call k8s_test,test); \
	  status=$$?; \
	  rm -fr build; \
@@ -224,8 +203,10 @@ k8s_test: ## test the application on K8s
		perl -ne 'BEGIN {$$on=0;}; if (index($$_, "~~~~BOUNDARY~~~~")!=-1){$$on+=1;next;}; print if $$on % 2;' | \
		base64 -d | tar -xzf -; \
		kubectl --namespace $(KUBE_NAMESPACE) delete pod $(TEST_RUNNER); \
	  make delete
	  exit $$status


rlint:  ## run lint check on Helm Chart using gitlab-runner
	if [ -n "$(RDEBUG)" ]; then DEBUG_LEVEL=debug; else DEBUG_LEVEL=warn; fi && \
	gitlab-runner --log-level $${DEBUG_LEVEL} exec $(EXECUTOR) \
@@ -290,3 +271,6 @@ help: ## show this help.
	@grep -hE '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
	@echo ""; echo "make vars (+defaults):"
	@grep -hE '^[0-9a-zA-Z_-]+ \?=.*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = " \?\= "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\#\#/  \#/'

depends:
	helm dependency update charts/$(HELM_CHART)/
+9 −5
Original line number Diff line number Diff line
@@ -23,18 +23,23 @@ KUBE_NAMESPACE ?= integration
HELM_RELEASE ?= test

# HELM_CHART the chart name
HELM_CHART ?= csp-lmc-mid
HELM_CHART ?= mid-csp

# HELM CHART PACKAGE
HELM_PACKAGE ?= charts/csp-proto

# INGRESS_HOST is the host name used in the Ingress resource definition for
# publishing services via the Ingress Controller
INGRESS_HOST ?= $(HELM_RELEASE).$(HELM_CHART).local

# Optional creation of the tango-base dependency
ENABLE_TANGO_BASE ?= true

# Fixed variables
# Timeout for gitlab-runner when run locally
TIMEOUT = 86400
# Helm version
HELM_VERSION = v2.14.0
HELM_VERSION = v3.2.4
# kubectl version
KUBERNETES_VERSION = v1.14.1

@@ -73,14 +78,13 @@ TEST_RUNNER = test-runner-$(HELM_CHART)-$(HELM_RELEASE)
# ('make interactive', 'make test', etc.) are defined in this file.
#
include .make/release.mk
include .make/docker.mk
include .make/k8s.mk
include .make/postdeploy.mk

package: ## package all existing charts into a git based repo
	mkdir -p helm-repo
	@for i in charts/*; do \
	helm package $${i} --destination ./helm-repo ; \
	done
	helm package $(HELM_PACKAGE) --destination ./helm-repo ; \
	cd ./helm-repo && helm repo index .

.PHONY: all test up down help k8s show lint deploy delete logs describe mkcerts localip namespace delete_namespace ingress_check kubeconfig kubectl_dependencies helm_dependencies rk8s_test k8s_test rlint
+0 −7
Original line number Diff line number Diff line
apiVersion: v2
name: csp-lmc-mid
description: A Helm chart for deploying the MID CSP.LMC collection
type: application
version: 0.1.0
appVersion: 0.1.0
icon: https://www.skatelescope.org/wp-content/uploads/2016/07/09545_NEW_LOGO_2014.png
−6 KiB

File deleted.

+0 −6
Original line number Diff line number Diff line
apiVersion: v1
appVersion: "1.0"
description: A Helm chart for deploying the TANGO base system on Kubernetes
name: tango-base
version: 0.1.0
icon: https://www.skatelescope.org/wp-content/uploads/2016/07/09545_NEW_LOGO_2014.png
Loading