Anatomy of a Chart
1 - Create a new Chart
1.1 Generation with helm create
# Créer un nouveau chart
helm create mon-app
# Structure générée
mon-app/
├── .helmignore # Fichiers à ignorer lors du packaging
├── Chart.yaml # Métadonnées du chart
├── values.yaml # Configuration par défaut
├── charts/ # Dépendances
├── templates/ # Templates Kubernetes
│ ├ ── NOTES.txt # Notes post-installation
│ ├── _helpers.tpl # Fonctions helpers
│ ├── deployment.yaml
│ ├── hpa.yaml
│ ├── ingress.yaml
│ ├── service.yaml
│ ├── serviceaccount.yaml
│ └── tests/
│ └── test-connection.yaml
└── README.md
1.2 Minimal structure
minimal-chart/
├── Chart.yaml
├── values.yaml
└── templates/
└── configmap.yaml
# Chart.yaml (minimal)
apiVersion: v2
name: minimal-chart
version: 0.1.0
2 - Configuration files
2.1 Complete Chart.yaml
apiVersion: v2
name: mon-application
version: 1.0.0
appVersion: "2.1.0"
description: |
Une application web complète avec base de données
et cache Redis.
type: application
kubeVersion: ">=1.23.0"
keywords:
- web
- api
- microservice
home: https://github.com/monorg/mon-app
sources:
- https://github.com/monorg/mon-app
- https://github.com/monorg/mon-app-chart
maintainers:
- name: DevOps Team
email: [email protected]
url: https://example.com
icon: https://example.com/icons/app.png
annotations:
artifacthub.io/category: web-application
artifacthub.io/license: Apache-2.0
artifacthub.io/links: |
- name: Documentation
url: https://docs.example.com
- name: Support
url: https://support.example.com
# Dépendances
dependencies:
- name: postgresql
version: "~12.1.0"
repository: https://charts.bitnami.com/bitnami
condition: postgresql.enabled
alias: db
- name: redis
version: "17.x"
repository: https://charts.bitnami.com/bitnami
condition: redis.enabled
import-values:
- child: primary
parent: redis
2.2 .helmignore
# .helmignore
# Fichiers à exclure du package
# Patterns communs
.DS_Store
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# IDE
*.swp
*.bak
*.tmp
*.orig
*~
.idea/
*.tmproj
.vscode/
# CI/CD
.travis.yml
.gitlab-ci.yml
.github/
# Tests et développement
OWNERS
SECURITY.md
CONTRIBUTING.md
hack/
Makefile
# Fichiers de build
*.tgz
2.3 Organized values.yaml
# values.yaml
# ===========================================
# Configuration globale
# ===========================================
global:
imageRegistry: ""
imagePullSecrets: []
storageClass: ""
# ===========================================
# Application principale
# ===========================================
replicaCount: 1
image:
repository: nginx
tag: "" # Défaut: appVersion du Chart.yaml
pullPolicy: IfNotPresent
pullSecrets: []
nameOverride: ""
fullnameOverride: ""
# ===========================================
# Service Account
# ===========================================
serviceAccount:
create: true
automount: true
annotations: {}
name: ""
# ===========================================
# Pod
# ===========================================
podAnnotations: {}
podLabels: {}
podSecurityContext:
fsGroup: 1000
securityContext:
runAsNonRoot: true
runAsUser: 1000
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
# ===========================================
# Service
# ===========================================
service:
type: ClusterIP
port: 80
# ===========================================
# Ingress
# ===========================================
ingress:
enabled: false
className: ""
annotations: {}
hosts:
- host: chart-example.local
paths:
- path: /
pathType: ImplementationSpecific
tls: []
# ===========================================
# Ressources
# ===========================================
resources:
limits:
cpu: 500m
memory: 512Mi
requests:
cpu: 100m
memory: 128Mi
# ===========================================
# Probes
# ===========================================
livenessProbe:
httpGet:
path: /health
port: http
initialDelaySeconds: 10
periodSeconds: 10
readinessProbe:
httpGet:
path: /ready
port: http
initialDelaySeconds: 5
periodSeconds: 5
# ===========================================
# Autoscaling
# ===========================================
autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 10
targetCPUUtilizationPercentage: 80
targetMemoryUtilizationPercentage: 80
# ===========================================
# Volumes et Persistence
# ===========================================
persistence:
enabled: false
storageClass: ""
accessModes:
- ReadWriteOnce
size: 8Gi
annotations: {}
existingClaim: ""
# ===========================================
# Configuration additionnelle
# ===========================================
env: []
envFrom: []
volumes: []
volumeMounts: []
nodeSelector: {}
tolerations: []
affinity: {}
# ===========================================
# Dépendances
# ===========================================
postgresql:
enabled: false
auth:
username: app
database: appdb
redis:
enabled: false
architecture: standalone
3 - The templates/ folder
3.1 Typical structure
templates/
├── NOTES.txt # Message post-installation
├── _helpers.tpl # Fonctions partagées
├── deployment.yaml # Deployment principal
├── service.yaml # Service
├── serviceaccount.yaml # ServiceAccount
├── configmap.yaml # ConfigMaps
├── secret.yaml # Secrets
├── ingress.yaml # Ingress
├── hpa.yaml # HorizontalPodAutoscaler