Les registries OCI (Open Container Initiative) permettent de stocker des charts Helm au même endroit que vos images Docker. Un seul registry, une seule authentification, une gestion unifiée des artefacts. Depuis Helm 3.8+, le support OCI est stable et recommandé pour les environnements de production.
Prérequis
Section intitulée « Prérequis »- Helm 3.8+ installé (
helm version) - Un compte sur un registry OCI (Harbor, GHCR, ECR, ACR, Docker Hub)
- Un chart packagé ou prêt à packager
- Module 09 — Qualité des charts (recommandé)
Ce que vous allez apprendre
Section intitulée « Ce que vous allez apprendre »- Pourquoi OCI pour les charts Helm
- S’authentifier sur un registry
- Packager et publier un chart
- Consommer un chart depuis OCI
- Stratégies de naming et versioning
- Registries compatibles
Pourquoi OCI pour les charts Helm
Section intitulée « Pourquoi OCI pour les charts Helm »L’évolution de la distribution Helm
Section intitulée « L’évolution de la distribution Helm »| Génération | Mécanisme | Limitations |
|---|---|---|
| Helm 2 | Repos HTTP (index.yaml + tarballs) | Serveur web dédié, pas de sécurité native |
| Helm 3 | Repos HTTP améliorés | Toujours un index.yaml à maintenir |
| Helm 3.8+ | OCI registries | Même infra que les images, authentification intégrée |
Avantages de OCI
Section intitulée « Avantages de OCI »| Aspect | Repos HTTP classiques | OCI registries |
|---|---|---|
| Infrastructure | Serveur web dédié + index.yaml | Votre registry d’images existant |
| Authentification | Basic auth ou tokens custom | Même auth que vos images Docker |
| Immutabilité | Dépend de votre config | Native (un tag = un digest) |
| Signature | Fichier .prov séparé | Cosign/Notation intégrés |
| Découverte | helm search repo | helm search + UI du registry |
S’authentifier sur un registry
Section intitulée « S’authentifier sur un registry »# Login avec username/passwordhelm registry login harbor.example.com
# Login avec robot account (CI/CD)helm registry login harbor.example.com \ --username 'robot$myproject+ci' \ --password-stdin < /path/to/token# Créer un PAT avec scope write:packages# https://github.com/settings/tokens
echo $GITHUB_TOKEN | helm registry login ghcr.io \ --username $GITHUB_USERNAME \ --password-stdin# Login via AWS CLIaws ecr get-login-password --region eu-west-1 | \ helm registry login 123456789.dkr.ecr.eu-west-1.amazonaws.com \ --username AWS \ --password-stdin# Login classique Dockerhelm registry login registry-1.docker.io \ --username $DOCKER_USERNAME \ --password-stdin < ~/.docker/tokenPackager et publier un chart
Section intitulée « Packager et publier un chart »-
Vérifier le chart
Avant de publier, validez la qualité :
Fenêtre de terminal helm lint ./my-charthelm template ./my-chart > /dev/null # Vérifie le rendu -
Packager le chart
Fenêtre de terminal helm package ./my-chart# Crée my-chart-1.2.3.tgzLa version vient de
Chart.yaml:Chart.yaml apiVersion: v2name: my-chartversion: 1.2.3 # Version du chartappVersion: "2.0.0" # Version de l'application -
Pousser vers le registry
Fenêtre de terminal helm push my-chart-1.2.3.tgz oci://harbor.example.com/myprojectRésultat :
Pushed: harbor.example.com/myproject/my-chart:1.2.3Digest: sha256:abc123... -
Vérifier la publication
Fenêtre de terminal helm show chart oci://harbor.example.com/myproject/my-chart --version 1.2.3
Workflow complet en une commande
Section intitulée « Workflow complet en une commande »# Lint → Package → Pushhelm lint ./my-chart && \helm package ./my-chart && \helm push my-chart-*.tgz oci://harbor.example.com/myprojectConsommer un chart depuis OCI
Section intitulée « Consommer un chart depuis OCI »Installation directe
Section intitulée « Installation directe »# Installer depuis OCIhelm install my-release oci://harbor.example.com/myproject/my-chart \ --version 1.2.3 \ -n my-namespace \ --create-namespacePull local puis install
Section intitulée « Pull local puis install »# Télécharger le charthelm pull oci://harbor.example.com/myproject/my-chart --version 1.2.3
# Installer depuis le tarball localhelm install my-release ./my-chart-1.2.3.tgz -n my-namespaceInspecter avant d’installer
Section intitulée « Inspecter avant d’installer »# Voir les métadonnéeshelm show chart oci://harbor.example.com/myproject/my-chart --version 1.2.3
# Voir les values par défauthelm show values oci://harbor.example.com/myproject/my-chart --version 1.2.3
# Voir le READMEhelm show readme oci://harbor.example.com/myproject/my-chart --version 1.2.3Stratégies de naming et versioning
Section intitulée « Stratégies de naming et versioning »Convention de nommage
Section intitulée « Convention de nommage »oci://<registry>/<project>/<chart-name>:<version>| Exemple | Registry | Project | Chart | Version |
|---|---|---|---|---|
oci://harbor.example.com/platform/nginx | harbor.example.com | platform | nginx | (latest) |
oci://ghcr.io/myorg/charts/api:2.1.0 | ghcr.io | myorg/charts | api | 2.1.0 |
Stratégie de versioning recommandée
Section intitulée « Stratégie de versioning recommandée »| Situation | Version chart | Tag OCI |
|---|---|---|
| Release stable | 1.2.3 | 1.2.3 |
| Pre-release | 1.2.3-rc.1 | 1.2.3-rc.1 |
| Branche feature | 0.0.0-feature-xyz | feature-xyz |
| CI automatique | 1.2.3+build.456 | 1.2.3 |
Utiliser les digests pour la reproductibilité
Section intitulée « Utiliser les digests pour la reproductibilité »# Référencer par digest (immuable)helm install my-release oci://harbor.example.com/myproject/my-chart@sha256:abc123...Registries compatibles
Section intitulée « Registries compatibles »| Registry | URL format | Notes |
|---|---|---|
| Harbor | oci://harbor.example.com/project | Gratuit, self-hosted, UI native pour charts |
| GHCR | oci://ghcr.io/owner/repo | Intégré à GitHub, gratuit pour public |
| ECR | oci://123456.dkr.ecr.region.amazonaws.com | AWS natif, IAM intégré |
| ACR | oci://myregistry.azurecr.io | Azure natif |
| GCR/Artifact Registry | oci://region-docker.pkg.dev/project/repo | Google Cloud |
| Docker Hub | oci://registry-1.docker.io/user | Limites de pull sur free tier |
Erreurs fréquentes
Section intitulée « Erreurs fréquentes »| Erreur | Cause probable | Solution |
|---|---|---|
unauthorized | Token expiré ou permissions insuffisantes | helm registry logout puis login |
manifest unknown | Chart ou version inexistant | Vérifier le nom et la version |
denied: requested access... | Pas de permission push | Vérifier les droits sur le projet |
Error: scheme "oci" not supported | Helm < 3.8 | Mettre à jour Helm |
Lab C1 — Publier sur un registry OCI
Section intitulée « Lab C1 — Publier sur un registry OCI »Objectif : Packager un chart, le publier sur GHCR (ou Harbor local), puis l’installer depuis oci://.
-
Préparer le chart
Fenêtre de terminal # Utiliser un chart existant ou en créer unhelm create my-lab-chartcd my-lab-chart# Modifier la version dans Chart.yamlsed -i 's/version: .*/version: 0.1.0/' Chart.yaml -
Se connecter au registry
Fenêtre de terminal # GHCRecho $GITHUB_TOKEN | helm registry login ghcr.io -u $GITHUB_USERNAME --password-stdin -
Packager et publier
Fenêtre de terminal cd ..helm package my-lab-charthelm push my-lab-chart-0.1.0.tgz oci://ghcr.io/$GITHUB_USERNAME/charts -
Vérifier et installer
Fenêtre de terminal # Vérifierhelm show chart oci://ghcr.io/$GITHUB_USERNAME/charts/my-lab-chart --version 0.1.0# Installerhelm install test-release oci://ghcr.io/$GITHUB_USERNAME/charts/my-lab-chart \--version 0.1.0 \-n oci-lab \--create-namespace -
Nettoyer
Fenêtre de terminal helm uninstall test-release -n oci-labkubectl delete namespace oci-lab
Critères de réussite :
- Chart packagé (
.tgzcréé) - Push vers registry OCI réussi
-
helm show chart oci://...affiche les métadonnées - Installation depuis
oci://fonctionnelle
À retenir
Section intitulée « À retenir »- OCI = standard ouvert pour stocker charts et images au même endroit
helm registry login= authentification (même credentials que Docker)helm push= publier un chart packagéhelm pull/helm install oci://= consommer depuis OCI- Immutabilité : ne jamais écraser un tag en production
- Digests : utilisez
@sha256:...pour la reproductibilité absolue
Prochaines étapes
Section intitulée « Prochaines étapes » 11 — Confiance et provenance Signer des charts pour garantir leur intégrité
12 — CI/CD packaging Automatiser lint, package et publish en pipeline
Harbor Installer votre propre registry OCI
Cosign Signer des artefacts OCI avec Sigstore