aboutsummaryrefslogtreecommitdiff
path: root/grumpy/gitsnapshot/templates
diff options
context:
space:
mode:
authorMax Resnick <max@ofmax.li>2019-08-03 22:22:27 -0700
committerMax Resnick <max@ofmax.li>2019-08-18 23:05:42 -0700
commit7d9a09e262d512eca02a254ee3534e71335a984f (patch)
treee3d91c6f58ec5a9cb36ee68b7c36a726732e89d3 /grumpy/gitsnapshot/templates
parentca67c4ad52142c5246b28a34f9c25a22684432be (diff)
downloadgrumpy-charts-7d9a09e262d512eca02a254ee3534e71335a984f.tar.gz
init commit of build tools and snapshot"
Diffstat (limited to '')
-rw-r--r--grumpy/gitsnapshot/templates/NOTES.txt21
-rw-r--r--grumpy/gitsnapshot/templates/_helpers.tpl56
-rw-r--r--grumpy/gitsnapshot/templates/cronjob.yaml53
-rw-r--r--grumpy/gitsnapshot/templates/secrets.yaml9
-rw-r--r--grumpy/gitsnapshot/templates/tests/test-connection.yaml15
5 files changed, 154 insertions, 0 deletions
diff --git a/grumpy/gitsnapshot/templates/NOTES.txt b/grumpy/gitsnapshot/templates/NOTES.txt
new file mode 100644
index 0000000..8213fc9
--- /dev/null
+++ b/grumpy/gitsnapshot/templates/NOTES.txt
@@ -0,0 +1,21 @@
+1. Get the application URL by running these commands:
+{{- if .Values.ingress.enabled }}
+{{- range $host := .Values.ingress.hosts }}
+ {{- range .paths }}
+ http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
+ {{- end }}
+{{- end }}
+{{- else if contains "NodePort" .Values.service.type }}
+ export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "gitsnapshot.fullname" . }})
+ export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
+ echo http://$NODE_IP:$NODE_PORT
+{{- else if contains "LoadBalancer" .Values.service.type }}
+ NOTE: It may take a few minutes for the LoadBalancer IP to be available.
+ You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "gitsnapshot.fullname" . }}'
+ export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "gitsnapshot.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
+ echo http://$SERVICE_IP:{{ .Values.service.port }}
+{{- else if contains "ClusterIP" .Values.service.type }}
+ export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "gitsnapshot.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
+ echo "Visit http://127.0.0.1:8080 to use your application"
+ kubectl port-forward $POD_NAME 8080:80
+{{- end }}
diff --git a/grumpy/gitsnapshot/templates/_helpers.tpl b/grumpy/gitsnapshot/templates/_helpers.tpl
new file mode 100644
index 0000000..8b854e5
--- /dev/null
+++ b/grumpy/gitsnapshot/templates/_helpers.tpl
@@ -0,0 +1,56 @@
+{{/* vim: set filetype=mustache: */}}
+{{/*
+Expand the name of the chart.
+*/}}
+{{- define "gitsnapshot.name" -}}
+{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+
+{{/*
+Create a default fully qualified app name.
+We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
+If release name contains chart name it will be used as a full name.
+*/}}
+{{- define "gitsnapshot.fullname" -}}
+{{- if .Values.fullnameOverride -}}
+{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
+{{- else -}}
+{{- $name := default .Chart.Name .Values.nameOverride -}}
+{{- if contains $name .Release.Name -}}
+{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
+{{- else -}}
+{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+{{- end -}}
+{{- end -}}
+
+{{/*
+Create chart name and version as used by the chart label.
+*/}}
+{{- define "gitsnapshot.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+
+{{/*
+Common labels
+*/}}
+{{- define "gitsnapshot.labels" -}}
+app.kubernetes.io/name: {{ include "gitsnapshot.name" . }}
+helm.sh/chart: {{ include "gitsnapshot.chart" . }}
+app.kubernetes.io/instance: {{ .Release.Name }}
+{{- if .Chart.AppVersion }}
+app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
+{{- end }}
+app.kubernetes.io/managed-by: {{ .Release.Service }}
+{{- end -}}
+
+{{/*
+Create the name of the service account to use
+*/}}
+{{- define "gitsnapshot.serviceAccountName" -}}
+{{- if .Values.serviceAccount.create -}}
+ {{ default (include "gitsnapshot.fullname" .) .Values.serviceAccount.name }}
+{{- else -}}
+ {{ default "default" .Values.serviceAccount.name }}
+{{- end -}}
+{{- end -}}
diff --git a/grumpy/gitsnapshot/templates/cronjob.yaml b/grumpy/gitsnapshot/templates/cronjob.yaml
new file mode 100644
index 0000000..f1f4116
--- /dev/null
+++ b/grumpy/gitsnapshot/templates/cronjob.yaml
@@ -0,0 +1,53 @@
+apiVersion: batch/v1beta1
+kind: CronJob
+metadata:
+ name: {{ include "gitsnapshot.fullname" . }}
+ labels:
+{{ include "gitsnapshot.labels" . | indent 4 }}
+spec:
+ schedule: "*/1 * * * *"
+ selector:
+ matchLabels:
+ app.kubernetes.io/name: {{ include "gitsnapshot.name" . }}
+ app.kubernetes.io/instance: {{ .Release.Name }}
+ jobTemplate:
+ metadata:
+ labels:
+ app.kubernetes.io/name: {{ include "gitsnapshot.name" . }}
+ app.kubernetes.io/instance: {{ .Release.Name }}
+ spec:
+ template:
+ spec:
+ restartPolicy: Never
+ containers:
+ - name: {{ .Chart.Name }}
+ command:
+ - /opt/app/gitbackup.sh
+ - /var/lib/git/repositories
+ - privategit
+ image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
+ imagePullPolicy: {{ .Values.image.pullPolicy }}
+ volumeMounts:
+ - mountPath: /var/lib/git
+ name: gitolite-storage
+ readOnly: false
+ env:
+ - name: AWS_DEFAULT_REGION
+ valueFrom:
+ secretKeyRef:
+ name: aws-s3-secret
+ key: AWS_DEFAULT_REGION
+ - name: AWS_SECRET_ACCESS_KEY
+ valueFrom:
+ secretKeyRef:
+ name: aws-s3-secret
+ key: AWS_SECRET_ACCESS_KEY
+ - name: AWS_ACCESS_KEY_ID
+ valueFrom:
+ secretKeyRef:
+ name: aws-s3-secret
+ key: AWS_ACCESS_KEY_ID
+ volumes:
+ - name: gitolite-storage
+ persistentVolumeClaim:
+ claimName: gitolite-storage
diff --git a/grumpy/gitsnapshot/templates/secrets.yaml b/grumpy/gitsnapshot/templates/secrets.yaml
new file mode 100644
index 0000000..b8b42d1
--- /dev/null
+++ b/grumpy/gitsnapshot/templates/secrets.yaml
@@ -0,0 +1,9 @@
+apiVersion: v1
+kind: Secret
+metadata:
+ name: aws-s3-secret
+type: Opaque
+stringData:
+ AWS_DEFAULT_REGION: {{ .Values.secrets.awsRegion }}
+ AWS_SECRET_ACCESS_KEY: {{ .Values.secrets.accessKey }}
+ AWS_ACCESS_KEY_ID: {{ .Values.secrets.accessKeyId }}
diff --git a/grumpy/gitsnapshot/templates/tests/test-connection.yaml b/grumpy/gitsnapshot/templates/tests/test-connection.yaml
new file mode 100644
index 0000000..189529f
--- /dev/null
+++ b/grumpy/gitsnapshot/templates/tests/test-connection.yaml
@@ -0,0 +1,15 @@
+apiVersion: v1
+kind: Pod
+metadata:
+ name: "{{ include "gitsnapshot.fullname" . }}-test-connection"
+ labels:
+{{ include "gitsnapshot.labels" . | indent 4 }}
+ annotations:
+ "helm.sh/hook": test-success
+spec:
+ containers:
+ - name: wget
+ image: busybox
+ command: ['wget']
+ args: ['{{ include "gitsnapshot.fullname" . }}:{{ .Values.service.port }}']
+ restartPolicy: Never