Skip to content

Commit 63bb637

Browse files
update helm-chart
Signed-off-by: Jonathan Irvin <djfoxyslpr@gmail.com>
1 parent a32e0fb commit 63bb637

File tree

14 files changed

+554
-2
lines changed

14 files changed

+554
-2
lines changed

.github/workflows/helm-chart.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
uses: azure/setup-helm@v1
2323

2424
- name: Lint Helm Chart
25-
run: helm lint helm-charts/bingo
25+
run: helm lint helm/bingo
2626

2727
publish:
2828
name: Package and Publish Helm Chart
@@ -39,7 +39,7 @@ jobs:
3939
- name: Package Helm Chart
4040
run: |
4141
mkdir -p dist
42-
helm package helm-charts/bingo --destination dist
42+
helm package helm/bingo --destination dist
4343
4444
- name: Upload Helm Chart to GitHub Release
4545
uses: softprops/action-gh-release@v1

helm/bingo/.helmignore

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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/
24+
# Python specific
25+
__pycache__/
26+
*.py[cod]
27+
*$py.class
28+
*.so
29+
.Python
30+
env/
31+
build/
32+
develop-eggs/
33+
dist/
34+
downloads/
35+
eggs/
36+
.eggs/
37+
lib/
38+
lib64/
39+
parts/
40+
sdist/
41+
var/
42+
wheels/
43+
*.egg-info/
44+
.installed.cfg
45+
*.egg

helm/bingo/Chart.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v2
2+
name: bingo
3+
description: A Helm chart for the Commit Bingo application
4+
type: application
5+
version: 0.1.0
6+
appVersion: "0.1.0"
7+
keywords:
8+
- bingo
9+
- nicegui
10+
- python
11+
maintainers:
12+
- name: Offending Commit
13+
email: offendingcommit@gmail.com

helm/bingo/templates/NOTES.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
1. Get the application URL by running these commands:
2+
{{- if .Values.ingress.enabled }}
3+
{{- range $host := .Values.ingress.hosts }}
4+
{{- range .paths }}
5+
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
6+
{{- end }}
7+
{{- end }}
8+
{{- else if contains "NodePort" .Values.service.type }}
9+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "bingo.fullname" . }})
10+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
11+
echo http://$NODE_IP:$NODE_PORT
12+
{{- else if contains "LoadBalancer" .Values.service.type }}
13+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
14+
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "bingo.fullname" . }}'
15+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "bingo.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
16+
echo http://$SERVICE_IP:{{ .Values.service.port }}
17+
{{- else if contains "ClusterIP" .Values.service.type }}
18+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "bingo.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
19+
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
20+
echo "Visit http://127.0.0.1:8080 to use your application"
21+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
22+
{{- end }}
23+
24+
2. To update the phrases.txt file, you can edit the ConfigMap:
25+
kubectl edit configmap {{ include "bingo.fullname" . }}-phrases -n {{ .Release.Namespace }}
26+
27+
3. After updating the ConfigMap, restart the deployment to apply changes:
28+
kubectl rollout restart deployment {{ include "bingo.fullname" . }} -n {{ .Release.Namespace }}

helm/bingo/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 "bingo.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 "bingo.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 "bingo.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "bingo.labels" -}}
37+
helm.sh/chart: {{ include "bingo.chart" . }}
38+
{{ include "bingo.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 "bingo.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "bingo.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 "bingo.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "bingo.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ include "bingo.fullname" . }}-phrases
5+
labels:
6+
{{- include "bingo.labels" . | nindent 4 }}
7+
data:
8+
phrases.txt: |-
9+
Can't nice things
10+
Techno babble
11+
Hell yeah!
12+
Raided
13+
That's Noice
14+
Position one
15+
How's my audio
16+
Someone redeems hydrate
17+
Threaten good time
18+
Mentions mods
19+
Says texas
20+
Spins bonus wheel
21+
Join discord
22+
Holy smokes!
23+
Says Cats or Dogs
24+
Doot doots
25+
Makes air quotes
26+
Talks about ellee
27+
Zoom
28+
Sight lines
29+
Talks about palia
30+
Says Commitee
31+
Dance party
32+
That's nuts!
33+
Says vel
34+
Says LGS
35+
Says Harlequin Law
36+
Says BBQ
37+
Says Pizza
38+
Says Sushi
39+
Says DevOps
40+
Says Kubernetes
41+
Says Palia Partner
42+
Offending Tide
43+
Thanks for the bitties
44+
See Grand baby
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "bingo.fullname" . }}
5+
labels:
6+
{{- include "bingo.labels" . | nindent 4 }}
7+
spec:
8+
{{- if not .Values.autoscaling.enabled }}
9+
replicas: {{ .Values.replicaCount }}
10+
{{- end }}
11+
selector:
12+
matchLabels:
13+
{{- include "bingo.selectorLabels" . | nindent 6 }}
14+
template:
15+
metadata:
16+
{{- with .Values.podAnnotations }}
17+
annotations:
18+
{{- toYaml . | nindent 8 }}
19+
{{- end }}
20+
labels:
21+
{{- include "bingo.selectorLabels" . | nindent 8 }}
22+
spec:
23+
{{- with .Values.imagePullSecrets }}
24+
imagePullSecrets:
25+
{{- toYaml . | nindent 8 }}
26+
{{- end }}
27+
serviceAccountName: {{ include "bingo.serviceAccountName" . }}
28+
securityContext:
29+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
30+
containers:
31+
- name: {{ .Chart.Name }}
32+
securityContext:
33+
{{- toYaml .Values.securityContext | nindent 12 }}
34+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
35+
imagePullPolicy: {{ .Values.image.pullPolicy }}
36+
env:
37+
- name: BUILD_ENVIRONMENT
38+
value: {{ .Values.env.BUILD_ENVIRONMENT }}
39+
ports:
40+
- name: http
41+
containerPort: {{ .Values.service.port }}
42+
protocol: TCP
43+
livenessProbe:
44+
httpGet:
45+
path: /
46+
port: http
47+
initialDelaySeconds: 30
48+
periodSeconds: 10
49+
readinessProbe:
50+
httpGet:
51+
path: /
52+
port: http
53+
initialDelaySeconds: 5
54+
periodSeconds: 5
55+
resources:
56+
{{- toYaml .Values.resources | nindent 12 }}
57+
volumeMounts:
58+
{{- if .Values.persistence.enabled }}
59+
- name: phrases-volume
60+
mountPath: {{ .Values.persistence.phrasesPath }}
61+
subPath: phrases.txt
62+
- name: static-volume
63+
mountPath: {{ .Values.persistence.staticPath }}
64+
{{- end }}
65+
{{- with .Values.nodeSelector }}
66+
nodeSelector:
67+
{{- toYaml . | nindent 8 }}
68+
{{- end }}
69+
{{- with .Values.affinity }}
70+
affinity:
71+
{{- toYaml . | nindent 8 }}
72+
{{- end }}
73+
{{- with .Values.tolerations }}
74+
tolerations:
75+
{{- toYaml . | nindent 8 }}
76+
{{- end }}
77+
volumes:
78+
{{- if .Values.persistence.enabled }}
79+
- name: phrases-volume
80+
persistentVolumeClaim:
81+
claimName: {{ include "bingo.fullname" . }}-phrases
82+
- name: static-volume
83+
persistentVolumeClaim:
84+
claimName: {{ include "bingo.fullname" . }}-static
85+
{{- end }}

helm/bingo/templates/hpa.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{{- if .Values.autoscaling.enabled }}
2+
apiVersion: autoscaling/v2
3+
kind: HorizontalPodAutoscaler
4+
metadata:
5+
name: {{ include "bingo.fullname" . }}
6+
labels:
7+
{{- include "bingo.labels" . | nindent 4 }}
8+
spec:
9+
scaleTargetRef:
10+
apiVersion: apps/v1
11+
kind: Deployment
12+
name: {{ include "bingo.fullname" . }}
13+
minReplicas: {{ .Values.autoscaling.minReplicas }}
14+
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
15+
metrics:
16+
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
17+
- type: Resource
18+
resource:
19+
name: cpu
20+
target:
21+
type: Utilization
22+
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
23+
{{- end }}
24+
{{- end }}

helm/bingo/templates/ingress.yaml

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

0 commit comments

Comments
 (0)