Last active
October 15, 2024 13:09
-
-
Save tomconte/25f7db5b419c24db8bc6cac2fa4c2a13 to your computer and use it in GitHub Desktop.
This is a Kubernetes DaemonSet definition that will install a custom certificate on the nodes and restart containerd. This is useful if your private registry is protected using a self-signed certificate. Not tested in production.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: trusted-ca | |
namespace: kube-system | |
data: | |
ca.crt: |+ | |
-----BEGIN CERTIFICATE----- | |
MIIFkTCCA3mgAwIBAgIUCXaMcLg8teiGZ7o0dIQRIOdHEA8wDQYJKoZIhvcNAQEL | |
BQAweDELMAkGA1UEBhMCRlIxDDAKBgNVBAgMA04vQTEMMAoGA1UEBwwDTi9BMSAw | |
HgYDVQQKDBdTZWxmLXNpZ25lZCBjZXJ0aWZpY2F0ZTErMCkGA1UEAwwiMTIwLjAu | |
MC4xOiBTZWxmLXNpZ25lZCBjZXJ0aWZpY2F0ZTAeFw0yMTAzMjIxMjI3MzNaFw0y | |
MjAzMjIxMjI3MzNaMHgxCzAJBgNVBAYTAkZSMQwwCgYDVQQIDANOL0ExDDAKBgNV | |
BAcMA04vQTEgMB4GA1UECgwXU2VsZi1zaWduZWQgY2VydGlmaWNhdGUxKzApBgNV | |
BAMMIjEyMC4wLjAuMTogU2VsZi1zaWduZWQgY2VydGlmaWNhdGUwggIiMA0GCSqG | |
SIb3DQEBAQUAA4ICDwAwggIKAoICAQDBq3taUTimeeLuxo5ghdeKWOdt5wB7dv/y | |
U6Hqet0+iaQp2SlE/5cCz1QuCNmjwOcu4mr1mRSC8mShCUrk2p08y1CzFWmyXyNF | |
woNAHI+jhWQjJz6FqyJHu6tPDSWS/VHQQQlo/VhKdimsTfjQTA1vju4PIh+IUmrI | |
Db25I8B2N4dshJsTAS9ORYmYMf6w64NEM6ahIM/krhwuHpCvijEk4cvJbaS1oagD | |
Vr+Kkad9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1Kt1mfTC | |
DvgtkOY2XRLtyHz9wqFdFbSY7fTRgPisXWwUr59tE2uXk4ZBQL5A7GISRq8Pr5hL | |
0qXh9DZKU/FNODy6fdDA12wmPZmhI5iUw+QOwbFXV7AYP9qR628K/BKLWYrdIp0V | |
YhP+zDNbfKxXMI1sROOwM9E7L5rABqCP3Jkm5fJq0ewxDswZsQ== | |
-----END CERTIFICATE----- | |
--- | |
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: setup-script | |
namespace: kube-system | |
data: | |
setup.sh: | | |
echo "$TRUSTED_CERT" > /usr/local/share/ca-certificates/ca.crt && update-ca-certificates && systemctl restart containerd | |
--- | |
apiVersion: apps/v1 | |
kind: DaemonSet | |
metadata: | |
namespace: kube-system | |
name: node-custom-setup | |
labels: | |
k8s-app: node-custom-setup | |
spec: | |
selector: | |
matchLabels: | |
k8s-app: node-custom-setup | |
template: | |
metadata: | |
labels: | |
k8s-app: node-custom-setup | |
spec: | |
hostPID: true | |
hostNetwork: true | |
initContainers: | |
- name: init-node | |
command: ["nsenter"] | |
args: ["--mount=/proc/1/ns/mnt", "--", "sh", "-c", "$(SETUP_SCRIPT)"] | |
image: debian | |
env: | |
- name: TRUSTED_CERT | |
valueFrom: | |
configMapKeyRef: | |
name: trusted-ca | |
key: ca.crt | |
- name: SETUP_SCRIPT | |
valueFrom: | |
configMapKeyRef: | |
name: setup-script | |
key: setup.sh | |
securityContext: | |
privileged: true | |
containers: | |
- name: wait | |
image: k8s.gcr.io/pause:3.1 | |
Can you tell me how to install a self-signed certificate on windows node? I think the above script works for linux nodes.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for this. That's awesome.
According to this docs and this blog
We can pull images from a specific registry without restarting containerd.
I hope
reload
capability of containerd is out very soon.