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.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
