Skip to content
This repository was archived by the owner on Sep 29, 2025. It is now read-only.

Commit 7de6766

Browse files
author
Raymond Augé
authored
Merge pull request #52 from rotty3000/LCD-45023
LCD 45023 Create reusable template to simplify the chart
2 parents 4edc146 + d405a4d commit 7de6766

File tree

17 files changed

+591
-1437
lines changed

17 files changed

+591
-1437
lines changed

.helmignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
.DS_Store
55
# Common VCS dirs
66
.git/
7+
.github/
78
.gitignore
89
.bzr/
910
.bzrignore
@@ -19,8 +20,11 @@
1920
# Various IDEs
2021
.project
2122
.idea/
22-
*.tmproj
2323
.vscode/
24+
*.md
25+
*.tmproj
2426

25-
dist/
27+
# Custom ignores
2628
_config.yml
29+
dist/
30+
values-*.yaml

Chart.yaml

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,16 @@
11
apiVersion: v2
2-
name: liferay
3-
description: A Liferay DXP Helm chart for Kubernetes
42

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.
3+
# This is the version number of the application being deployed. This version number should be
4+
# incremented each time you make changes to the application. Versions are not expected to
5+
# follow Semantic Versioning. They should reflect the version the application is using.
6+
# It is recommended to use it with quotes.
7+
appVersion: "latest"
8+
9+
description: A Liferay DXP Helm chart for Kubernetes
10+
name: liferay
1311
type: application
1412

1513
# This is the chart version. This version number should be incremented each time you make changes
1614
# to the chart and its templates, including the app version.
1715
# Versions are expected to follow Semantic Versioning (https://semver.org/)
1816
version: 0.0.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: "latest"

templates/NOTES.txt

Lines changed: 0 additions & 22 deletions
This file was deleted.

templates/_helpers.tpl

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
{{/*
2-
Expand the name of the chart.
2+
Create chart name and version as used by the chart label.
33
*/}}
4-
{{- define "liferay.name" -}}
5-
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
4+
{{- define "liferay.chart" -}}
5+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Custom labels
10+
*/}}
11+
{{- define "liferay.customLabels" -}}
12+
{{- with .Values.customLabels }}
13+
{{ toYaml . }}
14+
{{- end }}
615
{{- end }}
716

817
{{/*
@@ -23,13 +32,6 @@ If release name contains chart name it will be used as a full name.
2332
{{- end }}
2433
{{- end }}
2534

26-
{{/*
27-
Create chart name and version as used by the chart label.
28-
*/}}
29-
{{- define "liferay.chart" -}}
30-
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31-
{{- end }}
32-
3335
{{/*
3436
Common labels
3537
*/}}
@@ -44,14 +46,19 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
4446
{{- end }}
4547

4648
{{/*
47-
Custom labels
49+
Expand the name of the chart.
4850
*/}}
49-
{{- define "liferay.customLabels" -}}
50-
{{- with .Values.customLabels }}
51-
{{ toYaml . }}
52-
{{- end }}
51+
{{- define "liferay.name" -}}
52+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
5353
{{- end }}
5454

55+
{{/*
56+
Allow the release namespace to be overridden for multi-namespace deployments in combined charts.
57+
*/}}
58+
{{- define "liferay.namespace" -}}
59+
{{- default .Release.Namespace .Values.namespaceOverride | trunc 63 | trimSuffix "-" -}}
60+
{{- end -}}
61+
5562
{{/*
5663
Selector labels
5764
*/}}
@@ -69,11 +76,4 @@ Create the name of the service account to use
6976
{{- else }}
7077
{{- default "default" .Values.serviceAccount.name }}
7178
{{- end }}
72-
{{- end }}
73-
74-
{{/*
75-
Allow the release namespace to be overridden for multi-namespace deployments in combined charts.
76-
*/}}
77-
{{- define "liferay.namespace" -}}
78-
{{- default .Release.Namespace .Values.namespaceOverride | trunc 63 | trimSuffix "-" -}}
79-
{{- end -}}
79+
{{- end }}

templates/_statefulset.yaml

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
{{/*
2+
Create a StatefulSet workload.
3+
*/}}
4+
{{- define "liferay.statefulset" -}}
5+
{{- $suffix := ternary "" (printf "-%s" .name) (eq .name "") }}
6+
apiVersion: apps/v1
7+
kind: StatefulSet
8+
metadata:
9+
labels:
10+
app: {{ include "liferay.name" .root }}{{ $suffix }}
11+
{{- include "liferay.labels" .root | nindent 4 }}
12+
name: {{ include "liferay.fullname" .root }}{{ $suffix }}
13+
namespace: {{ include "liferay.namespace" .root | quote }}
14+
spec:
15+
replicas: {{ .statefulset.replicaCount }}
16+
selector:
17+
matchLabels:
18+
app: {{ include "liferay.name" .root }}{{ $suffix }}
19+
{{- include "liferay.selectorLabels" .root | nindent 6 }}
20+
serviceName: {{ include "liferay.fullname" .root }}{{ $suffix }}
21+
template:
22+
metadata:
23+
labels:
24+
app: {{ include "liferay.name" .root }}{{ $suffix }}
25+
{{- include "liferay.labels" .root | nindent 8 }}
26+
spec:
27+
{{- with .statefulset.affinity }}
28+
affinity:
29+
{{- toYaml . | nindent 8 }}
30+
{{- end }}
31+
containers:
32+
- # Main container
33+
{{- with .statefulset.env }}
34+
env:
35+
{{- toYaml . | nindent 8 }}
36+
{{- end }}
37+
{{- with .statefulset.envFrom }}
38+
envFrom:
39+
{{- toYaml . | nindent 8 }}
40+
{{- end }}
41+
image: {{ printf "%s:%s" .statefulset.image.repository (.statefulset.image.tag | toString) }}
42+
imagePullPolicy: {{ .statefulset.image.pullPolicy }}
43+
{{- with .statefulset.livenessProbe }}
44+
livenessProbe:
45+
{{- toYaml . | nindent 10 }}
46+
{{- end }}
47+
name: {{ include "liferay.name" .root }}{{ $suffix }}
48+
{{- with .statefulset.ports }}
49+
ports:
50+
{{- toYaml . | nindent 8 }}
51+
{{- end }}
52+
{{- with .statefulset.readinessProbe }}
53+
readinessProbe:
54+
{{- toYaml . | nindent 10 }}
55+
{{- end }}
56+
{{- with .statefulset.resources }}
57+
resources:
58+
{{- toYaml . | nindent 10 }}
59+
{{- end }}
60+
{{- with .statefulset.securityContext }}
61+
securityContext:
62+
{{- toYaml . | nindent 10 }}
63+
{{- end }}
64+
{{- with .statefulset.startupProbe }}
65+
startupProbe:
66+
{{- toYaml . | nindent 10 }}
67+
{{- end }}
68+
{{- with .statefulset.volumeMounts }}
69+
volumeMounts:
70+
{{- toYaml . | nindent 8 }}
71+
{{- end }}
72+
{{- with .statefulset.pullSecrets }}
73+
imagePullSecrets:
74+
{{- toYaml . | nindent 6 }}
75+
{{- end }}
76+
{{- if .statefulset.initContainers }}
77+
{{- $statefulset := .statefulset }}
78+
initContainers:
79+
{{- range .statefulset.initContainers }}
80+
{{- if .containerTemplate }}
81+
{{ tpl .containerTemplate $statefulset | nindent 6 }}
82+
{{- else }}
83+
- {{ toYaml . | nindent 8 }}
84+
{{- end }}
85+
{{- end }}
86+
{{- end }}
87+
{{- with .statefulset.nodeSelector }}
88+
nodeSelector:
89+
{{- toYaml . | nindent 8 }}
90+
{{- end }}
91+
{{- with .statefulset.schedulingGates }}
92+
schedulingGates:
93+
{{- toYaml . | nindent 6 }}
94+
{{- end }}
95+
{{- with .statefulset.podSecurityContext }}
96+
securityContext:
97+
{{- toYaml . | nindent 8 }}
98+
{{- end }}
99+
serviceAccountName: {{ include "liferay.serviceAccountName" .root }}
100+
{{- with .statefulset.tolerations }}
101+
tolerations:
102+
{{- toYaml . | nindent 6 }}
103+
{{- end }}
104+
{{- with .statefulset.volumes }}
105+
volumes:
106+
{{- toYaml . | nindent 6 }}
107+
{{- end }}
108+
{{- with .statefulset.updateStrategy }}
109+
updateStrategy:
110+
{{- toYaml . | nindent 4 }}
111+
{{- end }}
112+
{{- with .statefulset.volumeClaimTemplates }}
113+
volumeClaimTemplates:
114+
{{- toYaml . | nindent 2 }}
115+
{{- end }}
116+
---
117+
apiVersion: v1
118+
kind: Service
119+
metadata:
120+
{{- with .statefulset.service.annotations }}
121+
annotations:
122+
{{- toYaml . | nindent 4 }}
123+
{{- end }}
124+
labels:
125+
app: {{ include "liferay.name" .root }}{{ $suffix }}
126+
{{- include "liferay.labels" .root | nindent 4 }}
127+
name: {{ include "liferay.fullname" .root }}{{ $suffix }}
128+
namespace: {{ include "liferay.namespace" .root | quote }}
129+
spec:
130+
{{- with .statefulset.service.ports }}
131+
ports:
132+
{{- toYaml . | nindent 2 }}
133+
{{- end }}
134+
selector:
135+
app: {{ include "liferay.name" .root }}{{ $suffix }}
136+
{{- include "liferay.selectorLabels" .root | nindent 4 }}
137+
type: {{ .statefulset.service.type }}
138+
---
139+
apiVersion: v1
140+
kind: Service
141+
metadata:
142+
{{- with .statefulset.service.annotations }}
143+
annotations:
144+
{{- toYaml . | nindent 4 }}
145+
{{- end }}
146+
labels:
147+
app: {{ include "liferay.name" .root }}{{ $suffix }}
148+
{{- include "liferay.labels" .root | nindent 4 }}
149+
name: {{ include "liferay.fullname" .root }}{{ $suffix }}-headless
150+
namespace: {{ include "liferay.namespace" .root | quote }}
151+
spec:
152+
clusterIP: None # This is what makes it headless
153+
{{- with .statefulset.service.ports }}
154+
ports:
155+
{{- toYaml . | nindent 2 }}
156+
{{- end }}
157+
selector:
158+
app: {{ include "liferay.name" .root }}{{ $suffix }}
159+
{{- include "liferay.selectorLabels" .root | nindent 4 }}
160+
type: {{ .statefulset.service.type }}
161+
{{- if .statefulset.ingress.enabled }}
162+
---
163+
apiVersion: networking.k8s.io/v1
164+
kind: Ingress
165+
metadata:
166+
{{- with .statefulset.ingress.annotations }}
167+
annotations:
168+
{{- toYaml . | nindent 4 }}
169+
{{- end }}
170+
labels:
171+
app: {{ include "liferay.name" .root }}{{ $suffix }}
172+
{{- include "liferay.labels" .root | nindent 4 }}
173+
name: {{ include "liferay.fullname" .root }}{{ $suffix }}
174+
namespace: {{ include "liferay.namespace" .root | quote }}
175+
spec:
176+
{{- with .statefulset.ingress.className }}
177+
ingressClassName: {{ . }}
178+
{{- end }}
179+
rules:
180+
{{- with .statefulset.ingress.rules }}
181+
{{- toYaml . | nindent 2 }}
182+
{{- end }}
183+
{{- with .statefulset.ingress.tls }}
184+
tls:
185+
{{- toYaml . | nindent 2 }}
186+
{{- end }}
187+
{{- end }}
188+
{{- end -}}

0 commit comments

Comments
 (0)