1
votes

I am new to Helm Kubernetes. I am currently using a list of bash commands to create a local Minikube cluster with many containers installed. In order to alleviate the manual burden we were thinking of creating an (umbrella) Helm Chart to execute the whole list of commands.

Between the commands that I would need to run in the Chart there are few (cleanup) kubectl deletes, i.e. :

kubectl delete all,configmap --all -n system --force --grace-period=0

and also some helm installs, i.e.:

helm repo add bitnami https://charts.bitnami.com/bitnami && \
helm install postgres bitnami/postgresql --set postgresqlPassword=test,postgresqlDatabase=test && \

Question1: is it possible to include kubectl command in my Helm Chart?

Question2: is it possible to add a dependency from a Chart only remotely available? I.e. the dependency from postgres above.

Question3: If you think Helm is not the correct tool for doing this, what would you suggest instead?

Thank you

1
What would that kubectl command delete, in practice? That seems a little blunt to run routinely. - David Maze
Hi @DavidMaze, the kubectl delete is used to reset and clean-up the environment before any new deployment. This deployment is used for the dev laptop environments so we need to make sure the helm chart start with a brand new installation every time it is needed. - sommario
I'd suggest helm delete the old installation, or in a laptop environment use a tool like minikube or kind where it's easy to delete the whole (single-container) "cluster". - David Maze
thank you @DavidMaze - sommario

1 Answers

1
votes

You can't embed imperative kubectl commands in a Helm chart. An installed Helm chart keeps track of a specific set of Kubernetes resources it owns; you can helm delete the release, and that will delete that specific set of things. Similarly, if you have an installed Helm chart, you can helm upgrade it, and the new chart contents will replace the old ones.

For the workflow you describe – you're maintaining a developer environment based on Minikube, and you want to be able to start clean – there are two good approaches to take:

  1. helm delete the release(s) that are already there, which will uninstall their managed Kubernetes resources; or
  2. minikube delete the whole "cluster" (as a single container or VM), and then minikube start a new empty "cluster".