From c33eb66752237d4ee2dd540adf370f05abf75886 Mon Sep 17 00:00:00 2001 From: Dominik Chilla Date: Thu, 27 Aug 2020 14:48:58 +0200 Subject: [PATCH] helm --- README.md | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) diff --git a/README.md b/README.md index 6f9adce..32ae4f5 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,14 @@ * [Stick the nginx-ingress controler and my-nginx app together](#stick-nginx-ingress-and-tcp-service) * [Test exposed app on TCP-port 9000](#test-nginx-ingress-and-tcp-service) * [Running DaemonSets on `hostPort`](#running-daemonsets) +* [HELM charts](#helm) + * [Create a chart](#helm-create) + * [Install local chart without](#packaging helm-install-without-packaging) + * [List deployed helm charts](#helm-list) + * [Upgrade local chart without packaging](#helm-upgrade) + * [Get status of deployed chart](#helm-status) + * [Get deployment history](#helm-history) + * [Rollback](#helm-rollback) ## Install k3s https://k3s.io/: @@ -309,4 +317,136 @@ spec: rollingUpdate: maxUnavailable: 1 type: RollingUpdate +``` + +# HELM charts +Docs: +* https://helm.sh/docs/intro/using_helm/ + +Prerequisites: +* running kubernetes installation +* kubectl with ENV[KUBECONFIG] pointing to appropriate config file +* helm + +## Create a chart +`helm create helm-test` + +``` +~/kubernetes/helm$ tree helm-test/ +helm-test/ +├── charts +├── Chart.yaml +├── templates +│   ├── deployment.yaml +│   ├── _helpers.tpl +│   ├── hpa.yaml +│   ├── ingress.yaml +│   ├── NOTES.txt +│   ├── serviceaccount.yaml +│   ├── service.yaml +│   └── tests +│   └── test-connection.yaml +└── values.yaml +``` + +## Install local chart without packaging +`helm install helm-test-dev helm-test/ --set image.tag=latest --debug --wait` + +or just a *dry-run*: + +`helm install helm-test-dev helm-test/ --set image.tag=latest --debug --dry-run` + +``` +--wait: Waits until all Pods are in a ready state, PVCs are bound, Deployments have minimum (Desired minus maxUnavailable) +Pods in ready state and Services have an IP address (and Ingress if a LoadBalancer) before marking the release as successful. +It will wait for as long as the --timeout value. If timeout is reached, the release will be marked as FAILED. Note: In +scenarios where Deployment has replicas set to 1 and maxUnavailable is not set to 0 as part of rolling update strategy, + +--wait will return as ready as it has satisfied the minimum Pod in ready condition. +``` + +## List deployed helm charts +``` +~/kubernetes/helm$ helm list +NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION +helm-test-dev default 4 2020-08-27 12:30:38.98457042 +0200 CEST deployed helm-test-0.1.0 1.16.0 +``` + +## Upgrade local chart without packaging +``` +~/kubernetes/helm$ helm upgrade helm-test-dev helm-test/ --set image.tag=latest --wait --timeout 60s +Release "helm-test-dev" has been upgraded. Happy Helming! +NAME: helm-test-dev +LAST DEPLOYED: Thu Aug 27 12:47:09 2020 +NAMESPACE: default +STATUS: deployed +REVISION: 7 +NOTES: +1. Get the application URL by running these commands: + export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=helm-test,app.kubernetes.io/instance=helm-test-dev" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace default port-forward $POD_NAME 8080:80 +``` +`helm upgrade [...] --wait` is synchronous and exit with 0 on success, otherwise with >0 on failure. `helm upgrade` will wait for 5 minutes Setting the `--timeout` (Default 5 minutes) flag makes This can be used in term of CI/CD deployments with Jenkins. + +## Get status of deployed chart +``` +~/kubernetes/helm$ helm status helm-test-dev +NAME: helm-test-dev +LAST DEPLOYED: Thu Aug 27 12:47:09 2020 +NAMESPACE: default +STATUS: deployed +REVISION: 7 +NOTES: +1. Get the application URL by running these commands: + export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=helm-test,app.kubernetes.io/instance=helm-test-dev" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace default port-forward $POD_NAME 8080:80 +``` + +## Get deployment history +``` +~/kubernetes/helm$ helm history helm-test-dev +REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION +10 Thu Aug 27 12:56:33 2020 failed helm-test-0.1.0 1.16.0 Upgrade "helm-test-dev" failed: timed out waiting for the condition +11 Thu Aug 27 13:08:34 2020 superseded helm-test-0.1.0 1.16.0 Upgrade complete +12 Thu Aug 27 13:09:59 2020 superseded helm-test-0.1.0 1.16.0 Upgrade complete +13 Thu Aug 27 13:10:24 2020 superseded helm-test-0.1.0 1.16.0 Rollback to 11 +14 Thu Aug 27 13:23:22 2020 failed helm-test-0.1.1 blubb Upgrade "helm-test-dev" failed: timed out waiting for the condition +15 Thu Aug 27 13:26:43 2020 pending-upgrade helm-test-0.1.1 blubb Preparing upgrade +16 Thu Aug 27 13:27:12 2020 superseded helm-test-0.1.1 blubb Upgrade complete +17 Thu Aug 27 14:32:32 2020 superseded helm-test-0.1.1 Upgrade complete +18 Thu Aug 27 14:33:58 2020 superseded helm-test-0.1.1 Upgrade complete +19 Thu Aug 27 14:36:49 2020 failed helm-test-0.1.1 cosmetics Upgrade "helm-test-dev" failed: timed out waiting for the condition +``` + +## Rollback +`helm rollback helm-test-dev 18 --wait` +``` +~/kubernetes/helm$ helm history helm-test-dev +REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION +10 Thu Aug 27 12:56:33 2020 failed helm-test-0.1.0 1.16.0 Upgrade "helm-test-dev" failed: timed out waiting for the condition +11 Thu Aug 27 13:08:34 2020 superseded helm-test-0.1.0 1.16.0 Upgrade complete +12 Thu Aug 27 13:09:59 2020 superseded helm-test-0.1.0 1.16.0 Upgrade complete +13 Thu Aug 27 13:10:24 2020 superseded helm-test-0.1.0 1.16.0 Rollback to 11 +14 Thu Aug 27 13:23:22 2020 failed helm-test-0.1.1 blubb Upgrade "helm-test-dev" failed: timed out waiting for the condition +15 Thu Aug 27 13:26:43 2020 pending-upgrade helm-test-0.1.1 blubb Preparing upgrade +16 Thu Aug 27 13:27:12 2020 superseded helm-test-0.1.1 blubb Upgrade complete +17 Thu Aug 27 14:32:32 2020 superseded helm-test-0.1.1 Upgrade complete +18 Thu Aug 27 14:33:58 2020 superseded helm-test-0.1.1 Upgrade complete +19 Thu Aug 27 14:36:49 2020 failed helm-test-0.1.1 cosmetics Upgrade "helm-test-dev" failed: timed out waiting for the condition +20 Thu Aug 27 14:37:36 2020 deployed helm-test-0.1.1 Rollback to 18 +``` +``` +~/kubernetes/helm$ helm status helm-test-dev +NAME: helm-test-dev +LAST DEPLOYED: Thu Aug 27 14:37:36 2020 +NAMESPACE: default +STATUS: deployed +REVISION: 20 +NOTES: +1. Get the application URL by running these commands: + export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=helm-test,app.kubernetes.io/instance=helm-test-dev" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace default port-forward $POD_NAME 8080:80 ``` \ No newline at end of file