A template is a form that has placeholders that an automated process will parse to replace them with values. Designed to perform a specific function, it marks the places where you must provide the specifics. An overlay is a set of replacement strings. Blocks of text in the original file are entirely replaced with new blocks of text.
- A template needs to be carefully prepared to demand specific information in key places. When you use a template, you’re restricted to changing only those elements the template makes available.
- An overlay doesn’t require the original file to be prepared in any way. You can replace any part in its entirety.
https://helm.sh/docs/intro/install/
brew install helm
wget https://get.helm.sh/helm-v3.3.4-linux-amd64.tar.gz
sudo mv linux-amd64/helm /usr/local/bin/helm
tar -zvxf helm-v3.3.4-linux-amd64.tar.gz
creates a chart directory along with the common files and directories used in a chart:
helm create mychart
Install a chart from current directory:
$ helm install helloworld .
NAME: helloworld
LAST DEPLOYED: Wed Apr 21 11:39:14 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
Uninstall chart from k8s:
helm delete mychart
$ helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
"prometheus-community" has been added to your repositories
helm list # find the release name to delete
helm uninstall <release_name>
helm fetch prometheus-community/prometheus --untar
helm install -f values.yaml rbac-manager . -n rbac-manager
helm upgrade -f values.yaml rbac-manager . -n rbac-manager
helm template myprom prometheus-community/prometheus > k8s-myprom.yaml
kubectl apply -f k8s-myprom.yaml
ls mydir/ | xargs -I {} helm template . --set cluster=$(kubectl config current-context) -f {} | k apply -f -
$ helm template --release-name hpcc -f values.yaml . | k apply -f -
serviceaccount/hpcc-node-problem-detector created
configmap/hpcc-node-problem-detector-custom-config created
clusterrole.rbac.authorization.k8s.io/hpcc-node-problem-detector created
clusterrolebinding.rbac.authorization.k8s.io/hpcc-node-problem-detector created
Warning: spec.template.metadata.annotations[scheduler.alpha.kubernetes.io/critical-pod]: non-functional in v1.16+; use the "priorityClassName" field instead
daemonset.apps/hpcc-node-problem-detector created
$ kubectl create ns monitoring
gengwg@gengwg-mbp:~$ helm install hello-prom prometheus-community/kube-prometheus-stack -n monitoring
gengwg@gengwg-mbp:~$ helm list -n monitoring
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
hello-prom monitoring 1 2021-11-23 10:03:43.545979 -0800 PST deployed kube-prometheus-stack-20.0.1 0.52.0
gengwg@gengwg-mbp:~$ helm uninstall hello-prom -n monitoring
helm upgrade -i --create-namespace kubecost -f values.yaml . --namespace kubecost --set kubecostToken="xxxxxxxx"
helm template -f values.yaml . --set cluster=$cluster --set namespace=$ns --set groups={"group1", "group2"}
Sometimes you see errors like this:
~/k8s/kube-prometheus-stack$ helm upgrade --install myprom -f values-xyz.yaml .
Error: UPGRADE FAILED: another operation (install/upgrade/rollback) is in progress
Check the history:
~/k8s/kube-prometheus-stack$ helm history myprom
REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION
5 Fri Jul 29 18:57:04 2022 superseded kube-prometheus-stack-19.0.3 0.50.0 Upgrade complete
6 Fri Jul 29 19:03:17 2022 superseded kube-prometheus-stack-19.0.3 0.50.0 Upgrade complete
7 Tue Aug 2 17:15:01 2022 superseded kube-prometheus-stack-19.0.3 0.50.0 Upgrade complete
8 Tue Aug 2 17:22:47 2022 superseded kube-prometheus-stack-19.0.3 0.50.0 Upgrade complete
9 Tue Aug 2 17:24:12 2022 superseded kube-prometheus-stack-19.0.3 0.50.0 Upgrade complete
10 Thu Aug 4 19:44:03 2022 superseded kube-prometheus-stack-19.0.3 0.50.0 Upgrade complete
11 Thu Aug 4 19:59:15 2022 superseded kube-prometheus-stack-19.0.3 0.50.0 Upgrade complete
12 Thu Aug 4 20:21:53 2022 superseded kube-prometheus-stack-19.0.3 0.50.0 Upgrade complete
13 Tue Aug 9 15:11:37 2022 deployed kube-prometheus-stack-19.0.3 0.50.0 Upgrade complete
14 Thu Oct 20 14:59:12 2022 pending-upgrade kube-prometheus-stack-19.0.3 0.50.0 Preparing upgrade
Roll back to a working revision:
~/k8s/kube-prometheus-stack$ helm rollback myprom 13
~/k8s/kube-prometheus-stack$ helm history myprom
REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION
6 Fri Jul 29 19:03:17 2022 superseded kube-prometheus-stack-19.0.3 0.50.0 Upgrade complete
7 Tue Aug 2 17:15:01 2022 superseded kube-prometheus-stack-19.0.3 0.50.0 Upgrade complete
8 Tue Aug 2 17:22:47 2022 superseded kube-prometheus-stack-19.0.3 0.50.0 Upgrade complete
9 Tue Aug 2 17:24:12 2022 superseded kube-prometheus-stack-19.0.3 0.50.0 Upgrade complete
10 Thu Aug 4 19:44:03 2022 superseded kube-prometheus-stack-19.0.3 0.50.0 Upgrade complete
11 Thu Aug 4 19:59:15 2022 superseded kube-prometheus-stack-19.0.3 0.50.0 Upgrade complete
12 Thu Aug 4 20:21:53 2022 superseded kube-prometheus-stack-19.0.3 0.50.0 Upgrade complete
13 Tue Aug 9 15:11:37 2022 superseded kube-prometheus-stack-19.0.3 0.50.0 Upgrade complete
14 Thu Oct 20 14:59:12 2022 pending-upgrade kube-prometheus-stack-19.0.3 0.50.0 Preparing upgrade
15 Fri Oct 21 01:24:55 2022 deployed kube-prometheus-stack-19.0.3 0.50.0 Rollback to 13
helm upgrade --install myprom -f values-xyz.yaml . --timeout 10m
helm upgrade --install myprom -f values-xyz.yaml . --timeout 10m --debug
Error: failed pre-install: timed out waiting for the condition
helm.go:88: [debug] failed pre-install: timed out waiting for the condition
Check the recent events in the namespace:
kubectl get events --sort-by='{.lastTimestamp}' -n monitoring
You usually will find the reason it's failing to install, then deal with each issue case by case.
Some examples:
12s Warning FailedCreate job/myprom-admission-create Error creating: pods "myprom-admission-create--1-5m9q2" is forbidden: maximum cpu usage per Container is 4, but limit is 5
3s Warning FailedCreate job/myprom-admission-create Error creating: pods "myprom-admission-create--1-" is forbidden: no PriorityClass with name high was found