Skip to content

Instantly share code, notes, and snippets.

@brhoades
Last active August 6, 2020 03:08
Show Gist options
  • Save brhoades/46868eced1c80fe58b7bad386f947c13 to your computer and use it in GitHub Desktop.
Save brhoades/46868eced1c80fe58b7bad386f947c13 to your computer and use it in GitHub Desktop.
{{- define "common.deployment" -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "common.fullname" . }}
labels:
{{- include "common.labels" . | nindent 4 }}
annotations:
{{- include "common.annotations" . | nindent 4 }}
{{- if .Values.deployment.annotations }}
{{- range $key, $value := .Values.deployment.annotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
revisionHistoryLimit: 0
selector:
matchLabels:
{{- include "common.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "common.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.global.image.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{/* serviceAccountName: {{ include "common.serviceAccountName" . }} */}}
{{- if .Values.podSecurityContext }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- end }}
containers:
- name: {{ include "common.fullname" . }}-service
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.global.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy | default .Values.global.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.podPorts.http }}
protocol: TCP
{{- if .Values.features.livechecks.enabled }}
livenessProbe:
httpGet:
path: {{ .Values.features.livechecks.path }}
port: http
{{- end }}
{{- if .Values.features.readychecks.enabled }}
readinessProbe:
httpGet:
path: {{ .Values.features.readychecks.path }}
port: http
{{- end }}
env:
{{- if .Values.podDeps.postgresql }}
- name: DBHOST
value: {{ .Values.global.env.databaseHost }}
- name: DATABASE
value: {{ .Values.global.env.database }}
- name: DBUSER
valueFrom:
secretKeyRef:
name: database-credentials
key: username
- name: DBPASSWORD
valueFrom:
secretKeyRef:
name: database-credentials
key: password
{{- end }}
{{- if .Values.podDeps.jwtSecret }}
- name: JWT_SERVER_SECRET
valueFrom:
secretKeyRef:
name: jwt-token-secret
key: secret
{{- end }}
{{- if .Values.podDeps.proxyTrustToken }}
- name: PROXY_TRUST_TOKEN
valueFrom:
secretKeyRef:
name: proxy-trust-token
key: token
{{- end }}
{{ if .Values.env }}
{{- toYaml .Values.env | nindent 12 }}
{{- end }}
{{- if .Values.configMap }}
envFrom:
- configMapRef:
name: {{ include "common.fullname" . }}-configmap
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end -}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment