Skip to content

Commit f63dbef

Browse files
committed
add helm chart
1 parent eda0275 commit f63dbef

File tree

15 files changed

+522
-0
lines changed

15 files changed

+522
-0
lines changed

Bonus/helm/postgresql/Chart.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dependencies:
2+
- name: postgresql
3+
repository: oci://registry-1.docker.io/bitnamicharts
4+
version: 16.6.3
5+
digest: sha256:1879a79586c29784a0c6cbb5b120410cbfa084200f56602db4919577aa07c402
6+
generated: "2025-04-14T19:45:34.593631+04:00"

Bonus/helm/postgresql/Chart.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
apiVersion: v2
2+
name: postgresql
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: "1.16.0"
25+
dependencies:
26+
- name: postgresql
27+
version: 18.1.4
28+
repository: oci://registry-1.docker.io/bitnamicharts
29+
condition: postgresql.enabled
86.7 KB
Binary file not shown.

Bonus/helm/postgresql/help.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
helm install postgresql ./postgresql -n petclinic
2+
3+
4+
postgresql:
5+
enabled: true
6+
fullnameOverride: postgresql
7+
auth:
8+
enablePostgresUser: false
9+
volumePermissions:
10+
enabled: true
11+
primary:
12+
podSecurityContext:
13+
enabled: true
14+
fsGroup: 1001
15+
containerSecurityContext:
16+
enabled: true
17+
runAsUser: 1001
18+
runAsNonRoot: true
19+
persistence:
20+
enabled: true
21+
size: 8Gi
22+
extendedConfiguration: |
23+
max_connections = 100
24+
shared_buffers = 1GB
25+
effective_cache_size = 3GB
26+
maintenance_work_mem = 256MB
27+
checkpoint_completion_target = 0.9
28+
wal_buffers = 16MB
29+
default_statistics_target = 100
30+
random_page_cost = 1.1
31+
effective_io_concurrency = 200
32+
work_mem = 5242kB
33+
huge_pages = off
34+
min_wal_size = 1GB
35+
max_wal_size = 4GB
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "app.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 "app.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 "app.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "app.labels" -}}
37+
helm.sh/chart: {{ include "app.chart" . }}
38+
{{ include "app.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 "app.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "app.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 "app.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "app.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
63+
64+
{{- define "eureka.serverList" -}}
65+
{{- $eureka := dict "servers" (list) -}}
66+
{{- range $i, $e := until (int .Values.replicaCount) -}}
67+
{{- $noop := printf "http://%s-%d.%s-headless:%d/eureka/" (include "app.fullname" $) $i (include "app.fullname" $) (int $.Values.service.port) | append $eureka.servers | set $eureka "servers" -}}
68+
{{- end }}
69+
{{- join "," $eureka.servers -}}
70+
{{- end }}

Bonus/helm/postgresql/values.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
postgresql:
2+
enabled: true
3+
fullnameOverride: postgresql
4+
auth:
5+
enablePostgresUser: false
6+
primary:
7+
podSecurityContext:
8+
enabled: true
9+
fsGroup: 1001
10+
containerSecurityContext:
11+
enabled: true
12+
runAsUser: 1001
13+
runAsNonRoot: true
14+
persistence:
15+
enabled: true
16+
size: 8Gi
17+
extendedConfiguration: |
18+
max_connections = 200
19+
shared_buffers = 1GB
20+
effective_cache_size = 3GB
21+
maintenance_work_mem = 256MB
22+
checkpoint_completion_target = 0.9
23+
wal_buffers = 16MB
24+
default_statistics_target = 100
25+
random_page_cost = 1.1
26+
effective_io_concurrency = 200
27+
work_mem = 5242kB
28+
huge_pages = off
29+
min_wal_size = 1GB
30+
max_wal_size = 4GB
31+
32+
volumePermissions:
33+
enabled: true

Bonus/helm/timeserver/.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/

Bonus/helm/timeserver/Chart.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: v2
2+
name: timeserver
3+
description: A Helm chart for Spring Boot app
4+
type: application
5+
version: 0.1.0
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Thank you for installing {{ .Chart.Name }}!
2+
3+
Your release is named {{ .Release.Name }}.
4+
5+
To learn more about the release, try:
6+
7+
$ helm status {{ .Release.Name }}
8+
$ helm get all {{ .Release.Name }}
9+
10+
The timeserver application has been deployed with the following components:
11+
- Deployment: {{ include "app.fullname" . }}
12+
- Service: {{ include "app.fullname" . }}
13+
{{- if .Values.createConfigMap }}
14+
- ConfigMap: {{ include "app.configMapName" . }}
15+
{{- end }}
16+
{{- if .Values.createSecret }}
17+
- Secret: {{ include "app.secretName" . }}
18+
{{- end }}
19+
20+
To access the timeserver service from within the cluster:
21+
22+
$ kubectl run -it --rm debug --image=busybox --restart=Never -- wget -O- http://{{ include "app.fullname" . }}:{{ .Values.service.port }}
23+
24+
To get the application URL:
25+
{{- if eq .Values.service.type "NodePort" }}
26+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "app.fullname" . }})
27+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
28+
echo http://$NODE_IP:$NODE_PORT
29+
{{- else if eq .Values.service.type "LoadBalancer" }}
30+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
31+
You can watch the status by running:
32+
$ kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "app.fullname" . }}
33+
34+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "app.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
35+
echo http://$SERVICE_IP:{{ .Values.service.port }}
36+
{{- else if eq .Values.service.type "ClusterIP" }}
37+
$ kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ include "app.fullname" . }} 8080:{{ .Values.service.port }}
38+
39+
Then access the application at: http://127.0.0.1:8080
40+
{{- end }}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "app.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
*/}}
11+
{{- define "app.fullname" -}}
12+
{{- if .Values.fullnameOverride }}
13+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
14+
{{- else }}
15+
{{- $name := default .Chart.Name .Values.nameOverride }}
16+
{{- if contains $name .Release.Name }}
17+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
18+
{{- else }}
19+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
20+
{{- end }}
21+
{{- end }}
22+
{{- end }}
23+
24+
{{/*
25+
Create chart name and version as used by the chart label.
26+
*/}}
27+
{{- define "app.chart" -}}
28+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
29+
{{- end }}
30+
31+
{{/*
32+
Common labels
33+
*/}}
34+
{{- define "app.labels" -}}
35+
helm.sh/chart: {{ include "app.chart" . }}
36+
{{ include "app.selectorLabels" . }}
37+
{{- if .Chart.AppVersion }}
38+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
39+
{{- end }}
40+
app.kubernetes.io/managed-by: {{ .Release.Service }}
41+
{{- end }}
42+
43+
{{/*
44+
Selector labels
45+
*/}}
46+
{{- define "app.selectorLabels" -}}
47+
app.kubernetes.io/name: {{ include "app.name" . }}
48+
app.kubernetes.io/instance: {{ .Release.Name }}
49+
{{- end }}
50+
51+
{{/*
52+
ConfigMap name
53+
*/}}
54+
{{- define "app.configMapName" -}}
55+
{{- printf "%s-config" (include "app.fullname" .) }}
56+
{{- end }}
57+
58+
{{/*
59+
Secret name
60+
*/}}
61+
{{- define "app.secretName" -}}
62+
{{- printf "%s-secret" (include "app.fullname" .) }}
63+
{{- end }}

0 commit comments

Comments
 (0)