This article intends to explain how to create a configuration backup of an helm installed application via kubectl.
The best way to install an application in Kubernetes is helm. So they say. all you have to do, is adding your helm repo, installing your desired application and you get all your nifty stuff like a deployment, service etc. up and running.
So they say.
In an ideal world this is true, especially when you created the helm charts yourself.
I have been playing around with this kinda stuff now for 2 months and did see times again and again this to be not true, because the helm charts expect completely different environments or settings than what I have in place. So need to customize this and I prefer plain yaml manifests, which I can apply easily with kubectl, the basic cli tool to manage your cluster.
So I do I convert a helm installation into such manifests: Simply go and install something with helm, then take the existing configuration from the running cluster doing a backup.
Say we have a simple prometheus application running for our monitoring, it runs in namespace 'monitoring', where later also grafana will be running. Run this on your workstation:
kubectl -n monitoring get all,ingress,networkpolicies,configmaps,secrets -o yaml > prometheus.yaml
Usually you do already have a git versioned directory with all your yaml code. I for instance have a gitlab repo with all my manifests nicely structured, so I always know where to find this.
With that command I create a single file with all my current configurations, which I then can edit as required and re-apply manually for development or later via CICD for the production environment. However, it also contains timestamps, UIDs and internal annotations, which you want to edit out before reapplying.
Happy coding!