Skip to content

Commit c82ade2

Browse files
feat(k8s): initialize basic helm chart
1 parent fa8b61d commit c82ade2

7 files changed

Lines changed: 276 additions & 0 deletions

File tree

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: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
spec:
8+
replicas: {{ .Values.replicaCount }}
9+
selector:
10+
matchLabels:
11+
{{- include "third-places.selectorLabels" . | nindent 6 }}
12+
template:
13+
metadata:
14+
{{- with .Values.podAnnotations }}
15+
annotations:
16+
{{- toYaml . | nindent 8 }}
17+
{{- end }}
18+
labels:
19+
{{- include "third-places.selectorLabels" . | nindent 8 }}
20+
spec:
21+
{{- with .Values.imagePullSecrets }}
22+
imagePullSecrets:
23+
{{- toYaml . | nindent 8 }}
24+
{{- end }}
25+
containers:
26+
- name: {{ .Chart.Name }}
27+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
28+
imagePullPolicy: {{ .Values.image.pullPolicy }}
29+
ports:
30+
- name: http
31+
containerPort: {{ .Values.service.port }}
32+
protocol: TCP
33+
livenessProbe:
34+
httpGet:
35+
path: /
36+
port: http
37+
readinessProbe:
38+
httpGet:
39+
path: /
40+
port: http
41+
resources:
42+
{{- toYaml .Values.resources | nindent 12 }}
43+
{{- with .Values.nodeSelector }}
44+
nodeSelector:
45+
{{- toYaml . | nindent 8 }}
46+
{{- end }}
47+
{{- with .Values.affinity }}
48+
affinity:
49+
{{- toYaml . | nindent 8 }}
50+
{{- end }}
51+
{{- with .Values.tolerations }}
52+
tolerations:
53+
{{- toYaml . | nindent 8 }}
54+
{{- end }}

helm-chart/templates/ingress.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
{{- with .Values.ingress.annotations }}
11+
annotations:
12+
{{- toYaml . | nindent 4 }}
13+
{{- end }}
14+
spec:
15+
{{- if .Values.ingress.className }}
16+
ingressClassName: {{ .Values.ingress.className }}
17+
{{- end }}
18+
{{- if .Values.ingress.tls }}
19+
tls:
20+
{{- range .Values.ingress.tls }}
21+
- hosts:
22+
{{- range .hosts }}
23+
- {{ . | quote }}
24+
{{- end }}
25+
secretName: {{ .secretName }}
26+
{{- end }}
27+
{{- end }}
28+
rules:
29+
{{- range .Values.ingress.hosts }}
30+
- host: {{ .host | quote }}
31+
http:
32+
paths:
33+
{{- range .paths }}
34+
- path: {{ . }}
35+
pathType: Prefix
36+
backend:
37+
service:
38+
name: {{ $fullName }}
39+
port:
40+
number: {{ $svcPort }}
41+
{{- end }}
42+
{{- end }}
43+
{{- end }}

helm-chart/templates/service.yaml

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

helm-chart/values.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Default values for third-places.
2+
# This is a YAML-formatted file.
3+
# Declare variables to be passed into your templates.
4+
5+
replicaCount: 1
6+
7+
image:
8+
repository: ghcr.io/codeforphilly/third-places
9+
pullPolicy: IfNotPresent
10+
# Overrides the image tag whose default is the chart appVersion.
11+
tag: 0.1.2
12+
13+
imagePullSecrets: []
14+
nameOverride: ""
15+
fullnameOverride: "third-places"
16+
17+
podAnnotations: {}
18+
19+
service:
20+
type: ClusterIP
21+
port: 80
22+
23+
ingress:
24+
enabled: false
25+
className: ""
26+
annotations: {}
27+
# kubernetes.io/ingress.class: nginx
28+
# kubernetes.io/tls-acme: "true"
29+
hosts:
30+
- host: chart-example.local
31+
paths:
32+
- path: /
33+
pathType: ImplementationSpecific
34+
tls: []
35+
# - secretName: chart-example-tls
36+
# hosts:
37+
# - chart-example.local
38+
39+
resources: {}
40+
# We usually recommend not to specify default resources and to leave this as a conscious
41+
# choice for the user. This also increases chances charts run on environments with little
42+
# resources, such as Minikube. If you do want to specify resources, uncomment the following
43+
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
44+
# limits:
45+
# cpu: 100m
46+
# memory: 128Mi
47+
# requests:
48+
# cpu: 100m
49+
# memory: 128Mi
50+
51+
nodeSelector: {}
52+
53+
tolerations: []
54+
55+
affinity: {}

0 commit comments

Comments
 (0)