Creating a Helm App w Argocd
When you need to create a helm application for Argocd to deploy a Helm chart, it can feel a little confusing.
You go to a docs page and read thier installation guide and all you see is
Example: Traefik
helm repo add traefik https://traefik.github.io/charts
helm repo update
helm install traefik traefik/traefik
Where do you even begin?
How does this map to the argocd CRD?
How do I add a values file, I'm just getting an error?
Why is it looking in the helm charts repo for my values file?
The truth is, once you see it once, you can retrace the the steps to make any Argocd Helm Application Deployment.
Boilerplate Application
Lets start by creating a boiler plate application.
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: ""
namespace: argocd
spec:
project: default
sources:
- repoURL: ''
targetRevision: ''
path: '' # Path to the Helm chart directory in your repository.
chart: ''
helm:
releaseName: ''
# valueFiles:
# # Update this to point to your custom values file if you have one.
# - $values/values.yml
# parameters:
# - name: installCRD
# value: "true"
## IF VALUES FILE NEEDED
# - repoURL: ''
# targetRevision: master
# ref: values
destination:
namespace: ''
server: https://kubernetes.default.svc
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true # Allows ArgoCD to create the namespace if it doesn't exist.
# - ServerSideApply=true # Enable server-side apply
# - RespectIgnoreDifferences=true
# Needed in newest traefik chart
# ignoreDifferences:
# - kind: Service
# jqPathExpressions:
# - '.status.loadBalancer.ingress[].ipMode'
This is a good starting point to get a Helm application started.
Traefik Example
Lets use the above example
helm repo add traefik https://traefik.github.io/charts
helm repo update
helm install traefik traefik/traefik
Helm Command Mapping
Name | Mapping |
---|---|
helm repo add traefik https://traefik.github.io/charts | spec.sources.[].repoUrl |
helm install traefik traefik/traefik | spec.sources.[].path |
helm install traefik traefik/traefik | spec.sources.[].chart |
helm install traefik traefik/traefik | spec.sources.[].helm.releaseName |
So now the example Chart would look like this.
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: "traefik-system"
namespace: argocd
spec:
project: default
sources:
- repoURL: 'https://traefik.github.io/charts'
targetRevision: ''
path: traefik/traefik # Path to the Helm chart directory in your repository.
chart: traefik
helm:
releaseName: traefik
# valueFiles:
# - $values/values.yml # Update this to point to your custom values file if you have one.
# parameters:
# - name: installCRD
# value: "true" # Set to "true" if Traefik CRDs need to be installed.
## IF VALUES FILE NEEDED
# - repoURL: ''
# targetRevision: master
# ref: values
destination:
namespace: 'traefik'
server: https://kubernetes.default.svc
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true # Allows ArgoCD to create the namespace if it doesn't exist.
# - ServerSideApply=true # Enable server-side apply
# - RespectIgnoreDifferences=true
# Needed in newest traefik chart
# ignoreDifferences:
# - kind: Service
# jqPathExpressions:
# - '.status.loadBalancer.ingress[].ipMode'
What about the target revision?
Chart Version
Sometime you can visit the chart repo url in the browser and it will direct you to the git project for the chart.
Traefik's is here
Visit the releases tab
Copy the latest version you see or desired version to deploy.
v34.4.1
Now set it in the Target Revision.
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: "traefik-system"
namespace: argocd
spec:
project: default
sources:
- repoURL: 'https://traefik.github.io/charts'
targetRevision: 'v34.4.1'
path: traefik/traefik # Path to the Helm chart directory in your repository.
chart: traefik
helm:
releaseName: traefik
# valueFiles:
# - $values/values.yml # Update this to point to your custom values file if you have one.
# parameters:
# - name: installCRD
# value: "true" # Set to "true" if Traefik CRDs need to be installed.
## IF VALUES FILE NEEDED
# - repoURL: ''
# targetRevision: master
# ref: values
destination:
namespace: 'traefik'
server: https://kubernetes.default.svc
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true # Allows ArgoCD to create the namespace if it doesn't exist.
# - ServerSideApply=true # Enable server-side apply
# - RespectIgnoreDifferences=true
# Needed in newest traefik chart
# ignoreDifferences:
# - kind: Service
# jqPathExpressions:
# - '.status.loadBalancer.ingress[].ipMode'
We are now ready to deploy this!
But what if you need values?
Helm Values
You will get some errors if you try to add a values file in the repo with this file. it will only get from the traefik helm chart project.
To fix this you need to use the parameters in the helm section or add a values ref.
Values Ref
## IF VALUES FILE NEEDED
# - repoURL: ''
# targetRevision: master
# ref: values
This is the section of code that we are goin to uncomment.
Name | Mapping |
---|---|
Repo Where this helm App is being deployed from | repoUrl |
targetRevision | "branch to deploy on" |
ref to use in yml for this repo | ref |
We are going to use this repo i have set with a traefik values file to deploy this.
The values file is in the root of the project `values.yml
Lets add it to our argo helm depployment
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: "traefik-system"
namespace: argocd
spec:
project: default
sources:
- repoURL: 'https://traefik.github.io/charts'
targetRevision: 'v34.4.1'
path: traefik/traefik # Path to the Helm chart directory in your repository.
chart: traefik
helm:
releaseName: traefik
# Update this to point to your custom values file if you have one.
valueFiles:
- $values/values.yml
# parameters:
# - name: installCRD
# value: "true" # Set to "true" if Traefik CRDs need to be installed.
# IF VALUES FILE NEEDED
- repoURL: 'https://gitlab.com/d3vbd/hlab-cluster/traefik.git'
targetRevision: master
ref: values
destination:
namespace: 'traefik'
server: https://kubernetes.default.svc
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true # Allows ArgoCD to create the namespace if it doesn't exist.
# - ServerSideApply=true # Enable server-side apply
# - RespectIgnoreDifferences=true
# Needed in newest traefik chart
# ignoreDifferences:
# - kind: Service
# jqPathExpressions:
# - '.status.loadBalancer.ingress[].ipMode'
Now you have a full helm deployment with a values file!
Bonus Traefik Settings
Was having issues with this ipMode
in the service and found a workaround to use the ignoreDifferences
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: "traefik-system"
namespace: argocd
spec:
project: default
sources:
- repoURL: 'https://traefik.github.io/charts'
targetRevision: 'v34.4.1'
path: traefik/traefik # Path to the Helm chart directory in your repository.
chart: traefik
helm:
releaseName: traefik
valueFiles:
- $values/values.yml
- repoURL: 'https://gitlab.com/d3vbd/hlab-cluster/traefik.git'
targetRevision: master
ref: values
destination:
namespace: 'traefik'
server: https://kubernetes.default.svc
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true # Allows ArgoCD to create the namespace if it doesn't exist.
- ServerSideApply=true # Enable server-side apply
- RespectIgnoreDifferences=true
# Needed in newest traefik chart
ignoreDifferences:
- kind: Service
jqPathExpressions:
- '.status.loadBalancer.ingress[].ipMode'