diff --git a/docs/vars.md b/docs/vars.md index db672a389e0..d46d789cef0 100644 --- a/docs/vars.md +++ b/docs/vars.md @@ -128,6 +128,11 @@ Stack](https://github.com/kubernetes-sigs/kubespray/blob/master/docs/dns-stack.m to match Docker configuration. * *kubelet_rotate_certificates* - Auto rotate the kubelet client certificates by requesting new certificates from the kube-apiserver when the certificate expiration approaches. +* *kubelet_rotate_server_certificates* - Auto rotate the kubelet server certificates by requesting new certificates + from the kube-apiserver when the certificate expiration approaches. + **Note** that server certificates are **not** approved automatically. Approve them manually + (`kubectl get csr`, `kubectl certificate approve`) or implement custom approving controller like + [kubelet-rubber-stamp](https://github.com/kontena/kubelet-rubber-stamp). * *node_labels* - Labels applied to nodes via kubelet --node-labels parameter. For example, labels can be set in the inventory as variables or more widely in group_vars. *node_labels* can be defined either as a dict or a comma-separated labels string: diff --git a/roles/kubernetes/master/templates/kubeadm-config.v1beta2.yaml.j2 b/roles/kubernetes/master/templates/kubeadm-config.v1beta2.yaml.j2 index e3b6a4d2767..697c2aabc69 100644 --- a/roles/kubernetes/master/templates/kubeadm-config.v1beta2.yaml.j2 +++ b/roles/kubernetes/master/templates/kubeadm-config.v1beta2.yaml.j2 @@ -195,7 +195,10 @@ apiServer: {% endif %} {% if event_ttl_duration is defined %} event-ttl: {{ event_ttl_duration }} -{%endif%} +{% endif %} +{% if kubelet_rotate_server_certificates %} + kubelet-certificate-authority: {{ kube_cert_dir }}/ca.crt +{% endif %} {% if kubernetes_audit or kube_basic_auth|default(true) or kube_token_auth|default(true) or kube_webhook_token_auth|default(false) or ( cloud_provider is defined and cloud_provider in ["openstack", "azure", "vsphere", "aws"] ) or apiserver_extra_volumes or ssl_ca_dirs|length %} extraVolumes: {% if cloud_provider is defined and cloud_provider in ["openstack", "azure", "vsphere", "aws"] %} diff --git a/roles/kubernetes/node/templates/kubelet-config.v1beta1.yaml.j2 b/roles/kubernetes/node/templates/kubelet-config.v1beta1.yaml.j2 index 50a2d06105b..7daded04830 100644 --- a/roles/kubernetes/node/templates/kubelet-config.v1beta1.yaml.j2 +++ b/roles/kubernetes/node/templates/kubelet-config.v1beta1.yaml.j2 @@ -34,6 +34,9 @@ clusterDomain: {{ dns_domain }} {% if kubelet_rotate_certificates|bool %} rotateCertificates: true {% endif %} +{% if kubelet_rotate_server_certificates|bool %} +serverTLSBootstrap: true +{% endif %} {# DNS settings for kubelet #} {% if enable_nodelocaldns %} {% set kubelet_cluster_dns = [nodelocaldns_ip] %} diff --git a/roles/kubespray-defaults/defaults/main.yaml b/roles/kubespray-defaults/defaults/main.yaml index f5b84aaf417..fe27d1ea46c 100644 --- a/roles/kubespray-defaults/defaults/main.yaml +++ b/roles/kubespray-defaults/defaults/main.yaml @@ -379,6 +379,8 @@ kubelet_authorization_mode_webhook: true # kubelet uses certificates for authenticating to the Kubernetes API # Automatically generate a new key and request a new certificate from the Kubernetes API as the current certificate approaches expiration kubelet_rotate_certificates: true +# kubelet can also request a new server certificate from the Kubernetes API +kubelet_rotate_server_certificates: false ## List of key=value pairs that describe feature gates for ## the k8s cluster.