Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helm hooks #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions helm-deployment/company/templates/hooks/db-migrate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
apiVersion: batch/v1
kind: Job
metadata:
name: "{{ .Release.Name }}-db-migration"
labels:
app: "{{ .Release.Name }}-db-migration"
chart: {{ template "company.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
annotations:
"helm.sh/hook": pre-upgrade
"helm.sh/hook-weight": "-1"
"helm.sh/hook-delete-policy": hook-succeeded
spec:
template:
metadata:
name: "{{ .Release.Name }}-db-migration"
labels:
app: "{{ .Release.Name }}-db-migration"
release: {{ .Release.Name }}
spec:
restartPolicy: Never
containers:
- name: db-migration-job
image: docker.io/microsigns/k8s-db-migration:1.0.1
imagePullPolicy: Always
env:
- name: DB_URL
value: postgres://{{ .Values.database.user }}:{{ .Values.database.password }}@{{ .Values.database.host }}:5432/{{ .Values.database.name }}
resources: {}
imagePullSecrets:
- name: invue-registry-secret
1 change: 1 addition & 0 deletions helm-deployment/db-migrate/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
5 changes: 4 additions & 1 deletion helm-deployment/db-migrate/config/database.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
'use strict';

console.log( 'Loading the env variables')
console.log( 'Loading the env variables');
console.log( `ENV DB_URL ${process.env.DB_URL}`);
if( !process.env.DB_URL ){
console.log( `Loading ENV DB_URL from PATH`);
require('dotenv').config({ path: __dirname + '/../.env' });
}

console.log( `ENV DB_URL ${process.env.DB_URL} after`);
module.exports = {
development: {
use_env_variable: "DB_URL"
Expand Down
2 changes: 1 addition & 1 deletion helm-deployment/db-migrate/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "db-migrate",
"version": "1.0.0",
"version": "1.0.1",
"description": "Helm Chart DB Migration",
"main": "index.js",
"scripts": {
Expand Down