40857b9859
* Move proxy_env to kubespray-defaults/defaults There is no reasons to use set_facts here Signed-off-by: Etienne Champetier <e.champetier@ateme.com> * Ensure kubeadm doesn't use proxy *_proxy variables might be present in the environment (/etc/environment, bash profile, ...) When this is the case we end up with those proxy configuration in /etc/kubernetes/manifests/kube-*.yaml manifests We cannot unset env variables, but kubeadm is nice enough to ignore empty vars93d288e2a4/cmd/kubeadm/app/util/env.go (L27)
Signed-off-by: Etienne Champetier <e.champetier@ateme.com> (cherry picked from commit1c5391dda7
)
62 lines
2.1 KiB
YAML
62 lines
2.1 KiB
YAML
---
|
|
- name: Parse certificate key if not set
|
|
set_fact:
|
|
kubeadm_certificate_key: "{{ hostvars[groups['kube-master'][0]]['kubeadm_certificate_key'] }}"
|
|
when: kubeadm_certificate_key is undefined
|
|
|
|
- name: Pull control plane certs down
|
|
shell: >-
|
|
{{ bin_dir }}/kubeadm join phase
|
|
control-plane-prepare download-certs
|
|
--certificate-key {{ kubeadm_certificate_key }}
|
|
--control-plane
|
|
--token {{ kubeadm_token }}
|
|
--discovery-token-unsafe-skip-ca-verification
|
|
{{ kubeadm_discovery_address }}
|
|
&&
|
|
{{ bin_dir }}/kubeadm join phase
|
|
control-plane-prepare certs
|
|
--control-plane
|
|
--token {{ kubeadm_token }}
|
|
--discovery-token-unsafe-skip-ca-verification
|
|
{{ kubeadm_discovery_address }}
|
|
args:
|
|
creates: "{{ kube_cert_dir }}/apiserver-etcd-client.key"
|
|
environment: "{{ proxy_disable_env }}"
|
|
|
|
- name: Delete unneeded certificates
|
|
file:
|
|
path: "{{ item }}"
|
|
state: absent
|
|
with_items:
|
|
- "{{ kube_cert_dir }}/apiserver.crt"
|
|
- "{{ kube_cert_dir }}/apiserver.key"
|
|
- "{{ kube_cert_dir }}/ca.key"
|
|
- "{{ kube_cert_dir }}/etcd/ca.key"
|
|
- "{{ kube_cert_dir }}/etcd/healthcheck-client.crt"
|
|
- "{{ kube_cert_dir }}/etcd/healthcheck-client.key"
|
|
- "{{ kube_cert_dir }}/etcd/peer.crt"
|
|
- "{{ kube_cert_dir }}/etcd/peer.key"
|
|
- "{{ kube_cert_dir }}/etcd/server.crt"
|
|
- "{{ kube_cert_dir }}/etcd/server.key"
|
|
- "{{ kube_cert_dir }}/front-proxy-ca.crt"
|
|
- "{{ kube_cert_dir }}/front-proxy-ca.key"
|
|
- "{{ kube_cert_dir }}/front-proxy-client.crt"
|
|
- "{{ kube_cert_dir }}/front-proxy-client.key"
|
|
- "{{ kube_cert_dir }}/sa.key"
|
|
- "{{ kube_cert_dir }}/sa.pub"
|
|
|
|
- name: Calculate etcd cert serial
|
|
command: "openssl x509 -in {{ kube_cert_dir }}/apiserver-etcd-client.crt -noout -serial"
|
|
register: "etcd_client_cert_serial_result"
|
|
changed_when: false
|
|
when:
|
|
- inventory_hostname in groups['k8s-cluster']|union(groups['calico-rr']|default([]))|unique|sort
|
|
tags:
|
|
- network
|
|
|
|
- name: Set etcd_client_cert_serial
|
|
set_fact:
|
|
etcd_client_cert_serial: "{{ etcd_client_cert_serial_result.stdout.split('=')[1] }}"
|
|
tags:
|
|
- network
|