make-deploy/helm.mk

63 lines
1.8 KiB
Makefile
Raw Permalink Normal View History

2022-12-23 13:48:22 +00:00
MANDATORY-helm = K8S_CONTEXT HELM_CHART_NAME HELM_CHART_PATH HELM_VALUES_FILE NAMESPACE
# helm
#
2022-12-23 13:48:22 +00:00
# deploys helm charts on k8s via helm
2022-12-08 09:34:34 +00:00
#
start-helm:
2022-12-23 13:48:22 +00:00
@- echo "\n### starting deployment with helm"
@- echo "\n### setting kubernetes context to $(K8S_CONTEXT)"
2022-12-07 13:55:36 +00:00
@ kubectl config use-context $(K8S_CONTEXT)
2022-12-23 13:48:22 +00:00
ifdef TEST_MODE
@- echo "Testing chart with 'helm template --debug'"
@ envsubst < ${HELM_VALUES_FILE} | helm template ${HELM_CHART_NAME} ${HELM_CHART_PATH} --debug --values -
endif
ifdef NAMESPACE
K8S_NAMESPACE = $(NAMESPACE)
endif
2023-09-15 06:44:44 +00:00
ifdef DEBUG_MODE
@- echo "\n### deploying helm chart with --debug flag"
@- echo "-- DEBUG DEPLOYMENT --------------------"
@- echo " "
@- echo "Namespace: $(K8S_NAMESPACE)"
@- echo "Helm Chart: $(HELM_CHART_PATH)"
@- echo "Values File: $(HELM_VALUES_FILE)"
@- echo " "
@- echo "----------------------------------"
2023-09-22 07:41:40 +00:00
@ envsubst < $(HELM_VALUES_FILE) | helm upgrade $(HELM_CHART_NAME) $(HELM_CHART_PATH) -n $(K8S_NAMESPACE) --install --atomic --debug --wait --values -
ifdef ROLLBACK_MODE
@- echo "\n### rollback helm chart"
@- echo "-- DEBUG DEPLOYMENT --------------------"
@- echo " "
@- echo "Namespace: $(K8S_NAMESPACE)"
@- echo "Helm Chart: $(HELM_CHART_PATH)"
@- echo "Helm Release: $(HELM_CHART_NAME)"
@- echo " "
@- echo "----------------------------------"
@ helm rollback -n ${HELM_NAMESPACE} ${HELM_CHART_NAME}
2023-09-15 06:44:44 +00:00
else
@- echo "\n### deploying helm chart"
2022-12-23 13:48:22 +00:00
@- echo "-- DEPLOYMENT --------------------"
@- echo " "
@- echo "Namespace: $(K8S_NAMESPACE)"
2022-12-23 13:48:22 +00:00
@- echo "Helm Chart: $(HELM_CHART_PATH)"
@- echo "Values File: $(HELM_VALUES_FILE)"
@- echo " "
@- echo "----------------------------------"
2023-09-22 07:41:40 +00:00
@ envsubst < $(HELM_VALUES_FILE) | helm upgrade $(HELM_CHART_NAME) $(HELM_CHART_PATH) -n $(K8S_NAMESPACE) --install --atomic --wait --values -
2022-12-23 13:48:22 +00:00
2023-09-15 06:44:44 +00:00
endif
pull-helm:
2023-09-15 06:44:44 +00:00
# nop