Skip to content

Commit 4515da8

Browse files
Merge pull request #50 from CodeForPhilly/helm-chart
feat(k8s): add helm chart
2 parents 27f18f2 + 6690984 commit 4515da8

File tree

11 files changed

+415
-0
lines changed

11 files changed

+415
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[holomapping]
2+
root = "helm-chart"
3+
files = "**"

.holo/config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[holospace]
2+
name = "third-places"

helm-chart/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

helm-chart/Chart.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: third-places
3+
description: A Helm chart for Kubernetes
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.1.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: 0.1.2

helm-chart/templates/_helpers.tpl

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "third-places.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "third-places.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "third-places.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "third-places.labels" -}}
37+
helm.sh/chart: {{ include "third-places.chart" . }}
38+
{{ include "third-places.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "third-places.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "third-places.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "third-places.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "third-places.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "third-places.fullname" . }}-postgresql
5+
labels:
6+
{{- include "third-places.labels" . | nindent 4 }}
7+
app.kubernetes.io/component: postgresql
8+
spec:
9+
selector:
10+
{{- include "third-places.selectorLabels" . | nindent 4 }}
11+
app.kubernetes.io/component: postgresql
12+
type: {{ .Values.postgresql.serviceType }}
13+
ports:
14+
- name: postgresql
15+
port: 5432
16+
nodePort: 30432
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
apiVersion: apps/v1
2+
kind: StatefulSet
3+
metadata:
4+
name: {{ include "third-places.fullname" . }}-postgresql
5+
labels:
6+
{{- include "third-places.labels" . | nindent 4 }}
7+
app.kubernetes.io/component: postgresql
8+
spec:
9+
replicas: {{ .Values.postgresql.replicas }}
10+
selector:
11+
matchLabels:
12+
{{- include "third-places.selectorLabels" . | nindent 6 }}
13+
app.kubernetes.io/component: postgresql
14+
serviceName: postgresql
15+
template:
16+
metadata:
17+
labels:
18+
{{- include "third-places.selectorLabels" . | nindent 8 }}
19+
app.kubernetes.io/component: postgresql
20+
{{- with .Values.postgresql.podAnnotations }}
21+
annotations:
22+
{{- toYaml . | nindent 8 }}
23+
{{- end }}
24+
spec:
25+
{{- with .Values.postgresql.imagePullSecrets }}
26+
imagePullSecrets:
27+
{{ toYaml . | nindent 6 }}
28+
{{- end }}
29+
containers:
30+
- name: postgresql
31+
image: {{ .Values.postgresql.image.repository }}:{{ .Values.postgresql.image.tag }}
32+
{{- if or .Values.postgresql.config .Values.postgresql.existingSecret }}
33+
envFrom:
34+
{{- if .Values.postgresql.config }}
35+
- configMapRef:
36+
name: {{ include "third-places.fullname" . }}-postgresql
37+
{{- end }}
38+
{{- if .Values.postgresql.existingSecret }}
39+
- secretRef:
40+
name: {{ .Values.postgresql.existingSecret }}
41+
{{- end }}
42+
{{- end }}
43+
ports:
44+
- containerPort: 5432
45+
name: postgresql
46+
{{- if .Values.postgresql.volumes }}
47+
volumeMounts:
48+
{{- if .Values.postgresql.volumes.data }}
49+
- name: data
50+
mountPath: /var/lib/postgresql/data
51+
subPath: postgresql-data
52+
{{- end }}
53+
{{- end }}
54+
readinessProbe:
55+
tcpSocket:
56+
port: 5432
57+
initialDelaySeconds: 5
58+
periodSeconds: 10
59+
livenessProbe:
60+
tcpSocket:
61+
port: 5432
62+
initialDelaySeconds: 15
63+
periodSeconds: 20
64+
65+
{{- with .Values.postgresql.nodeSelector }}
66+
nodeSelector:
67+
{{- toYaml . | nindent 8 }}
68+
{{- end }}
69+
70+
{{- with .Values.postgresql.affinity }}
71+
affinity:
72+
{{- toYaml . | nindent 8 }}
73+
{{- end }}
74+
75+
{{- with .Values.postgresql.tolerations }}
76+
tolerations:
77+
{{- toYaml . | nindent 8 }}
78+
{{- end }}
79+
80+
{{- if .Values.postgresql.volumes }}
81+
volumeClaimTemplates:
82+
{{- if .Values.postgresql.volumes.data }}
83+
- metadata:
84+
name: data
85+
spec:
86+
accessModes:
87+
- ReadWriteOnce
88+
{{- if .Values.postgresql.volumes.data.storageClassName }}
89+
storageClassName: {{ .Values.postgresql.volumes.data.storageClassName }}
90+
{{- end }}
91+
resources:
92+
requests:
93+
storage: {{ .Values.postgresql.volumes.data.size }}
94+
{{- end }}
95+
{{- end }}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "third-places.fullname" . }}
5+
labels:
6+
{{- include "third-places.labels" . | nindent 4 }}
7+
app.kubernetes.io/component: application
8+
spec:
9+
replicas: {{ .Values.replicaCount }}
10+
selector:
11+
matchLabels:
12+
{{- include "third-places.selectorLabels" . | nindent 6 }}
13+
app.kubernetes.io/component: application
14+
template:
15+
metadata:
16+
{{- with .Values.podAnnotations }}
17+
annotations:
18+
{{- toYaml . | nindent 8 }}
19+
{{- end }}
20+
labels:
21+
{{- include "third-places.selectorLabels" . | nindent 8 }}
22+
app.kubernetes.io/component: application
23+
spec:
24+
{{- with .Values.imagePullSecrets }}
25+
imagePullSecrets:
26+
{{- toYaml . | nindent 8 }}
27+
{{- end }}
28+
containers:
29+
- name: {{ .Chart.Name }}
30+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
31+
imagePullPolicy: {{ .Values.image.pullPolicy }}
32+
ports:
33+
- name: http
34+
containerPort: {{ .Values.service.port }}
35+
protocol: TCP
36+
livenessProbe:
37+
httpGet:
38+
path: /
39+
port: http
40+
readinessProbe:
41+
httpGet:
42+
path: /
43+
port: http
44+
resources:
45+
{{- toYaml .Values.resources | nindent 12 }}
46+
{{- with .Values.nodeSelector }}
47+
nodeSelector:
48+
{{- toYaml . | nindent 8 }}
49+
{{- end }}
50+
{{- with .Values.affinity }}
51+
affinity:
52+
{{- toYaml . | nindent 8 }}
53+
{{- end }}
54+
{{- with .Values.tolerations }}
55+
tolerations:
56+
{{- toYaml . | nindent 8 }}
57+
{{- end }}

helm-chart/templates/ingress.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{{- if .Values.ingress.enabled -}}
2+
{{- $fullName := include "third-places.fullname" . -}}
3+
{{- $svcPort := .Values.service.port -}}
4+
apiVersion: networking.k8s.io/v1
5+
kind: Ingress
6+
metadata:
7+
name: {{ $fullName }}
8+
labels:
9+
{{- include "third-places.labels" . | nindent 4 }}
10+
app.kubernetes.io/component: application
11+
{{- with .Values.ingress.annotations }}
12+
annotations:
13+
{{- toYaml . | nindent 4 }}
14+
{{- end }}
15+
spec:
16+
{{- if .Values.ingress.className }}
17+
ingressClassName: {{ .Values.ingress.className }}
18+
{{- end }}
19+
{{- if .Values.ingress.tls }}
20+
tls:
21+
{{- range .Values.ingress.tls }}
22+
- hosts:
23+
{{- range .hosts }}
24+
- {{ . | quote }}
25+
{{- end }}
26+
secretName: {{ .secretName }}
27+
{{- end }}
28+
{{- end }}
29+
rules:
30+
{{- range .Values.ingress.hosts }}
31+
- host: {{ .host | quote }}
32+
http:
33+
paths:
34+
{{- range .paths }}
35+
- path: {{ . }}
36+
pathType: Prefix
37+
backend:
38+
service:
39+
name: {{ $fullName }}
40+
port:
41+
number: {{ $svcPort }}
42+
{{- end }}
43+
{{- end }}
44+
{{- end }}

helm-chart/templates/service.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "third-places.fullname" . }}
5+
labels:
6+
{{- include "third-places.labels" . | nindent 4 }}
7+
app.kubernetes.io/component: application
8+
spec:
9+
type: {{ .Values.service.type }}
10+
ports:
11+
- port: {{ .Values.service.port }}
12+
targetPort: http
13+
protocol: TCP
14+
name: http
15+
selector:
16+
{{- include "third-places.selectorLabels" . | nindent 4 }}
17+
app.kubernetes.io/component: application

0 commit comments

Comments
 (0)