How do I lookup configMap values to build k8s manifest using ArgoCD - kubernetes

I'm using ArgoCD for gitops deployments right now and I have k8s manifest files that require configMap values to be built (via helm right now). However, ArgoCD does not allow me to use helm lookup feature so I can't have that in my helm chart.
I have a helm chart that uses helm lookup to pull values from a configMap to build a k8s manifest file (pretty common). The problem is that argocd does not allow me to use the helm lookup functionality when it is deploying the helm chart. Has anyone come across this situation where you need to build a manifest file using values in a configMap while using ArgoCD? How did you accomplish that? Any help is greatly appreciated.

I think this is a well-known issue for ArgoCD to work with helm, I think the below thread will be helpful for you.
https://github.com/argoproj/argo-cd/issues/5202

Related

Migrate Kubernetes manifests to Helm charts

I'm currently deploying k8s using manifests and kubectl command.
Is there any automated way to convert these manifests to Helm charts?
If not, can you please give me a template or examples to follow in order to do this migration manually?
Thank you.
I tried helmify CLI but I was unable to install it.

How does ArgoCD sync/update a updated helm chart under the hood?

our team right now is using helm chart to deploy services to k8s cluster, and ArgoCD to sync the helm chart modification to k8s cluster.
My question is that, when ArgoCD performs a helm chart sync, what action does it do under the hood? does it use the command "helm upgrade" to do it? or else?
Thanks
Argo does not perform a helm install or helm upgrade of sorts; it is more closely related to a helm template <cmd+opts> | kubectl apply -f -.
I think you should look into the concept of GitOps.
Argo CD is responsible for pulling updated code from Git repositories
and deploying it directly to Kubernetes resources.
(quoted from https://codefresh.io/learn/argo-cd/)
I think best way is to package the chart into a CR instances in your env and then give argocd credentials to access the charts
The trick is how would you give argocd credentials and also if you have multiple charts how do sync all in one go

Apply Github hosted Kubernetes file with Helm

I am trying to set up a helmfile deployment for my local kubernetes cluster which is running using 'kind' (a lightweight alternative to minikube). I have charts set up for my app which are all deploying correctly, however I require an nginx-ingress controller. Luckily 'kind' provides one, which I am currently applying with the command:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
It seems perverse that I should have everything else set up to deploy at the touch of a button, but still have to 'remember' (and also train my colleagues to remember...) to run this additional command.
I realise I could copy and paste and create my own version, but I would like to keep up to date with any changes made at source. Is it possible to create a chart that makes a reference to an external template?
I am looking at solutions using either helm or helmfile.
Your linked YAML file seems to have been generated from the ingress-nginx chart.
Subchart
You can include ingress-nginx as a subchart in Helm 3 by adding it as a dependency to your own chart. In Helm 3, this is done with the dependencies field in Chart.yaml, e.g.:
apiVersion: v2
name: my-chart
version: 0.1.0
dependencies:
- name: ingress-nginx
version: ~4.0.6
repository: https://kubernetes.github.io/ingress-nginx
condition: ingress-nginx.enabled
This may be problematic, however, if you need to install multiple versions of your own chart in the same cluster. To handle this, you'd need to consider the implications of multiple Ingress controllers.
Chart
Ingress controllers are capable of handling ingresses from various releases across multiple namespaces. Therefore, I would recommend maintaining ingress-nginx separately from your own releases that depend on it. This would mean installing ingress-nginx like you already are or as a separate chart (guide).
If you go this route, there are tools that help make it easier for devs to take a hands-off approach for setting up their K8s environments. Some popular ones include Skaffold, DevSpace, Tilt, and Helmfile.

Is There a Way to Detect Changes made to Resources Deployed by a Helm Chart

We have several resources deployed as part of a helm (v3) chart. Some time ago, I made changes to resources deployed by that helm chart manually, via kubectl. This caused some drift between the values in the yaml resources deployed by the helm release (as show by helm get values <release>) and what is actually deployed in the cluster
Example: kubectl describe deployment <deployment> shows an updated image that was manually applied via a kubectl re-apply. Whereas helm show values <release> shows the original image used by helm for said deployment.
I realize that I should have performed a helm upgrade with a modified values.yaml file to execute the image change, but I am wondering if there is a way for me to sync the state of the values I manually updated with the values in the helm release. The goal is to create a new default values.yaml that reflect the current state of the cluster resources.
Thanks!
This is a community wiki answer posted for better visibility. Feel free to expand it.
According to the Helm issue 2730 this feature will not be added in the Helm, as it is outside of the scope of the project.
It looks like there is no existing tool right from the Helm, that would help to port/adapt the life kubernetes resource back into existing or new helm charts/releases.
Based on this, you can use one of the following options:
As suggested by #David Maze. The Helm Diff Plugin will show you the difference between the chart output and the cluster, but then you need to manually update values.yaml and templates.
The helm-adopt plugin is a helm plugin to adopt existing k8s resources into a new generated helm chart.

Create custom helm charts

I'm using helm charts to create deploy micro services, by executing helm create it creates basic chart with deployment, services and ingress but I have few other configurations such as horizontal pod autoscaler, pod disruption budget.
what I do currently copy the yaml and change accordingly, but this takes lot of time and I don't see this as a (correct way/best practice) to do it.
helm create <chartname>
I want to know how you can create helm charts and have your extra configurations as well.
Bitnami's guide to creating your first helm chart describes helm create as "the best way to get started" and says that "if you already have definitions for your application, all you need to do is replace the generated YAML files for your own". The approach is also suggested in the official helm docs and the chart developer guide. So you are acting on best advice.
It would be cool if there were a wizard you could use to take existing kubernetes yaml files and make a helm chart from them. One tool like this that is currently available is chartify. It is listed on helm's related projects page (and I couldn't see any others that would be relevant).
You can try using Move2Kube. You will have to put all your yamls (if the source is kubernetes yamls) or other source artifacts in a directory (say src) and do move2kube translate -s src/.
In the wizard that comes up, you can choose helm instead of yamls and it will create a helm chart for you.