Skip to content

Commit b3be447

Browse files
authored
- fix: autoscaling apiVersion, autoscaling/v2 is available since 1.23 (#146)
- fix: postgresql dependency (upgrade to the lastest available chart `12.1.6`) - feat: add 2 init container on puppetdb deployment to start only when postgresql & puppet master is ready - feat: allow custom config on puppetdb - feat: bump Puppetserver to `v7.9.2`. - feat: bump PuppetDB to `v7.10.0`. - feat: bump Puppetboard to `v4.2.4`. - fix: move configmap in /tmp to avoid Read Only error in puppetserver init container
1 parent 0c5d19d commit b3be447

14 files changed

Lines changed: 238 additions & 143 deletions

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ numbering uses [semantic versioning](http://semver.org).
55

66
NOTE: The change log until version `v0.2.4` is auto-generated.
77

8+
## [v7.0.0](https://github.com/puppetlabs/puppetserver-helm-chart/tree/v7.0.0) (2023-01-05)
9+
10+
- fix: autoscaling apiVersion, `autoscaling/v2` is available since 1.23
11+
- fix: postgresql dependency (upgrade to the lastest available chart `12.1.6`)
12+
- feat: add 2 init container on puppetdb deployment to start only when postgresql & puppet master is ready
13+
- feat: allow custom config on puppetdb
14+
- feat: bump Puppetserver to `v7.9.2`.
15+
- feat: bump PuppetDB to `v7.10.0`.
16+
- feat: bump Puppetboard to `v4.2.4`.
17+
- fix: move configmap in /tmp to avoid Read Only error in puppetserver init container
18+
819
## [v6.8.2](https://github.com/puppetlabs/puppetserver-helm-chart/tree/v6.8.2) (2022-12-31)
920

1021
- fix: set postgresql.fullnameOverride to match chart name, avoids error when release name is different

Chart.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
apiVersion: v2
22
name: puppetserver
3-
version: 6.8.2
4-
appVersion: 7.4.2
3+
version: 7.0.0
4+
appVersion: 7.9.2
55
description: Puppet automates the delivery and operation of software.
66
keywords: ["puppet", "puppetserver", "automation", "iac", "infrastructure", "cm", "ci", "cd"]
77
home: https://puppet.com/
88
icon: https://secure.gravatar.com/avatar/fdd009b7c1ec96e088b389f773e87aec.jpg?s=80&r=g&d=mm
99
dependencies:
1010
- name: postgresql
11-
version: 10.16.*
11+
version: 12.1.6
1212
repository: https://charts.bitnami.com/bitnami
1313
condition: postgresql.enabled
1414
sources:

README.md

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ To achieve better throughput of Puppet Infrastructure, you can enable and scale
7070

7171
### Multiple PostgreSQL Read Replicas
7272

73-
To achieve better throughput of Puppet Infrastructure, you can enable and scale out PostgreSQL cluster using `.Values.postgresql.replication.enabled` and `.Values.postgresql.replication.slaveReplicas`.
73+
For now it's not available anymore, since bitnami cleanned their old release. for multiple Postgresql we have to use postgresql-ha.
74+
Read replica return an error on puppetdb:
75+
`ERROR [p.p.c.services] Will retry database connection after temporary failure: java.sql.SQLTransientConnectionException: PDBMigrationsPool: default - Connection is not available, request timed out after 3002ms.`
76+
7477

7578
## Chart Components
7679

@@ -145,6 +148,17 @@ The following table lists the configurable parameters of the Puppetserver chart
145148

146149
| Parameter | Description | Default|
147150
| --------- | ----------- | -------|
151+
| `global.curl.image`| curl image |`curlimages/curl`|
152+
| `global.curl.tag`| curl image tag |`7.87.0`|
153+
| `global.curl.imagePullPolicy`| curl image pull policy |`IfNotPresent`|
154+
| `global.imagePullSecrets` | Global Docker registry secret names as an array | [] |
155+
| `global.pgchecker.image`| pgchecker image |`docker.io/busybox`|
156+
| `global.pgchecker.tag`| pgchecker image tag |`1.36`|
157+
| `global.pgchecker.imagePullPolicy`| pgchecker image pull policy |`IfNotPresent`|
158+
| `global.postgresql.auth.username`| puppetdb and postgresql username |`puppetdb`|
159+
| `global.postgresql.auth.password`| puppetdb and postgresql password |`unbreakablePassword`|
160+
| `global.postgresql.auth.existingSecret`| existing k8s secret that holds puppetdb and postgresql username and password |``|
161+
| `global.postgresql.*`| please refer to https://github.com/bitnami/charts/tree/main/bitnami/postgresql#global-parameters |``|
148162
| `puppetserver.name` | puppetserver component label | `puppetserver`|
149163
| `puppetserver.image` | puppetserver image | `puppet/puppetserver`|
150164
| `puppetserver.tag` | puppetserver img tag | `6.12.1`|
@@ -283,18 +297,12 @@ The following table lists the configurable parameters of the Puppetserver chart
283297
| `r10k.hiera.viaSsh.credentials.ssh.value`| r10k hiera data ssh key file |``|
284298
| `r10k.hiera.viaSsh.credentials.known_hosts.value`| r10k hiera data ssh known hosts file |``|
285299
| `r10k.hiera.viaSsh.credentials.existingSecret`| r10k hiera data ssh secret that holds ssh key and known hosts files |``|
286-
| `postgresql.enabled` | postgres deployment as puppetdb backend | `true`|
287-
| `postgresql.name` | postgres component label | `postgresql`|
288-
| `postgresql.resources` | postgres resource limits |``|
289-
| `postgresql.postgresqlDatabase` | postgres database name |`puppetdb`|
290-
| `postgresql.initdbUser` | postgres username to run initdb scripts at first boot |`postgres`|
291-
| `postgresql.initdbScriptsConfigMap` | postgres initdb scripts run at first boot |`postgresql-custom-extensions`|
292-
| `postgresql.persistence.enabled` | postgres database persistence |`true`|
293-
| `postgresql.persistence.existingClaim` | postgres manually managed pvc |``|
294-
| `postgresql.persistence.size` | postgres persistence pvc size |`10Gi`|
295-
| `postgresql.persistence.annotations` | postgres persistence resource policy via annotations |`keep`|
296-
| `postgresql.replication.enabled` | postgres replication availability |`false`|
297-
| `postgresql.replication.slaveReplicas` | postgres replication slave replicas |`1`|
300+
| `postgresql.*`| please refer to https://github.com/bitnami/charts/tree/main/bitnami/postgresql#parameters |``|
301+
| `postgresql.primary.initdb.scriptsConfigMap` | postgres initdb scripts run at first boot |`postgresql-custom-extensions`|
302+
| `postgresql.primary.persistence.enabled` | postgres database persistence |`true`|
303+
| `postgresql.primary.persistence.existingClaim` | postgres manually managed pvc |``|
304+
| `postgresql.primary.persistence.size` | postgres persistence pvc size |`10Gi`|
305+
| `postgresql.primary.persistence.annotations` | postgres annotations for the PVC |`helm.sh/resource-policy: keep`|
298306
| `puppetdb.enabled` | puppetdb component enabled |`true`|
299307
| `puppetdb.name` | puppetdb component label | `puppetdb`|
300308
| `puppetdb.image` | puppetdb img | `puppet/puppetdb`|
@@ -313,7 +321,10 @@ The following table lists the configurable parameters of the Puppetserver chart
313321
| `puppetdb.customPersistentVolumeClaim.storage.enable`| If true, use custom PVC for storage |``|
314322
| `puppetdb.customPersistentVolumeClaim.storage.config`| Configuration for custom PVC for storage |``|
315323
| `puppetdb.extraContainers`| Extra containers to inject into the puppetdb pod |``|
324+
| `puppetdb.extraInitContainers`| Extra initContainers to inject into the puppetdb pod |``|
316325
| `puppetdb.serviceAccount.enabled`| Enable service account (Note: Service Account will only be automatically created if `puppetdb.serviceAccount.create` is not set. |`false`|
326+
| `puppetdb.customconfigs.enabled`| puppetdb additional config map enabled |`false`|
327+
317328
| `puppetdb.serviceAccount.create`| puppetdb additional masters svc labels |`false`|
318329
| `puppetdb.rbac.create`| Enable PodSecurityPolicy's RBAC rules |`false`|
319330
| `puppetdb.psp.create`| Whether to create a PodSecurityPolicy. WARNING: PodSecurityPolicy is deprecated in Kubernetes v1.21 or later, unavailable in v1.25 or later |`false`|
@@ -336,10 +347,6 @@ The following table lists the configurable parameters of the Puppetserver chart
336347
| `hiera.config`| hieradata yaml config |``|
337348
| `hiera.eyaml.private_key`| hiera eyaml private key |``|
338349
| `hiera.eyaml.public_key`| hiera eyaml public key |``|
339-
| `global.imagePullSecrets` | Global Docker registry secret names as an array | [] |
340-
| `global.credentials.username`| puppetdb and postgresql username |`puppetdb`|
341-
| `global.credentials.password`| puppetdb and postgresql password |`unbreakablePassword`|
342-
| `global.credentials.existingSecret`| existing k8s secret that holds puppetdb and postgresql username and password |``|
343350
| `nameOverride`| puppetserver components name for `component:` labels |``|
344351
| `nodeSelector`| Node labels for pod assignment |``|
345352
| `affinity`| Affinity for pod assignment |``|

templates/NOTES.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ Hieradata Repo: "{{.Values.hiera.hieradataurl}}"
2222
{{- end }}
2323

2424
{{ if .Values.hiera.eyaml.existingMap -}}
25-
WARNING: you specified a ConfigMap for eyaml secret and it unsecure
25+
WARNING: you specified a ConfigMap for eyaml secret and it unsecure
2626
{{- end }}
2727
{{- if or (.Values.hiera.eyaml.public_key) (.Values.hiera.eyaml.private_key) }}
28-
WARNING: you specified a eyaml keys inside the values.yaml and it unsecure
28+
WARNING: you specified a eyaml keys inside the values.yaml and it unsecure
2929
{{- end }}
3030

3131
If you need to get your password for PuppetDB and PostgreSQL:

templates/_helpers.tpl

Lines changed: 25 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ app.kubernetes.io/component: {{ .Values.r10k.name }}
9191
{{- end -}}
9292

9393
{{- define "puppetserver.postgresql.matchLabels" -}}
94-
app.kubernetes.io/component: {{ .Values.postgresql.name }}
94+
app.kubernetes.io/component: postgresql
9595
{{ include "puppetserver.common.matchLabels" . }}
9696
{{- end -}}
9797

@@ -215,6 +215,15 @@ Puppet Compilers' port.
215215
{{- or (eq (include "puppetserver.ingress.isStable" .) "true") (and (eq (include "puppetserver.ingress.apiVersion" .) "networking.k8s.io/v1beta1") (semverCompare ">= 1.18-0" (include "puppetserver.kubeVersion" .))) -}}
216216
{{- end -}}
217217
218+
{{/* Get autoscaling API Version */}}
219+
{{- define "puppetserver.autoscaling.apiVersion" -}}
220+
{{- if and (semverCompare ">= 1.23-0" (include "puppetserver.kubeVersion" .)) -}}
221+
{{- print "autoscaling/v2" -}}
222+
{{- else -}}
223+
{{- print "autoscaling/v2beta2" -}}
224+
{{- end -}}
225+
{{- end -}}
226+
218227
{{/*
219228
Set's the affinity for pod placement
220229
when running with multiple Puppet compilers.
@@ -257,49 +266,12 @@ Calculates the max. number of compilers
257266
{{- end -}}
258267
{{- end -}}
259268

260-
{{/*
261-
Return PostgreSQL username
262-
*/}}
263-
{{- define "postgresql.username" -}}
264-
{{- if .Values.global.credentials.username }}
265-
{{- .Values.global.credentials.username -}}
266-
{{- else -}}
267-
{{- .Values.postgresqlUsername -}}
268-
{{- end -}}
269-
{{- end -}}
270-
271-
{{/*
272-
Return PuppetDB and PostgreSQL password
273-
*/}}
274-
{{- define "postgresql.password" -}}
275-
{{- if .Values.global.credentials.password }}
276-
{{- .Values.global.credentials.password -}}
277-
{{- else if .Values.postgresqlPassword -}}
278-
{{- .Values.postgresqlPassword -}}
279-
{{- else -}}
280-
unbreakablePassword
281-
{{- end -}}
282-
{{- end -}}
283-
284-
{{/*
285-
Return PuppetDB and PostgreSQL password
286-
*/}}
287-
{{- define "postgresql.postgres.password" -}}
288-
{{- if .Values.global.credentials.password }}
289-
{{- .Values.global.credentials.password -}}
290-
{{- else if .Values.postgresqlPostgresPassword -}}
291-
{{- .Values.postgresqlPostgresPassword -}}
292-
{{- else -}}
293-
unbreakablePassword
294-
{{- end -}}
295-
{{- end -}}
296-
297269
{{/*
298270
Create the name for the PuppetDB password secret.
299271
*/}}
300272
{{- define "puppetdb.secret" -}}
301-
{{- if .Values.global.credentials.existingSecret -}}
302-
{{- .Values.global.credentials.existingSecret -}}
273+
{{- if .Values.global.postgresql.auth.existingSecret -}}
274+
{{- .Values.global.postgresql.auth.existingSecret -}}
303275
{{- else -}}
304276
puppetdb-secret
305277
{{- end -}}
@@ -388,7 +360,7 @@ Define puppetserver service Account name
388360
*/}}
389361
{{- define "puppetserver.puppetserver.serviceAccount.name" -}}
390362
{{ default "puppetserver" .Values.puppetserver.serviceAccount.accountName }}
391-
{{- end -}}
363+
{{- end -}}
392364

393365
{{/*
394366
Define puppetdb service Account name
@@ -397,6 +369,18 @@ Define puppetdb service Account name
397369
{{ default "puppetdb" .Values.puppetdb.serviceAccount.accountName }}
398370
{{- end -}}
399371

372+
{{/*
373+
Return PostgreSQL host name
374+
*/}}
375+
{{- define "postgresql.hostname" -}}
376+
{{- if .Values.postgresql.enabled }}
377+
{{- if eq .Values.postgresql.architecture "standalone" -}}
378+
{{- printf "%s-%s" .Release.Name "postgresql-hl" | trimSuffix "-" -}}
379+
{{- else }}
380+
{{- printf "%s-%s" .Release.Name "postgresql-primary-hl" | trimSuffix "-" -}}
381+
{{- end -}}
382+
{{- end -}}
383+
{{- end -}}
400384

401385
{{/* *************************************************************************************
402386
The following definitions were more complex and necessary during part of this development.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{{- if .Values.puppetdb.customconfigs.enabled }}
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: puppetdb-custom-configs
6+
labels:
7+
{{- include "puppetserver.puppetdb.labels" . | nindent 4 }}
8+
data:
9+
{{- toYaml .Values.puppetdb.customconfigs.configmaps | nindent 2 }}
10+
{{- end }}
11+

templates/puppetdb-deployment.yaml

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,71 @@ spec:
2121
{{- include "puppetserver.puppetdb.labels" . | nindent 8 }}
2222
{{- if .Values.podAnnotations }}
2323
annotations:
24+
{{- if .Values.puppetdb.customconfigs.enabled }}
25+
checksum/custom-configs.configmap: {{ include (print $.Template.BasePath "/puppetdb-customconfigs-configmap.yaml") . | sha256sum }}
26+
{{- end }}
2427
{{- toYaml .Values.podAnnotations | nindent 8 }}
2528
{{- end }}
2629
spec:
2730
hostname: puppetdb
2831
{{- if .Values.puppetdb.serviceAccount.enabled }}
2932
serviceAccountName: {{ include "puppetserver.puppetdb.serviceAccount.name" . }}
3033
{{- end }}
34+
initContainers:
35+
{{- with .Values.puppetdb.extraInitContainers }}
36+
{{- toYaml . | nindent 8 }}
37+
{{- end }}
38+
- name: pgchecker
39+
image: "{{.Values.global.pgchecker.image}}:{{.Values.global.pgchecker.tag}}"
40+
imagePullPolicy: {{.Values.global.pgchecker.imagePullPolicy}}
41+
securityContext:
42+
allowPrivilegeEscalation: false
43+
runAsUser: 1000
44+
runAsGroup: 1000
45+
runAsNonRoot: true
46+
command:
47+
- sh
48+
- -c
49+
- |
50+
echo 'Waiting for PostgreSQL to become ready...'
51+
until printf "." && nc -z -w 2 {{ include "postgresql.hostname" . }} 5432; do
52+
sleep 2;
53+
done;
54+
echo 'PostgreSQL OK ✓'
55+
resources:
56+
requests:
57+
cpu: 20m
58+
memory: 32Mi
59+
limits:
60+
cpu: 20m
61+
memory: 32Mi
62+
- name: wait-puppetserver
63+
image: "{{.Values.global.curl.image}}:{{.Values.global.curl.tag}}"
64+
imagePullPolicy: {{.Values.global.curl.imagePullPolicy}}
65+
securityContext:
66+
allowPrivilegeEscalation: false
67+
runAsUser: 1000
68+
runAsGroup: 1000
69+
runAsNonRoot: true
70+
command:
71+
- sh
72+
- -c
73+
- |
74+
echo 'Waiting for puppetserver to become ready...'
75+
until curl --silent --fail --insecure 'https://puppet:{{ template "puppetserver.puppetserver-masters.port" . }}/status/v1/simple' | grep -q '^running$'; do
76+
sleep 2;
77+
done;
78+
echo 'Puppetserver OK ✓'
79+
resources:
80+
requests:
81+
cpu: 20m
82+
memory: 32Mi
83+
limits:
84+
cpu: 20m
85+
memory: 32Mi
86+
{{- if .Values.puppetdb.extraInitContainers }}
87+
{{- toYaml .Values.puppetdb.extraInitContainers | nindent 8 }}
88+
{{- end }}
3189
containers:
3290
{{- with .Values.puppetdb.extraContainers }}
3391
{{- toYaml . | nindent 8 }}
@@ -44,7 +102,7 @@ spec:
44102
value: "{{ template "puppetserver.puppetserver-masters.port" . }}"
45103
{{- if not (hasKey .Values.puppetdb.extraEnv "PUPPETDB_POSTGRES_HOSTNAME") }}
46104
- name: PUPPETDB_POSTGRES_HOSTNAME
47-
value: "{{ template "puppetserver.name" . }}-postgresql"
105+
value: "{{ include "postgresql.hostname" . }}"
48106
{{- end }}
49107
- name: PUPPETDB_PASSWORD
50108
valueFrom:
@@ -76,6 +134,11 @@ spec:
76134
mountPath: /etc/puppetlabs/puppetdb/conf.d/metrics.conf
77135
subPath: metrics.conf
78136
{{- end -}}
137+
{{- range $key, $value := .Values.puppetdb.customconfigs.configmaps }}
138+
- name: puppetdb-custom-configs
139+
mountPath: /etc/puppetlabs/puppetdb/conf.d/{{ $key }}
140+
subPath: {{ $key }}
141+
{{- end }}
79142
{{- if .Values.puppetboard.enabled }}
80143
- name: puppetboard
81144
image: "{{.Values.puppetboard.image}}:{{.Values.puppetboard.tag}}"
@@ -95,6 +158,11 @@ spec:
95158
value: "/opt/puppetlabs/server/data/puppetdb/certs/private_keys/puppetdb.pem"
96159
- name: PUPPETBOARD_PORT
97160
value: {{ .Values.puppetboard.port | quote }}
161+
- name: SECRET_KEY
162+
valueFrom:
163+
secretKeyRef:
164+
name: puppetdb-puppetboard
165+
key: SECRET_KEY
98166
{{- range $key, $value := .Values.puppetboard.extraEnv }}
99167
- name: {{ $key }}
100168
value: "{{ $value }}"
@@ -177,6 +245,11 @@ spec:
177245
configMap:
178246
name: puppetdb-metrics-config
179247
{{- end }}
248+
{{- if .Values.puppetdb.customconfigs.enabled }}
249+
- name: puppetdb-custom-configs
250+
configMap:
251+
name: puppetdb-custom-configs
252+
{{- end }}
180253
{{- if .Values.nodeSelector }}
181254
nodeSelector:
182255
{{ toYaml .Values.nodeSelector | nindent 10 }}

templates/puppetdb-secret.yaml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
{{- if not .Values.global.credentials.existingSecret -}}
1+
{{- if .Values.puppetdb.enabled }}
2+
{{- if not .Values.global.postgresql.auth.existingSecret }}
23
apiVersion: v1
34
kind: Secret
45
metadata:
@@ -7,6 +8,22 @@ metadata:
78
{{- include "puppetserver.puppetdb.labels" . | nindent 4 }}
89
type: Opaque
910
data:
10-
username: {{ .Values.global.credentials.username | b64enc | quote }}
11-
password: {{ include "postgresql.password" . | b64enc | quote }}
12-
{{- end -}}
11+
username: {{ .Values.global.postgresql.auth.username | b64enc | quote }}
12+
password: {{ .Values.global.postgresql.auth.password | b64enc | quote }}
13+
{{- end }}
14+
---
15+
{{- if .Values.puppetboard.enabled }}
16+
apiVersion: v1
17+
kind: Secret
18+
metadata:
19+
name: puppetdb-puppetboard
20+
type: Opaque
21+
data:
22+
{{- $secret := lookup "v1" "Secret" .Release.Namespace "puppetdb-puppetboard" }}
23+
{{- if $secret }}
24+
SECRET_KEY: {{ $secret.data.SECRET_KEY }}
25+
{{- else }}
26+
SECRET_KEY: {{ randAlphaNum 64 | b64enc | quote }}
27+
{{- end }}
28+
{{- end }}
29+
{{- end }}

0 commit comments

Comments
 (0)