Deploy Helm OCI charts with ArgoCD

Roman Pridybailo
3 min readApr 19, 2021

--

In this post, I’ll describe how to deploy OCI Helm chart using ArgoCD.

In our projects, we use Harbor both registries for docker and Helm Charts. Currently, we using Chartmuseum but in the Harbor release v2.2.0 was announced that it will be deprecated

Researching was not so long, and we found that Helm 3 supports OCI for package distribution. Also, the OCI-compatible registry, provided by Harbor since version 2.0.0

Helm 3: Commands for working with registries

Enable OCI support

$ export HELM_EXPERIMENTAL_OCI=1

Login

$ helm registry login -u <user_name> myregistry.com
Password:
Login succeeded

List all saved charts

$ helm chart list
REF NAME VERSION DIGEST SIZE CREATEDmyregistry.com/helm-charts/simple-chart:1.0.0 simple-chart 0.1.0 a8de052 4.1 KiB 8 hours
myregistry.com/helm-charts/simple-chart:1.1.2 simple-chart 0.1.0 c2afe75 4.1 KiB 19 minutes

Save a chart directory to the local cache

$ helm chart save simple-chart myregistry.com/helm-charts/simple-chart:1.1.2ref:     myregistry.com/helm-charts/simple-chart:1.1.2
digest: 43f18e1ee4df7b58b7094730566fb81964eb07a9d4d8fb
size: 4.1 KiB
name: simple-chart
version: 0.1.0
1.1.2: saved

Push a chart to remote

$ helm chart push myregistry.com/helm-charts/simple-chart:1.1.2The push refers to repository [myregistry.com/helm-charts/simple-chart]
ref: myregistry.com/helm-charts/simple-chart:1.1.2
digest: 3f0e3243f18e1ee4df7b58b7094730566fb81964eb07a9d4d8fb
size: 4.1 KiB
name: simple-chart
version: 0.1.0
1.1.2: pushed to remote (1 layer, 4.1 KiB total)

Use OCI Helm Chart

Create an empty directory with Chart.yaml and values.yaml files and push to Git repo

Chart.yaml

apiVersion: v2
name: simple-chart
description: Simple Chart
type: application
version: 0.1.0
dependencies:
- name: simple-chart
version: "1.1.2"
repository: "oci://myregistry.com/helm-charts"

values.yaml

simple-chart:
env:
myFirstEnv: 'SimpleEnv'

Build dependency and deploy Helm Chart

Go to Chart directory and run commands:

$ helm dependency buildUpdate Complete. ⎈Happy Helming!⎈
Saving 1 charts
Downloading simple-chart from repo oci://myregistry.com/helm-charts
1.1.2: Pulling from myregistry.com/helm-charts/simple-chart
Deleting outdated charts

Deploy application:

$ helm install my-application .
NAME: my-application
LAST DEPLOYED: Mon Apr 19 22:39:03 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None

Deploy an application with ArgoCD

Create helm repo with cli

argocd repo add myregistry.com --type helm --name registry --enable-oci --username <username> --password <password>

Create helm repo with yaml

This example based on the official ArgoCD Helm Chart

Create secret with Login and Password from Helm registry

apiVersion: v1
kind: Secret
metadata:
name: argocd-helm-oci
data:
username: username|base64
password: password|base64
type: Opaque

Apply secret to Kubernetes:

$ kubectl apply -f secret.yaml

Edit values.yaml

Add repository:

server:
config:
repositories: |
- type: helm
name: registry
url: myregistry.com
enableOci: true
usernameSecret:
name: argocd-helm-oci
key: username
passwordSecret:
name: argocd-helm-oci
key: password

Add application:

server:
...
additionalApplications:
- name: my-application
project: default
source:
path: .
repoURL: 'https://git.com/myrepo/simple-chart.git'
targetRevision: HEAD
helm:
valueFiles:
- values.yaml
destination:
namespace: default
server: 'https://kubernetes.default.svc'
syncPolicy:
automated:
prune: true
selfHeal: true

Install ArgoCD

$ helm install -n argocd argocd .

--

--