Installation de Helm
1 - Prérequis
Avant d'installer Helm, assurez-vous d'avoir :
- kubectl installé et configuré
- Accès à un cluster Kubernetes
- Permissions appropriées sur le cluster
# Vérifier kubectl
kubectl version --client
# Vérifier l'accès au cluster
kubectl cluster-info
2 - Installation
2.1 Linux
# Option 1 : Script officiel
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
# Option 2 : Package manager (Debian/Ubuntu)
curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg > /dev/null
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
sudo apt-get update
sudo apt-get install helm
# Option 3 : Snap
sudo snap install helm --classic
# Option 4 : Téléchargement binaire
wget https://get.helm.sh/helm-v3.13.0-linux-amd64.tar.gz
tar -zxvf helm-v3.13.0-linux-amd64.tar.gz
sudo mv linux-amd64/helm /usr/local/bin/helm
2.2 macOS
# Option 1 : Homebrew (recommandé)
brew install helm
# Option 2 : MacPorts
sudo port install helm-3.0
# Option 3 : Téléchargement binaire
wget https://get.helm.sh/helm-v3.13.0-darwin-amd64.tar.gz
tar -zxvf helm-v3.13.0-darwin-amd64.tar.gz
sudo mv darwin-amd64/helm /usr/local/bin/helm
2.3 Windows
# Option 1 : Chocolatey
choco install kubernetes-helm
# Option 2 : Scoop
scoop install helm
# Option 3 : Téléchargement binaire
# Télécharger depuis https://github.com/helm/helm/releases
# Extraire et ajouter au PATH
2.4 Vérification de l'installation
# Vérifier la version
helm version
# Output attendu :
# version.BuildInfo{Version:"v3.13.0", GitCommit:"...", GitTreeState:"clean", GoVersion:"go1.20.8"}
3 - Configuration initiale
3.1 Autocomplétion
# Bash
helm completion bash > /etc/bash_completion.d/helm
# ou
echo 'source <(helm completion bash)' >> ~/.bashrc
# Zsh
helm completion zsh > "${fpath[1]}/_helm"
# ou
echo 'source <(helm completion zsh)' >> ~/.zshrc
# Fish
helm completion fish > ~/.config/fish/completions/helm.fish
# PowerShell
helm completion powershell | Out-String | Invoke-Expression
3.2 Variables d'environnement
# Répertoire de configuration Helm
export HELM_CONFIG_HOME="$HOME/.config/helm"
# Répertoire de cache
export HELM_CACHE_HOME="$HOME/.cache/helm"
# Répertoire des données (plugins, etc.)
export HELM_DATA_HOME="$HOME/.local/share/helm"
# Namespace par défaut pour les releases
export HELM_NAMESPACE="default"
3.3 Fichier de configuration
# Voir la configuration
helm env
# Output :
# HELM_BIN="helm"
# HELM_CACHE_HOME="/home/user/.cache/helm"
# HELM_CONFIG_HOME="/home/user/.config/helm"
# HELM_DATA_HOME="/home/user/.local/share/helm"
# HELM_DEBUG="false"
# HELM_KUBEAPISERVER=""
# HELM_KUBEASGROUPS=""
# HELM_KUBEASUSER=""
# HELM_KUBECONTEXT=""
# HELM_KUBETOKEN=""
# HELM_MAX_HISTORY="10"
# HELM_NAMESPACE="default"
# HELM_PLUGINS="/home/user/.local/share/helm/plugins"
# HELM_REGISTRY_CONFIG="/home/user/.config/helm/registry/config.json"
# HELM_REPOSITORY_CACHE="/home/user/.cache/helm/repository"
# HELM_REPOSITORY_CONFIG="/home/user/.config/helm/repositories.yaml"
4 - Ajout de repositories
4.1 Repositories courants
# Bitnami - Applications générales
helm repo add bitnami https://charts.bitnami.com/bitnami
# Prometheus Community - Monitoring
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
# Grafana - Dashboards et observabilité
helm repo add grafana https://grafana.github.io/helm-charts
# Jetstack - cert-manager
helm repo add jetstack https://charts.jetstack.io
# Ingress NGINX
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
# Mettre à jour les repos
helm repo update
4.2 Gestion des repositories
# Lister les repositories
helm repo list
# Rechercher dans un repository
helm search repo nginx
# Rechercher sur Artifact Hub
helm search hub prometheus
# Supprimer un repository
helm repo remove bitnami
# Mettre à jour un repository spécifique
helm repo update bitnami
5 - Plugins Helm
5.1 Plugins essentiels
# helm-diff - Voir les différences avant upgrade
helm plugin install https://github.com/databus23/helm-diff
# helm-secrets - Gérer les secrets chiffrés
helm plugin install https://github.com/jkroepke/helm-secrets
# helm-unittest - Tests unitaires pour charts
helm plugin install https://github.com/helm-unittest/helm-unittest
# helm-push - Push de charts vers ChartMuseum
helm plugin install https://github.com/chartmuseum/helm-push
5.2 Gestion des plugins
# Lister les plugins installés
helm plugin list
# Mettre à jour un plugin
helm plugin update diff
# Désinstaller un plugin
helm plugin uninstall diff
# Utiliser un plugin
helm diff upgrade my-release ./my-chart
6 - Premier déploiement
6.1 Déployer un chart simple
# Rechercher nginx
helm search repo nginx
# Voir les informations du chart
helm show chart bitnami/nginx
helm show readme bitnami/nginx
helm show values bitnami/nginx
# Installer avec valeurs par défaut
helm install my-nginx bitnami/nginx
# Vérifier l'installation
helm list
kubectl get pods
kubectl get svc
6.2 Personnaliser le déploiement
# Voir les valeurs par défaut
helm show values bitnami/nginx > values.yaml
# Modifier values.yaml puis installer
helm install my-nginx bitnami/nginx -f values.yaml
# Ou surcharger directement
helm install my-nginx bitnami/nginx \
--set service.type=NodePort \
--set replicaCount=3
6.3 Vérifier et accéder
# Status de la release
helm status my-nginx
# Voir les ressources créées
kubectl get all -l app.kubernetes.io/instance=my-nginx
# Obtenir l'URL d'accès
kubectl get svc my-nginx -o jsonpath='{.status.loadBalancer.ingress[0].ip}'
# Port-forward pour test local
kubectl port-forward svc/my-nginx 8080:80
7 - Commandes de base
7.1 Aide et documentation
# Aide générale
helm --help
# Aide pour une commande spécifique
helm install --help
helm upgrade --help
# Documentation d'un chart
helm show readme bitnami/nginx
helm show values bitnami/nginx
helm show chart bitnami/nginx
helm show all bitnami/nginx
7.2 Gestion des releases
# Lister les releases
helm list
helm list --all-namespaces
helm list -n production
# Status d'une release
helm status my-nginx
# Historique
helm history my-nginx
# Supprimer une release
helm uninstall my-nginx
helm uninstall my-nginx --keep-history # Garder l'historique
7.3 Debugging
# Dry-run (simuler sans installer)
helm install my-nginx bitnami/nginx --dry-run
# Debug avec output verbose
helm install my-nginx bitnami/nginx --debug
# Voir le manifest généré
helm template my-nginx bitnami/nginx
# Valider un chart localement
helm lint ./my-chart
8 - Intégration avec kubectl
8.1 Utiliser le même contexte
# Helm utilise automatiquement le contexte kubectl actuel
kubectl config current-context
# Spécifier un contexte différent
helm install my-app ./chart --kube-context=production-cluster
# Spécifier un kubeconfig
helm install my-app ./chart --kubeconfig=/path/to/kubeconfig
8.2 Namespaces
# Installer dans un namespace spécifique
helm install my-app ./chart -n production
# Créer le namespace s'il n'existe pas
helm install my-app ./chart -n production --create-namespace
# Définir le namespace par défaut
export HELM_NAMESPACE=production
Résumé
Dans ce chapitre, nous avons :
- Installé Helm sur différents OS
- Configuré l'autocomplétion et les variables
- Ajouté des repositories de charts
- Installé des plugins utiles
- Effectué notre premier déploiement
- Appris les commandes de base
Prochaine étape
Dans le prochain chapitre, nous approfondirons les concepts fondamentaux de Helm.
→ Chapitre suivant : Concepts fondamentaux