Skip to content

Commit

Permalink
Remove rotate_tokens logic
Browse files Browse the repository at this point in the history
kubeadm never rotates sa.key/sa.pub, so there is no need to delete tokens/restart pods

Signed-off-by: Etienne Champetier <[email protected]>
  • Loading branch information
champtar authored and k8s-ci-robot committed Mar 5, 2021
1 parent 280036f commit 8800b5c
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 109 deletions.
1 change: 0 additions & 1 deletion cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@
environment: "{{ proxy_disable_env }}"
roles:
- { role: kubespray-defaults }
- { role: kubernetes-apps/rotate_tokens, tags: rotate_tokens, when: "secret_changed|default(false)" }
- { role: win_nodes/kubernetes_patch, tags: ["master", "win_nodes"] }

- hosts: kube-master
Expand Down
14 changes: 0 additions & 14 deletions docs/upgrades.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,20 +289,6 @@ follows:
* kube-apiserver, kube-scheduler, and kube-controller-manager
* Add-ons (such as KubeDNS)

## Upgrade considerations

Kubespray supports rotating certificates used for etcd and Kubernetes
components, but some manual steps may be required. If you have a pod that
requires use of a service token and is deployed in a namespace other than
`kube-system`, you will need to manually delete the affected pods after
rotating certificates. This is because all service account tokens are dependent
on the apiserver token that is used to generate them. When the certificate
rotates, all service account tokens must be rotated as well. During the
kubernetes-apps/rotate_tokens role, only pods in kube-system are destroyed and
recreated. All other invalidated service account tokens are cleaned up
automatically, but other pods are not deleted out of an abundance of caution
for impact to user deployed pods.

### Component-based upgrades

A deployer may want to upgrade specific components in order to minimize risk
Expand Down
48 changes: 0 additions & 48 deletions roles/kubernetes-apps/rotate_tokens/tasks/main.yml

This file was deleted.

18 changes: 0 additions & 18 deletions roles/kubernetes/control-plane/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,21 +121,3 @@
until: result.status == 200
retries: 60
delay: 1

- name: Master | set secret_changed
command: /bin/true
notify:
- Master | set secret_changed to true
- Master | Copy new kubeconfig for root user

- name: Master | set secret_changed to true
set_fact:
secret_changed: true

- name: Master | Copy new kubeconfig for root user
copy:
src: "{{ kube_config_dir }}/admin.conf"
dest: "{{ ansible_env.HOME | default('/root') }}/.kube/config"
remote_src: yes
mode: "0600"
backup: yes
4 changes: 0 additions & 4 deletions roles/kubernetes/control-plane/tasks/kubeadm-secondary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,3 @@
when:
- inventory_hostname != groups['kube-master']|first
- kubeadm_already_run is not defined or not kubeadm_already_run.stat.exists

- name: Set secret_changed to false to avoid extra token rotation
set_fact:
secret_changed: false
23 changes: 0 additions & 23 deletions roles/kubernetes/control-plane/tasks/kubeadm-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@
- kube_oidc_auth
- kube_oidc_ca_cert is defined

- name: kubeadm | Check serviceaccount key
stat:
path: "{{ kube_cert_dir }}/sa.key"
get_attributes: no
get_checksum: yes
get_mime: no
register: sa_key_before
run_once: true

- name: kubeadm | Check if kubeadm has already run
stat:
path: "/var/lib/kubelet/config.yaml"
Expand Down Expand Up @@ -180,20 +171,6 @@
- upgrade_cluster_setup
- kubeadm_already_run.stat.exists

- name: kubeadm | Check serviceaccount key again
stat:
path: "{{ kube_cert_dir }}/sa.key"
get_attributes: no
get_checksum: yes
get_mime: no
register: sa_key_after
run_once: true

- name: kubeadm | Set secret_changed if service account key was updated
command: /bin/true
notify: Master | set secret_changed
when: sa_key_before.stat.checksum|default("") != sa_key_after.stat.checksum

# FIXME(mattymo): from docs: If you don't want to taint your control-plane node, set this field to an empty slice, i.e. `taints: {}` in the YAML file.
- name: kubeadm | Remove taint for master with node role
command: "{{ bin_dir }}/kubectl --kubeconfig {{ kube_config_dir }}/admin.conf taint node {{ inventory_hostname }} {{ item }}"
Expand Down
1 change: 0 additions & 1 deletion upgrade-cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@
environment: "{{ proxy_disable_env }}"
roles:
- { role: kubespray-defaults }
- { role: kubernetes-apps/rotate_tokens, tags: rotate_tokens, when: "secret_changed|default(false)" }
- { role: win_nodes/kubernetes_patch, tags: ["master", "win_nodes"] }

- hosts: calico-rr
Expand Down

0 comments on commit 8800b5c

Please sign in to comment.