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

feature: Enable configuration of Kubelet TLS certs #2536

Merged
merged 1 commit into from
Nov 3, 2022
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,8 @@ The following settings are optional and allow you to further configure your clus
ephemeral-storage= "1Gi"
```

* `settings.kubernetes.server-certificate`: The base64 encoded content of an x509 certificate for the Kubelet web server, which is used for retrieving logs and executing commands.
* `settings.kubernetes.server-key`: The base64 encoded content of an x509 private key for the Kubelet web server.
* `settings.kubernetes.topology-manager-policy`: Specifies the topology manager policy. Possible values are `none`, `restricted`, `best-effort`, and `single-numa-node`. Defaults to `none`.
* `settings.kubernetes.topology-manager-scope`: Specifies the topology manager scope. Possible values are `container` and `pod`. Defaults to `container`. If you want to group all containers in a pod to a common set of NUMA nodes, you can set this setting to `pod`.

Expand Down
2 changes: 2 additions & 0 deletions Release.toml
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,6 @@ version = "1.10.1"
"migrate_v1.11.0_aws-creds.lz4",
"migrate_v1.11.0_aws-creds-metadata.lz4",
"migrate_v1.11.0_credential-providers.lz4",
"migrate_v1.11.0_kubelet-tls-config.lz4",
"migrate_v1.11.0_kubelet-new-config-files.lz4",
]
16 changes: 16 additions & 0 deletions packages/kubernetes-1.21/etc-kubernetes-pki.mount
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Unit]
Description=Kubernetes PKI directory (/etc/kubernetes/pki)
DefaultDependencies=no
Conflicts=umount.target
Before=local-fs.target umount.target
After=selinux-policy-files.service
Wants=selinux-policy-files.service

[Mount]
What=tmpfs
Where=/etc/kubernetes/pki
Type=tmpfs
Options=nosuid,nodev,noexec,noatime,context=system_u:object_r:secret_t:s0,mode=0700

[Install]
WantedBy=preconfigured.target
5 changes: 5 additions & 0 deletions packages/kubernetes-1.21/kubelet-config
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@ featureGates:
CSIMigration: false
protectKernelDefaults: true
serializeImagePulls: false
{{#if (and (default "" settings.kubernetes.server-certificate) (default "" settings.kubernetes.server-key))}}
tlsCertFile: "/etc/kubernetes/pki/kubelet-server.crt"
tlsPrivateKeyFile: "/etc/kubernetes/pki/kubelet-server.key"
{{else}}
serverTLSBootstrap: {{settings.kubernetes.server-tls-bootstrap}}
stmcginnis marked this conversation as resolved.
Show resolved Hide resolved
{{/if}}
tlsCipherSuites:
- TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
volumePluginDir: "/var/lib/kubelet/plugins/volume/exec"
Expand Down
3 changes: 3 additions & 0 deletions packages/kubernetes-1.21/kubelet-server-crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{~#if settings.kubernetes.server-certificate~}}
{{base64_decode settings.kubernetes.server-certificate}}
{{~/if~}}
3 changes: 3 additions & 0 deletions packages/kubernetes-1.21/kubelet-server-key
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{~#if settings.kubernetes.server-key~}}
{{base64_decode settings.kubernetes.server-key}}
{{~/if~}}
10 changes: 9 additions & 1 deletion packages/kubernetes-1.21/kubernetes-1.21.spec
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ Source7: kubelet-bootstrap-kubeconfig
Source8: kubernetes-tmpfiles.conf
Source9: kubelet-sysctl.conf
Source10: prepare-var-lib-kubelet.service
Source11: kubelet-server-crt
Source12: kubelet-server-key
Source13: etc-kubernetes-pki.mount

# ExecStartPre drop-ins
Source20: prestart-pull-pause-ctr.conf
Expand Down Expand Up @@ -90,7 +93,7 @@ install -d %{buildroot}%{_cross_bindir}
install -p -m 0755 ${output}/kubelet %{buildroot}%{_cross_bindir}

install -d %{buildroot}%{_cross_unitdir}
install -p -m 0644 %{S:1} %{S:10} %{buildroot}%{_cross_unitdir}
install -p -m 0644 %{S:1} %{S:10} %{S:13} %{buildroot}%{_cross_unitdir}

install -d %{buildroot}%{_cross_unitdir}/kubelet.service.d
install -p -m 0644 %{S:20} %{S:21} %{S:22} %{buildroot}%{_cross_unitdir}/kubelet.service.d
Expand All @@ -102,6 +105,8 @@ install -m 0644 %{S:4} %{buildroot}%{_cross_templatedir}/kubelet-kubeconfig
install -m 0644 %{S:5} %{buildroot}%{_cross_templatedir}/kubernetes-ca-crt
install -m 0644 %{S:6} %{buildroot}%{_cross_templatedir}/kubelet-exec-start-conf
install -m 0644 %{S:7} %{buildroot}%{_cross_templatedir}/kubelet-bootstrap-kubeconfig
install -m 0644 %{S:11} %{buildroot}%{_cross_templatedir}/kubelet-server-crt
install -m 0644 %{S:12} %{buildroot}%{_cross_templatedir}/kubelet-server-key

install -d %{buildroot}%{_cross_tmpfilesdir}
install -p -m 0644 %{S:8} %{buildroot}%{_cross_tmpfilesdir}/kubernetes.conf
Expand All @@ -123,6 +128,7 @@ ln -rs \
%{_cross_bindir}/kubelet
%{_cross_unitdir}/kubelet.service
%{_cross_unitdir}/prepare-var-lib-kubelet.service
%{_cross_unitdir}/etc-kubernetes-pki.mount
%dir %{_cross_unitdir}/kubelet.service.d
%{_cross_unitdir}/kubelet.service.d/prestart-pull-pause-ctr.conf
%{_cross_unitdir}/kubelet.service.d/make-kubelet-dirs.conf
Expand All @@ -134,6 +140,8 @@ ln -rs \
%{_cross_templatedir}/kubelet-bootstrap-kubeconfig
%{_cross_templatedir}/kubelet-exec-start-conf
%{_cross_templatedir}/kubernetes-ca-crt
%{_cross_templatedir}/kubelet-server-crt
%{_cross_templatedir}/kubelet-server-key
%{_cross_tmpfilesdir}/kubernetes.conf
%{_cross_sysctldir}/90-kubelet.conf
%dir %{_cross_libexecdir}/kubernetes
Expand Down
16 changes: 16 additions & 0 deletions packages/kubernetes-1.22/etc-kubernetes-pki.mount
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Unit]
Description=Kubernetes PKI directory (/etc/kubernetes/pki)
DefaultDependencies=no
Conflicts=umount.target
Before=local-fs.target umount.target
After=selinux-policy-files.service
Wants=selinux-policy-files.service

[Mount]
What=tmpfs
Where=/etc/kubernetes/pki
Type=tmpfs
Options=nosuid,nodev,noexec,noatime,context=system_u:object_r:secret_t:s0,mode=0700

[Install]
WantedBy=preconfigured.target
5 changes: 5 additions & 0 deletions packages/kubernetes-1.22/kubelet-config
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,12 @@ featureGates:
CSIMigration: false
protectKernelDefaults: true
serializeImagePulls: false
{{#if (and (default "" settings.kubernetes.server-certificate) (default "" settings.kubernetes.server-key))}}
tlsCertFile: "/etc/kubernetes/pki/kubelet-server.crt"
tlsPrivateKeyFile: "/etc/kubernetes/pki/kubelet-server.key"
{{else}}
serverTLSBootstrap: {{settings.kubernetes.server-tls-bootstrap}}
{{/if}}
tlsCipherSuites:
- TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
volumePluginDir: "/var/lib/kubelet/plugins/volume/exec"
Expand Down
3 changes: 3 additions & 0 deletions packages/kubernetes-1.22/kubelet-server-crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{~#if settings.kubernetes.server-certificate~}}
{{base64_decode settings.kubernetes.server-certificate}}
{{~/if~}}
3 changes: 3 additions & 0 deletions packages/kubernetes-1.22/kubelet-server-key
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{~#if settings.kubernetes.server-key~}}
{{base64_decode settings.kubernetes.server-key}}
{{~/if~}}
10 changes: 9 additions & 1 deletion packages/kubernetes-1.22/kubernetes-1.22.spec
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ Source7: kubelet-bootstrap-kubeconfig
Source8: kubernetes-tmpfiles.conf
Source9: kubelet-sysctl.conf
Source10: prepare-var-lib-kubelet.service
Source11: kubelet-server-crt
Source12: kubelet-server-key
Source13: etc-kubernetes-pki.mount

# ExecStartPre drop-ins
Source20: prestart-pull-pause-ctr.conf
Expand Down Expand Up @@ -87,7 +90,7 @@ install -d %{buildroot}%{_cross_bindir}
install -p -m 0755 ${output}/kubelet %{buildroot}%{_cross_bindir}

install -d %{buildroot}%{_cross_unitdir}
install -p -m 0644 %{S:1} %{S:10} %{buildroot}%{_cross_unitdir}
install -p -m 0644 %{S:1} %{S:10} %{S:13} %{buildroot}%{_cross_unitdir}

install -d %{buildroot}%{_cross_unitdir}/kubelet.service.d
install -p -m 0644 %{S:20} %{S:21} %{S:22} %{buildroot}%{_cross_unitdir}/kubelet.service.d
Expand All @@ -99,6 +102,8 @@ install -m 0644 %{S:4} %{buildroot}%{_cross_templatedir}/kubelet-kubeconfig
install -m 0644 %{S:5} %{buildroot}%{_cross_templatedir}/kubernetes-ca-crt
install -m 0644 %{S:6} %{buildroot}%{_cross_templatedir}/kubelet-exec-start-conf
install -m 0644 %{S:7} %{buildroot}%{_cross_templatedir}/kubelet-bootstrap-kubeconfig
install -m 0644 %{S:11} %{buildroot}%{_cross_templatedir}/kubelet-server-crt
install -m 0644 %{S:12} %{buildroot}%{_cross_templatedir}/kubelet-server-key

install -d %{buildroot}%{_cross_tmpfilesdir}
install -p -m 0644 %{S:8} %{buildroot}%{_cross_tmpfilesdir}/kubernetes.conf
Expand All @@ -120,6 +125,7 @@ ln -rs \
%{_cross_bindir}/kubelet
%{_cross_unitdir}/kubelet.service
%{_cross_unitdir}/prepare-var-lib-kubelet.service
%{_cross_unitdir}/etc-kubernetes-pki.mount
%dir %{_cross_unitdir}/kubelet.service.d
%{_cross_unitdir}/kubelet.service.d/prestart-pull-pause-ctr.conf
%{_cross_unitdir}/kubelet.service.d/make-kubelet-dirs.conf
Expand All @@ -131,6 +137,8 @@ ln -rs \
%{_cross_templatedir}/kubelet-bootstrap-kubeconfig
%{_cross_templatedir}/kubelet-exec-start-conf
%{_cross_templatedir}/kubernetes-ca-crt
%{_cross_templatedir}/kubelet-server-crt
%{_cross_templatedir}/kubelet-server-key
%{_cross_tmpfilesdir}/kubernetes.conf
%{_cross_sysctldir}/90-kubelet.conf
%dir %{_cross_libexecdir}/kubernetes
Expand Down
16 changes: 16 additions & 0 deletions packages/kubernetes-1.23/etc-kubernetes-pki.mount
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Unit]
Description=Kubernetes PKI directory (/etc/kubernetes/pki)
DefaultDependencies=no
Conflicts=umount.target
Before=local-fs.target umount.target
After=selinux-policy-files.service
Wants=selinux-policy-files.service

[Mount]
What=tmpfs
Where=/etc/kubernetes/pki
Type=tmpfs
Options=nosuid,nodev,noexec,noatime,context=system_u:object_r:secret_t:s0,mode=0700

[Install]
WantedBy=preconfigured.target
5 changes: 5 additions & 0 deletions packages/kubernetes-1.23/kubelet-config
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,12 @@ featureGates:
CSIMigrationvSphere: true
protectKernelDefaults: true
serializeImagePulls: false
{{#if (and (default "" settings.kubernetes.server-certificate) (default "" settings.kubernetes.server-key))}}
tlsCertFile: "/etc/kubernetes/pki/kubelet-server.crt"
tlsPrivateKeyFile: "/etc/kubernetes/pki/kubelet-server.key"
{{else}}
serverTLSBootstrap: {{settings.kubernetes.server-tls-bootstrap}}
{{/if}}
tlsCipherSuites:
- TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
volumePluginDir: "/var/lib/kubelet/plugins/volume/exec"
Expand Down
3 changes: 3 additions & 0 deletions packages/kubernetes-1.23/kubelet-server-crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{~#if settings.kubernetes.server-certificate~}}
{{base64_decode settings.kubernetes.server-certificate}}
{{~/if~}}
3 changes: 3 additions & 0 deletions packages/kubernetes-1.23/kubelet-server-key
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{~#if settings.kubernetes.server-key~}}
{{base64_decode settings.kubernetes.server-key}}
{{~/if~}}
10 changes: 9 additions & 1 deletion packages/kubernetes-1.23/kubernetes-1.23.spec
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ Source7: kubelet-bootstrap-kubeconfig
Source8: kubernetes-tmpfiles.conf
Source9: kubelet-sysctl.conf
Source10: prepare-var-lib-kubelet.service
Source11: kubelet-server-crt
Source12: kubelet-server-key
Source13: etc-kubernetes-pki.mount

# ExecStartPre drop-ins
Source20: prestart-pull-pause-ctr.conf
Expand Down Expand Up @@ -88,7 +91,7 @@ install -d %{buildroot}%{_cross_bindir}
install -p -m 0755 ${output}/kubelet %{buildroot}%{_cross_bindir}

install -d %{buildroot}%{_cross_unitdir}
install -p -m 0644 %{S:1} %{S:10} %{buildroot}%{_cross_unitdir}
install -p -m 0644 %{S:1} %{S:10} %{S:13} %{buildroot}%{_cross_unitdir}

install -d %{buildroot}%{_cross_unitdir}/kubelet.service.d
install -p -m 0644 %{S:20} %{S:21} %{S:22} %{S:23} %{buildroot}%{_cross_unitdir}/kubelet.service.d
Expand All @@ -100,6 +103,8 @@ install -m 0644 %{S:4} %{buildroot}%{_cross_templatedir}/kubelet-kubeconfig
install -m 0644 %{S:5} %{buildroot}%{_cross_templatedir}/kubernetes-ca-crt
install -m 0644 %{S:6} %{buildroot}%{_cross_templatedir}/kubelet-exec-start-conf
install -m 0644 %{S:7} %{buildroot}%{_cross_templatedir}/kubelet-bootstrap-kubeconfig
install -m 0644 %{S:11} %{buildroot}%{_cross_templatedir}/kubelet-server-crt
install -m 0644 %{S:12} %{buildroot}%{_cross_templatedir}/kubelet-server-key

install -d %{buildroot}%{_cross_tmpfilesdir}
install -p -m 0644 %{S:8} %{buildroot}%{_cross_tmpfilesdir}/kubernetes.conf
Expand All @@ -121,6 +126,7 @@ ln -rs \
%{_cross_bindir}/kubelet
%{_cross_unitdir}/kubelet.service
%{_cross_unitdir}/prepare-var-lib-kubelet.service
%{_cross_unitdir}/etc-kubernetes-pki.mount
%dir %{_cross_unitdir}/kubelet.service.d
%{_cross_unitdir}/kubelet.service.d/prestart-pull-pause-ctr.conf
%{_cross_unitdir}/kubelet.service.d/make-kubelet-dirs.conf
Expand All @@ -133,6 +139,8 @@ ln -rs \
%{_cross_templatedir}/kubelet-bootstrap-kubeconfig
%{_cross_templatedir}/kubelet-exec-start-conf
%{_cross_templatedir}/kubernetes-ca-crt
%{_cross_templatedir}/kubelet-server-crt
%{_cross_templatedir}/kubelet-server-key
%{_cross_tmpfilesdir}/kubernetes.conf
%{_cross_sysctldir}/90-kubelet.conf
%dir %{_cross_libexecdir}/kubernetes
Expand Down
16 changes: 16 additions & 0 deletions packages/kubernetes-1.24/etc-kubernetes-pki.mount
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Unit]
Description=Kubernetes PKI directory (/etc/kubernetes/pki)
DefaultDependencies=no
Conflicts=umount.target
Before=local-fs.target umount.target
After=selinux-policy-files.service
Wants=selinux-policy-files.service

[Mount]
What=tmpfs
Where=/etc/kubernetes/pki
Type=tmpfs
Options=nosuid,nodev,noexec,noatime,context=system_u:object_r:secret_t:s0,mode=0700

[Install]
WantedBy=preconfigured.target
5 changes: 5 additions & 0 deletions packages/kubernetes-1.24/kubelet-config
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,12 @@ featureGates:
CSIMigrationvSphere: true
protectKernelDefaults: true
serializeImagePulls: false
{{#if (and (default "" settings.kubernetes.server-certificate) (default "" settings.kubernetes.server-key))}}
tlsCertFile: "/etc/kubernetes/pki/kubelet-server.crt"
tlsPrivateKeyFile: "/etc/kubernetes/pki/kubelet-server.key"
{{else}}
serverTLSBootstrap: {{settings.kubernetes.server-tls-bootstrap}}
{{/if}}
tlsCipherSuites:
- TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
volumePluginDir: "/var/lib/kubelet/plugins/volume/exec"
Expand Down
3 changes: 3 additions & 0 deletions packages/kubernetes-1.24/kubelet-server-crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{~#if settings.kubernetes.server-certificate~}}
{{base64_decode settings.kubernetes.server-certificate}}
{{~/if~}}
3 changes: 3 additions & 0 deletions packages/kubernetes-1.24/kubelet-server-key
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{~#if settings.kubernetes.server-key~}}
{{base64_decode settings.kubernetes.server-key}}
{{~/if~}}
10 changes: 9 additions & 1 deletion packages/kubernetes-1.24/kubernetes-1.24.spec
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ Source7: kubelet-bootstrap-kubeconfig
Source8: kubernetes-tmpfiles.conf
Source9: kubelet-sysctl.conf
Source10: prepare-var-lib-kubelet.service
Source11: kubelet-server-crt
Source12: kubelet-server-key
Source13: etc-kubernetes-pki.mount

# ExecStartPre drop-ins
Source20: prestart-pull-pause-ctr.conf
Expand Down Expand Up @@ -96,7 +99,7 @@ install -d %{buildroot}%{_cross_bindir}
install -p -m 0755 ${output}/kubelet %{buildroot}%{_cross_bindir}

install -d %{buildroot}%{_cross_unitdir}
install -p -m 0644 %{S:1} %{S:10} %{buildroot}%{_cross_unitdir}
install -p -m 0644 %{S:1} %{S:10} %{S:13} %{buildroot}%{_cross_unitdir}

install -d %{buildroot}%{_cross_unitdir}/kubelet.service.d
install -p -m 0644 %{S:20} %{S:21} %{S:22} %{S:23} %{buildroot}%{_cross_unitdir}/kubelet.service.d
Expand All @@ -108,6 +111,8 @@ install -m 0644 %{S:4} %{buildroot}%{_cross_templatedir}/kubelet-kubeconfig
install -m 0644 %{S:5} %{buildroot}%{_cross_templatedir}/kubernetes-ca-crt
install -m 0644 %{S:6} %{buildroot}%{_cross_templatedir}/kubelet-exec-start-conf
install -m 0644 %{S:7} %{buildroot}%{_cross_templatedir}/kubelet-bootstrap-kubeconfig
install -m 0644 %{S:11} %{buildroot}%{_cross_templatedir}/kubelet-server-crt
install -m 0644 %{S:12} %{buildroot}%{_cross_templatedir}/kubelet-server-key

install -d %{buildroot}%{_cross_tmpfilesdir}
install -p -m 0644 %{S:8} %{buildroot}%{_cross_tmpfilesdir}/kubernetes.conf
Expand All @@ -129,6 +134,7 @@ ln -rs \
%{_cross_bindir}/kubelet
%{_cross_unitdir}/kubelet.service
%{_cross_unitdir}/prepare-var-lib-kubelet.service
%{_cross_unitdir}/etc-kubernetes-pki.mount
%dir %{_cross_unitdir}/kubelet.service.d
%{_cross_unitdir}/kubelet.service.d/prestart-pull-pause-ctr.conf
%{_cross_unitdir}/kubelet.service.d/make-kubelet-dirs.conf
Expand All @@ -141,6 +147,8 @@ ln -rs \
%{_cross_templatedir}/kubelet-bootstrap-kubeconfig
%{_cross_templatedir}/kubelet-exec-start-conf
%{_cross_templatedir}/kubernetes-ca-crt
%{_cross_templatedir}/kubelet-server-crt
%{_cross_templatedir}/kubelet-server-key
%{_cross_tmpfilesdir}/kubernetes.conf
%{_cross_sysctldir}/90-kubelet.conf
%dir %{_cross_libexecdir}/kubernetes
Expand Down
14 changes: 14 additions & 0 deletions sources/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions sources/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ members = [
"api/migration/migrations/v1.11.0/aws-creds-metadata",
"api/migration/migrations/v1.11.0/aws-config-settings",
"api/migration/migrations/v1.11.0/credential-providers",
"api/migration/migrations/v1.11.0/kubelet-tls-config",
"api/migration/migrations/v1.11.0/kubelet-new-config-files",

"bottlerocket-release",

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "kubelet-new-config-files"
version = "0.1.0"
edition = "2018"
authors = ["Sean McGinnis <stmcg@amazon.com>"]
license = "Apache-2.0 OR MIT"
publish = false
# Don't rebuild crate just because of changes to README.
exclude = ["README.md"]

[dependencies]
migration-helpers = { path = "../../../migration-helpers", version = "0.1.0" }
Loading