You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.4 KiB

  1. ---
  2. - name: Refresh certificates so they are fresh and not expired
  3. command: >-
  4. {{ bin_dir }}/kubeadm init phase
  5. --config {{ kube_config_dir }}/kubeadm-config.yaml
  6. upload-certs
  7. --upload-certs
  8. register: kubeadm_upload_cert
  9. delegate_to: "{{ groups['kube-master'][0] }}"
  10. when: kubeadm_etcd_refresh_cert_key
  11. run_once: yes
  12. - name: Parse certificate key if not set
  13. set_fact:
  14. kubeadm_certificate_key: "{{ hostvars[groups['kube-master'][0]]['kubeadm_upload_cert'].stdout_lines[-1] | trim }}"
  15. when: kubeadm_certificate_key is undefined
  16. - name: Pull control plane certs down
  17. shell: >-
  18. {{ bin_dir }}/kubeadm join phase
  19. control-plane-prepare download-certs
  20. --certificate-key {{ kubeadm_certificate_key }}
  21. --control-plane
  22. --token {{ kubeadm_token }}
  23. --discovery-token-unsafe-skip-ca-verification
  24. {{ kubeadm_discovery_address }}
  25. &&
  26. {{ bin_dir }}/kubeadm join phase
  27. control-plane-prepare certs
  28. --control-plane
  29. --token {{ kubeadm_token }}
  30. --discovery-token-unsafe-skip-ca-verification
  31. {{ kubeadm_discovery_address }}
  32. args:
  33. creates: "{{ kube_cert_dir }}/apiserver-etcd-client.key"
  34. - name: Delete unneeded certificates
  35. file:
  36. path: "{{ item }}"
  37. state: absent
  38. with_items:
  39. - "{{ kube_cert_dir }}/apiserver.crt"
  40. - "{{ kube_cert_dir }}/apiserver.key"
  41. - "{{ kube_cert_dir }}/ca.key"
  42. - "{{ kube_cert_dir }}/etcd/ca.key"
  43. - "{{ kube_cert_dir }}/etcd/healthcheck-client.crt"
  44. - "{{ kube_cert_dir }}/etcd/healthcheck-client.key"
  45. - "{{ kube_cert_dir }}/etcd/peer.crt"
  46. - "{{ kube_cert_dir }}/etcd/peer.key"
  47. - "{{ kube_cert_dir }}/etcd/server.crt"
  48. - "{{ kube_cert_dir }}/etcd/server.key"
  49. - "{{ kube_cert_dir }}/front-proxy-ca.crt"
  50. - "{{ kube_cert_dir }}/front-proxy-ca.key"
  51. - "{{ kube_cert_dir }}/front-proxy-client.crt"
  52. - "{{ kube_cert_dir }}/front-proxy-client.key"
  53. - "{{ kube_cert_dir }}/sa.key"
  54. - "{{ kube_cert_dir }}/sa.pub"
  55. - name: Calculate etcd cert serial
  56. command: "openssl x509 -in {{ kube_cert_dir }}/apiserver-etcd-client.crt -noout -serial"
  57. register: "etcd_client_cert_serial_result"
  58. changed_when: false
  59. when:
  60. - inventory_hostname in groups['k8s-cluster']|union(groups['calico-rr']|default([]))|unique|sort
  61. tags:
  62. - network
  63. - name: Set etcd_client_cert_serial
  64. set_fact:
  65. etcd_client_cert_serial: "{{ etcd_client_cert_serial_result.stdout.split('=')[1] }}"
  66. tags:
  67. - network