Cloud / HELM Interview Questions
What are Helm hooks and how do you use them for database migrations and pre-install jobs?
Helm hooks allow containers to run at specific points during a release's lifecycle. Hooks are Kubernetes Job resources with special annotations that Helm recognizes.
Hook types available: pre-install, post-install, pre-upgrade, post-upgrade, pre-rollback, post-rollback, pre-delete, post-delete, test (for custom testing).
Database migration example: apiVersion: batch/v1 kind: Job metadata: name: {{ .Release.Name }}-db-migrate annotations: "helm.sh/hook": pre-upgrade "helm.sh/hook-weight": "5" "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded spec: template: spec: containers: - name: migrate image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" command: ["python", "manage.py", "migrate"] restartPolicy: OnFailure
Hook weights determine execution order (lower numbers run first). Delete policies control cleanup: before-hook-creation (delete previous), hook-succeeded (clean after success), hook-failed (keep for debugging).
Hook resources are not released with the chart - they persist unless specifically deleted or managed with delete policies. For critical hooks like database migrations, test thoroughly in staging first.
More Related questions...