首页 公告 RSS

Leveraging Kustomize to Render Helm Charts and Deploying via ArgoCD

March 18, 2024 本文有 247 个字 需要花费 2 分钟阅读

Introduction

Although I have my reservations about using Helm, there are times when it’s unavoidable. In this article, I’ll introduce a method that allows Kustomize and Helm to work together, addressing my dissatisfaction with Helm.

Procedure

Previously, when I deployed with Helm, I had to pull down the entire Helm charts, modify the values.yaml, commit, and then deploy. This process was quite cumbersome. However, Kustomize supports direct rendering of Helm charts. You can refer to the following documentation:

https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/helmcharts/

For specific parameters, you can refer to the following link:

https://kubectl.docs.kubernetes.io/references/kustomize/builtins/#_helmchartinflationgenerator_

Then, you just need to add the --enable-helm parameter at compile time.

For instance, for a project, if I want to deploy a Dragonfly, it becomes incredibly simple. I only need three files, the first one being kustomization.yaml:

helmCharts:
- name: dragonfly
  repo: https://dragonflyoss.github.io/helm-charts/
  version: 1.1.32
  releaseName: dragonfly
  namespace: dragonfly
  valuesFile: values.yaml

Next is the values.yaml file, which I won’t display here.

Finally, the argo.yaml:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: 'dragonfly'
spec:
  destination:
    namespace: 'dragonfly'
    server: 'https://xxxxxxxxxxxxxxxxxxx.gr7.us-west-2.eks.amazonaws.com'
  source:
    path: 'dragonfly'
    repoURL: 'https://git.xxxxx.com/kubernetes-app-yaml.git'
    targetRevision: HEAD
  project: 'app'

Next, enable Helm support for Kustomize on ArgoCD. You can refer to the following link for specific operations:

https://argo-cd.readthedocs.io/en/release-2.8/user-guide/kustomize/#kustomizing-helm-charts

In reality, you just need to add the following content to the argocd-cm ConfigMap:

kustomize.buildOptions: --enable-helm

If you need to update your charts, simply modify the version of the charts directly. All parameters are under your control, making it very convenient.

Feel free to follow my blog at www.bboy.app

Have Fun