Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a custom CA file for r10k control repo #212

Merged
merged 4 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ numbering uses [semantic versioning](http://semver.org).

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

## [v9.3.0](https://github.com/puppetlabs/puppetserver-helm-chart/tree/v9.3.0) (2024-03-28)
- Feat: Use custom CA file for r10k HTTPS code repository

## [v9.2.1](https://github.com/puppetlabs/puppetserver-helm-chart/tree/v9.2.1) (2024-03-27)
- Fix: Add 'netrc' credentials documentation for r10k and hiera repos

Expand Down
2 changes: 1 addition & 1 deletion Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: puppetserver
version: 9.2.1
version: 9.3.0
appVersion: 7.13.0
description: Puppet automates the delivery and operation of software.
keywords: ["puppet", "puppetserver", "automation", "iac", "infrastructure", "cm", "ci", "cd"]
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,8 @@ The following table lists the configurable parameters of the Puppetserver chart
| `r10k.code.viaSsh.credentials.existingSecret`| r10k control repo ssh secret that holds ssh key and known hosts files |``|
| `r10k.code.viaHttps.credentials.netrc.value`| r10k control repo https .netrc file |``|
| `r10k.code.viaHttps.credentials.existingSecret`| r10k control repo https secret that holds .netrc file contents in `netrc` key |``|
| `r10k.code.viaHttps.customCa.cert.value`| r10k control repo https custom CA file in PEM format |``|
| `r10k.code.viaHttps.customCa.existingSecret`| r10k control repo https secret that holds custom CA file in PEM format in `cert` key |``|
| `r10k.hiera.resources` | r10k hiera data resource limits |``|
| `r10k.hiera.cronJob.enabled` | enable or disable r10k hiera data cron job schedule policy | `true`|
| `r10k.hiera.cronJob.schedule` | r10k hiera data cron job schedule policy | `*/2 * * * *`|
Expand Down
20 changes: 20 additions & 0 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ Create the args array for "r10k_code_cronjob.sh"
{{- join " " .Values.r10k.code.extraArgs }}
{{- end -}}

{{/*
Create the base URL for custom CA repo configuration
*/}}
{{- define "r10k.code.viaHttps.customCa.repoUrl" -}}
{{- $parsedRepo := urlParse .Values.puppetserver.puppeturl -}}
{{- printf "%s://%s" $parsedRepo.scheme $parsedRepo.host }}
{{- end -}}

{{/*
Create the args array for "r10k_hiera_cronjob.sh"
*/}}
Expand Down Expand Up @@ -578,6 +586,18 @@ Create the name for the r10k.code.viaHttps secret.
{{- end -}}
{{- end -}}

{{/*
Create the name for the r10k.code.viaHttps.customCa secret.
Defaults to "r10k.code.viaHttps.secret"
*/}}
{{- define "r10k.code.viaHttps.customCa.secret" -}}
{{- if .Values.r10k.code.viaHttps.customCa.existingSecret -}}
{{- .Values.r10k.code.viaHttps.customCa.existingSecret -}}
{{- else -}}
{{ template "r10k.code.viaHttps.secret" . }}
{{- end -}}
{{- end -}}

{{/*
Create the name for the r10k.hiera.viaSsh secret.
*/}}
Expand Down
16 changes: 16 additions & 0 deletions templates/puppet-r10k-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ spec:
subPath: .netrc
{{- end }}
{{- end }}
{{- with .Values.r10k.code.viaHttps.customCa }}
{{- if or .existingSecret .cert.value }}
- name: r10k-code-cert
mountPath: /home/puppet/code-certs/ca.pem
subPath: ca.pem
{{- end }}
{{- end }}
- name: puppet-code-storage
mountPath: /etc/puppetlabs/code/
- name: r10k-code-volume
Expand Down Expand Up @@ -199,6 +206,15 @@ spec:
- key: known_hosts
path: known_hosts
{{- end }}
{{- if or .Values.r10k.code.viaHttps.customCa.existingSecret .Values.r10k.code.viaHttps.customCa.cert.value }}
- name: r10k-code-cert
secret:
secretName: {{ template "r10k.code.viaHttps.customCa.secret" . }}
defaultMode: 288 # = mode 0440
items:
- key: cert
path: ca.pem
{{- end }}
{{- if or .Values.r10k.code.viaHttps.credentials.existingSecret .Values.r10k.code.viaHttps.credentials.netrc.value }}
- name: r10k-code-netrc
secret:
Expand Down
16 changes: 16 additions & 0 deletions templates/puppetserver-deployment-compilers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,13 @@ spec:
subPath: .netrc
{{- end }}
{{- end }}
{{- with .Values.r10k.code.viaHttps.customCa }}
{{- if or .existingSecret .cert.value }}
- name: r10k-code-cert
mountPath: /home/puppet/code-certs/ca.pem
subPath: ca.pem
{{- end }}
{{- end }}
- name: puppet-code-storage
mountPath: /etc/puppetlabs/code/
- name: puppet-puppet-storage
Expand Down Expand Up @@ -614,6 +621,15 @@ spec:
- key: netrc
path: .netrc
{{- end }}
{{- if or .Values.r10k.code.viaHttps.customCa.existingSecret .Values.r10k.code.viaHttps.customCa.cert.value }}
- name: r10k-code-cert
secret:
secretName: {{ template "r10k.code.viaHttps.customCa.secret" . }}
defaultMode: 288 # = mode 0440
items:
- key: cert
path: ca.pem
{{- end }}
- name: r10k-code-volume
configMap:
name: {{ template "puppetserver.fullname" . }}-r10k-code-config
Expand Down
16 changes: 16 additions & 0 deletions templates/puppetserver-deployment-masters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,13 @@ spec:
subPath: .netrc
{{- end }}
{{- end }}
{{- with .Values.r10k.code.viaHttps.customCa }}
{{- if or .existingSecret .cert.value }}
- name: r10k-code-cert
mountPath: /home/puppet/code-certs/ca.pem
subPath: ca.pem
{{- end }}
{{- end }}
- name: puppet-code-storage
mountPath: /etc/puppetlabs/code/
- name: puppet-puppet-storage
Expand Down Expand Up @@ -680,6 +687,15 @@ spec:
- key: netrc
path: .netrc
{{- end }}
{{- if or .Values.r10k.code.viaHttps.customCa.existingSecret .Values.r10k.code.viaHttps.customCa.cert.value }}
- name: r10k-code-cert
secret:
secretName: {{ template "r10k.code.viaHttps.customCa.secret" . }}
defaultMode: 288 # = mode 0440
items:
- key: cert
path: ca.pem
{{- end }}
{{- if .Values.puppetserver.puppeturl }}
- name: r10k-code-volume
configMap:
Expand Down
16 changes: 16 additions & 0 deletions templates/puppetserver-statefulset-compilers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,13 @@ spec:
subPath: .netrc
{{- end }}
{{- end }}
{{- with .Values.r10k.code.viaHttps.customCa }}
{{- if or .existingSecret .cert.value }}
- name: r10k-code-cert
mountPath: /home/puppet/code-certs/ca.pem
subPath: ca.pem
{{- end }}
{{- end }}
- name: puppet-code-volume
mountPath: /etc/puppetlabs/code/
- name: puppet-puppet-volume
Expand Down Expand Up @@ -595,6 +602,15 @@ spec:
- key: netrc
path: .netrc
{{- end }}
{{- if or .Values.r10k.code.viaHttps.customCa.existingSecret .Values.r10k.code.viaHttps.customCa.cert.value }}
- name: r10k-code-cert
secret:
secretName: {{ template "r10k.code.viaHttps.customCa.secret" . }}
defaultMode: 288 # = mode 0440
items:
- key: cert
path: ca.pem
{{- end }}
{{- if .Values.puppetserver.puppeturl }}
- name: r10k-code-volume
configMap:
Expand Down
5 changes: 5 additions & 0 deletions templates/r10k-code-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@ data:
netrc: {{ .netrc.value | b64enc | quote }}
{{- end }}
{{- end }}
{{- with .Values.r10k.code.viaHttps.customCa }}
{{- if .cert.value }}
cert: {{ .cert.value | b64enc | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
3 changes: 3 additions & 0 deletions templates/r10k-code.configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ data:
tail -Fq ~/.r10k_code_cronjob.out &
{{- end }}
touch {{ .Values.r10k.code.cronJob.successFile }} > /dev/null 2>&1
{{- if .Values.r10k.code.viaHttps.customCa }}
git config --global http."{{ template "r10k.code.viaHttps.customCa.repoUrl" .}}".sslCAInfo ~/code-certs/ca.pem
{{- end }}
{{- if .Values.r10k.code.cronJob.enabled }}
exec supercronic ~/.r10k_code_crontab
{{- else}}
Expand Down
2 changes: 1 addition & 1 deletion tests/__snapshot__/jmx-servicemonitor_test.yaml.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ manifest should match snapshot:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: puppetserver
app.kubernetes.io/version: 7.13.0
helm.sh/chart: puppetserver-9.2.1
helm.sh/chart: puppetserver-9.3.0
release: kube-prometheus-stack
name: puppetserver-jmx
namespace: puppet
Expand Down
2 changes: 1 addition & 1 deletion tests/__snapshot__/puppetdb-pvc_test.yaml.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ manifest should match snapshot:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: puppetserver
app.kubernetes.io/version: 7.13.0
helm.sh/chart: puppetserver-9.2.1
helm.sh/chart: puppetserver-9.3.0
name: puppetserver-puppetdb-claim
spec:
accessModes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ manifest should match snapshot:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: puppetserver
app.kubernetes.io/version: 7.13.0
helm.sh/chart: puppetserver-9.2.1
helm.sh/chart: puppetserver-9.3.0
release: kube-prometheus-stack
name: puppetserver-puppetdb
namespace: puppet
Expand Down
2 changes: 1 addition & 1 deletion tests/__snapshot__/puppetdb.networkpolicy_test.yaml.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ manifest should match snapshot:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: puppetserver
app.kubernetes.io/version: 7.13.0
helm.sh/chart: puppetserver-9.2.1
helm.sh/chart: puppetserver-9.3.0
name: puppetserver-puppetdb
spec:
egress:
Expand Down
2 changes: 1 addition & 1 deletion tests/__snapshot__/puppetserver-ca-pvc_test.yaml.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ manifest should match snapshot:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: puppetserver
app.kubernetes.io/version: 7.13.0
helm.sh/chart: puppetserver-9.2.1
helm.sh/chart: puppetserver-9.3.0
name: puppetserver-ca-claim
spec:
accessModes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ manifest should match snapshot:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: puppetserver
app.kubernetes.io/version: 7.13.0
helm.sh/chart: puppetserver-9.2.1
helm.sh/chart: puppetserver-9.3.0
name: puppetserver-puppetserver-compiler
spec:
replicas: 1
Expand All @@ -31,7 +31,7 @@ manifest should match snapshot:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: puppetserver
app.kubernetes.io/version: 7.13.0
helm.sh/chart: puppetserver-9.2.1
helm.sh/chart: puppetserver-9.3.0
spec:
containers:
- env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ manifest should match snapshot:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: puppetserver
app.kubernetes.io/version: 7.13.0
helm.sh/chart: puppetserver-9.2.1
helm.sh/chart: puppetserver-9.3.0
name: puppetserver-puppetserver-compilers
spec:
egress:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ manifest should match snapshot:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: puppetserver
app.kubernetes.io/version: 7.13.0
helm.sh/chart: puppetserver-9.2.1
helm.sh/chart: puppetserver-9.3.0
name: puppetserver-compilers
spec:
maxUnavailable: 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ manifest should match snapshot:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: puppetserver
app.kubernetes.io/version: 7.13.0
helm.sh/chart: puppetserver-9.2.1
helm.sh/chart: puppetserver-9.3.0
name: puppetserver-puppetserver-compiler
spec:
podManagementPolicy: OrderedReady
Expand All @@ -32,7 +32,7 @@ manifest should match snapshot:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: puppetserver
app.kubernetes.io/version: 7.13.0
helm.sh/chart: puppetserver-9.2.1
helm.sh/chart: puppetserver-9.3.0
spec:
containers:
- env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ manifest should match snapshot:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: puppetserver
app.kubernetes.io/version: 7.13.0
helm.sh/chart: puppetserver-9.2.1
helm.sh/chart: puppetserver-9.3.0
name: puppetserver-puppetserver
spec:
egress:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ manifest should match snapshot:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: puppetserver
app.kubernetes.io/version: 7.13.0
helm.sh/chart: puppetserver-9.2.1
helm.sh/chart: puppetserver-9.3.0
name: puppetserver-masters
spec:
maxUnavailable: 2
Expand Down
2 changes: 1 addition & 1 deletion tests/__snapshot__/puppetserver-pvc_test.yaml.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ manifest should match snapshot:
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: puppetserver
app.kubernetes.io/version: 7.13.0
helm.sh/chart: puppetserver-9.2.1
helm.sh/chart: puppetserver-9.3.0
name: puppetserver-puppet-claim
spec:
accessModes:
Expand Down
6 changes: 6 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,12 @@ r10k:
## from a pre-existing K8s secret
## NOTE: Using this secret supercedes all other credentials settings.
existingSecret: ""
customCa:
cert:
## A multi-line string
value: # |
# PEM-encoded custom CA certificates
existingSecret: ""
viaSsh:
credentials:
ssh:
Expand Down
Loading