How to support node selection when using helm install - kubernetes-helm

Using helm 2.7.3. New to helm and kubernetes. I have two worker nodes, and I want to deploy to a specific node. I've assigned unique labels to each node. I then added nodeSelector to deployment.yaml. When I run helm install it appears to be ignoring the node selection and deploys randomly between the two worker nodes.
Would like to understand the best approach to node selection when deploying with helm.

You can use something like this:
helm install --name elasticsearch elastic/elasticsearch --set \
nodeSelector."beta\\.kubernetes\\.io/os"=linux
Note: Escaping . character! Hope this helps.

See the example:
kubectl label nodes <your desired node> databases=mysql --overwrite
Check the label:
kubectl get nodes --show-labels
Run the following command:
helm create test-chart && cd test-chart
helm install . --set nodeSelector.databases=mysql

in ansible task
- name: install etcd middleware
command:
chdir: /var/lib/kube/controlpanel/component
cmd: "{{tools.helm.path}} upgrade etcd ./etcd --install --namespace=middleware --set replicaCount=3 --set nodeSelector.\"xxx\\.yyy\\.local/node-role-middleware\"="

You can use this one example:
helm upgrade --install airflow apache-airflow/airflow --namespace airflow --create-namespace --set {nodeSelector="your-worker-node-name"}
--set allows setting for required parameters.
The following link provides the supported parameters of the mentioned example:
https://airflow.apache.org/docs/helm-chart/stable/parameters-ref.html#kubernetes
You can set many parameters using many --set. Look at the link:https://helm.sh/docs/helm/helm_install/. This is the example:
helm install --set foo=bar --set foo=newbar myredis ./redis
Just check that the nodeSelector parameter is supported by your chart.

Related

helm deployments over kustomize

Say for example I have rendered all the manifests of a tool called cert-manager and I have deployed in kubernetes environment using kustomize, If I want to perform an upgrade version of cert-manager through helm, How do I do that??
You can just run the command
helm repo add jetstack https://charts.jetstack.io
update the variable or value you would like to change
helm install \
cert-manager jetstack/cert-manager \
--namespace cert-manager \
--create-namespace \
--version v1.7.1 \
# --set installCRDs=true
make sure you use the same name of deployment or stateful sets, so accordingly PODs or deployment will get rolled out.
i think, the cert-manager does not use the PVC or PV so nothing worry about the Read Write Many.
Ref doc : https://cert-manager.io/docs/installation/helm/

Helm Chart - How to validate the chart without installing?

I am using the following command to install the Helm chart
helm upgrade myRelease azureacr/chart --namespace calculator --install --set replicaCount=4 --set image.repository=my.azurecr.io --set canary=false --wait --timeout 45s
it works perfectly fine.
However, I want to (re)view the generated chart before installing it? The below command just prints the template and I don't know how to pass the parameters to it
helm template myRelease
In other words, I know that the value of "c" is 2 for the below code
var a = 1, b = 1, c = a +b
In the same way, is there a way to get the final chart by applying the required parameters?
You can try using --dry-run command in helm install something like this
helm upgrade myRelease azureacr/chart --namespace calculator --install --set replicaCount=4 --set image.repository=my.azurecr.io --set canary=false --wait --timeout 45s --dry-run --debug
It's a great way to have the server render your templates, then return the resulting manifest file.

Trying to install Kong using the Helm chart

Trying to install Kong using the Helm chart using the following command using this post
>helm install --version 0.26.1 --name kong stable/kong --namespace kong --set ingressController.enabled=true --set image.tag=1.4 --set admin.useTLS=false
But getting the following error
Error: unknown flag: --name
Solution I tried
Removed -- name then I am getting the following error
Error: failed to download "stable/kong" (hint: running helm repo update may help)
Can anyone please help me with this?
In helm version 3 --name flag is removed. You can give a name without --name flag as shown below
helm repo add kong https://charts.konghq.com
helm repo update
helm install --version 1.7.0 kong kong/kong --namespace kong --set ingressController.enabled=true --set image.tag=1.4 --set admin.useTLS=false
Find more details here

How to install helm chart prometheus-operator on GKE with prometheusOperator.admissionWebhooks.enabled=false?

I want to install the helm chart stable/prometheus-operator on a GKE cluster. I'm aware that either firewall rules need to be adjusted or hooks need to be disabled by setting prometheusOperator.admissionWebhooks.enabled=false (for details see the README of the chart).
However, if I install the chart with
- wget -qq https://get.helm.sh/helm-v3.0.0-linux-amd64.tar.gz && tar xf helm-v3.0.0-linux-amd64.tar.gz && mv linux-amd64/helm /usr/local/bin
- helm repo add stable https://kubernetes-charts.storage.googleapis.com/
- helm repo update
- kubectl create ns monitoring
- kubectl apply -f https://raw.githubusercontent.com/coreos/prometheus-operator/master/example/prometheus-operator-crd/alertmanager.crd.yaml
- kubectl apply -f https://raw.githubusercontent.com/coreos/prometheus-operator/master/example/prometheus-operator-crd/prometheus.crd.yaml
- kubectl apply -f https://raw.githubusercontent.com/coreos/prometheus-operator/master/example/prometheus-operator-crd/prometheusrule.crd.yaml
- kubectl apply -f https://raw.githubusercontent.com/coreos/prometheus-operator/master/example/prometheus-operator-crd/servicemonitor.crd.yaml
- kubectl apply -f https://raw.githubusercontent.com/coreos/prometheus-operator/master/example/prometheus-operator-crd/podmonitor.crd.yaml
- helm install monitoring stable/prometheus-operator --namespace=monitoring --wait --timeout 10m --set prometheusOperator.admissionWebhooks.enabled=false
in GitLab CI the pod prometheus-operator has two containers which remain in state "Pending" for 5 minutes. I expect this rather simple setup to be available within one minute.
You can inspect the cluster setup at https://gitlab.com/krichter/prometheus-operator-503/-/jobs/358887366.
The approach shown in Installing Prometheus on GKE + istio doesn't apply because I didn't install istio.
This is caused by a known issue in the helm chart. According to https://github.com/helm/charts/issues/19147 the issue can be avoided by setting prometheusOperator.tlsProxy.enabled=false.

Is there something like `helm exec`?

I use the following helm (2.4.2) commands in my gitlab-ci.yml script:
- helm upgrade --install myapp-db --wait --set postgresUser=postgres,postgresPassword=postgres,postgresDatabase=myapp stable/postgresql
- helm upgrade --install myapp-web ./myapp-chart --wait --set env.DATABASE_URL="${DATABASE_URL}"
It's part of a deployment to my staging/review environment. After the above commands complete, I would like to execute commands against the my-app pod to create/migrate the database. At the moment this is achieved through the use of an initContainer (defined in the referenced yaml file). But I would prefer the logic to be part of the CI script - so I don't have to have a separate deployment file for production.
Is there a way to do this with helm? Or is my only option to use kubectl exec? If I use kubectl exec, is there an easy way to get the name of the pod using helm?
This GitHub issue addresses how you might use kubectl to find out the name of a pod based on a label:
https://github.com/kubernetes/kubernetes/issues/8876
I implemented the following:
- export POD_NAME=`kubectl get pod -l "app=myapp-web-chart" -o jsonpath='{.items[0].metadata.name}'`
- kubectl exec $POD_NAME -- mix ecto.migrate
Still, it would be much nicer if there was a way to do this with helm