Skip to content

Commit

Permalink
add support run both docker and containerd certs update (#2092)
Browse files Browse the repository at this point in the history
* add support run both docker and containerd certs update

* update certificate path

* update containerd test case

* update containerd cert mount name
  • Loading branch information
pgvishnuram committed Jan 29, 2024
1 parent 1bbf1f3 commit c72c4be
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ data:
if [ ! -d /hostcontainerd/certs.d/$REGISTRY_HOST ]; then
mkdir -p /hostcontainerd/certs.d/$REGISTRY_HOST;
fi
cp $dir/*.crt /hostcontainerd/certs.d/$REGISTRY_HOST/;
cp $dir/*.crt /hostcontainerd/certs.d/registry.{{ .Values.global.baseDomain }}/;
cp $dir/*.pem /hostcontainerd/certs.d/$REGISTRY_HOST/;
cp $dir/*.pem /hostcontainerd/certs.d/registry.{{ .Values.global.baseDomain }}/;
if [ "$CONFIG_KEY" = true ]; then
cp /hostcontainerd/host.toml /hostcontainerd/certs.d/$REGISTRY_HOST/host.toml
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ spec:
subPath: update-containerd-certs.sh
{{ range $secret_name := (.Values.global.privateCaCerts) }}
- name: {{ $secret_name }}
mountPath: /private-ca-certs/{{ $secret_name }}/{{ $secret_name }}.crt
subPath: {{ $secret_name }}.crt
mountPath: /private-ca-certs/{{ $secret_name }}/{{ $secret_name }}.pem
subPath: cert.pem
{{- end }}
terminationGracePeriodSeconds: 1
hostNetwork: true
Expand Down
2 changes: 1 addition & 1 deletion templates/trust-private-ca-on-all-nodes/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if and .Values.global.privateCaCertsAddToHost.enabled ( not .Values.global.privateCaCertsAddToHost.addToContainerd ) }}
{{- if and .Values.global.privateCaCertsAddToHost.enabled .Values.global.privateCaCertsAddToHost.addToDockerd }}
################################
## DaemonSet to mount the private root CA
##
Expand Down
14 changes: 7 additions & 7 deletions tests/chart_tests/test_containerd_privateca.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ def test_containerd_privateca_daemonset_enabled(self, kube_version):
cert_copier = docs[0]["spec"]["template"]["spec"]["containers"][0]
cert_copier["image"].startswith("alpine:3")

volmounts = cert_copier["volumeMounts"]
volumemounts = cert_copier["volumeMounts"]

volmounts_expected = [
expected_volumemounts = [
{"name": "hostcerts", "mountPath": "/host-trust-store"},
{
"mountPath": "/hostcontainerd",
Expand All @@ -84,14 +84,14 @@ def test_containerd_privateca_daemonset_enabled(self, kube_version):
},
{
"name": "private-ca-cert-foo",
"mountPath": "/private-ca-certs/private-ca-cert-foo/private-ca-cert-foo.crt",
"subPath": "private-ca-cert-foo.crt",
"mountPath": "/private-ca-certs/private-ca-cert-foo/private-ca-cert-foo.pem",
"subPath": "cert.pem",
},
{
"name": "private-ca-cert-bar",
"mountPath": "/private-ca-certs/private-ca-cert-bar/private-ca-cert-bar.crt",
"subPath": "private-ca-cert-bar.crt",
"mountPath": "/private-ca-certs/private-ca-cert-bar/private-ca-cert-bar.pem",
"subPath": "cert.pem",
},
]

assert volmounts == volmounts_expected
assert volumemounts == expected_volumemounts
1 change: 1 addition & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ global:
enabled: false
hostDirectory: /etc/docker/certs.d
addToContainerd: false
addToDockerd: true
containerdCertConfigPath: /etc/containerd/certs.d
containerdConfigToml: ~
containerdnodeAffinitys: []
Expand Down

0 comments on commit c72c4be

Please sign in to comment.