2017-02-08 21:41:36 +00:00
|
|
|
---
|
2018-01-29 11:37:48 +00:00
|
|
|
- import_tasks: sync_kube_master_certs.yml
|
2017-04-12 10:37:50 +00:00
|
|
|
when: inventory_hostname in groups['kube-master']
|
|
|
|
|
2018-01-29 11:37:48 +00:00
|
|
|
- import_tasks: sync_kube_node_certs.yml
|
2017-04-12 10:37:50 +00:00
|
|
|
when: inventory_hostname in groups['k8s-cluster']
|
2017-02-08 21:41:36 +00:00
|
|
|
|
2017-09-01 19:51:37 +00:00
|
|
|
# Issue admin certs to kube-master hosts
|
2018-01-29 11:37:48 +00:00
|
|
|
- include_tasks: ../../../vault/tasks/shared/issue_cert.yml
|
2017-02-08 21:41:36 +00:00
|
|
|
vars:
|
2017-09-05 11:40:26 +00:00
|
|
|
issue_cert_common_name: "admin"
|
2017-09-01 19:51:37 +00:00
|
|
|
issue_cert_copy_ca: "{{ item == kube_admin_certs_needed|first }}"
|
2017-02-08 21:41:36 +00:00
|
|
|
issue_cert_file_group: "{{ kube_cert_group }}"
|
|
|
|
issue_cert_file_owner: kube
|
|
|
|
issue_cert_hosts: "{{ groups['kube-master'] }}"
|
|
|
|
issue_cert_path: "{{ item }}"
|
2017-09-01 19:51:37 +00:00
|
|
|
issue_cert_role: kube-master
|
2017-02-08 21:41:36 +00:00
|
|
|
issue_cert_url: "{{ hostvars[groups.vault|first]['vault_leader_url'] }}"
|
2017-08-30 13:03:22 +00:00
|
|
|
issue_cert_mount_path: "{{ kube_vault_mount_path }}"
|
2017-09-01 19:51:37 +00:00
|
|
|
with_items: "{{ kube_admin_certs_needed|d([]) }}"
|
2017-02-08 21:41:36 +00:00
|
|
|
when: inventory_hostname in groups['kube-master']
|
|
|
|
|
2017-08-30 13:03:22 +00:00
|
|
|
- name: gen_certs_vault | Set fact about certificate alt names
|
|
|
|
set_fact:
|
|
|
|
kube_cert_alt_names: >-
|
|
|
|
{{
|
|
|
|
groups['kube-master'] +
|
|
|
|
['kubernetes.default.svc.cluster.local', 'kubernetes.default.svc', 'kubernetes.default', 'kubernetes'] +
|
|
|
|
['localhost']
|
|
|
|
}}
|
|
|
|
run_once: true
|
|
|
|
|
|
|
|
- name: gen_certs_vault | Add external load balancer domain name to certificate alt names
|
|
|
|
set_fact:
|
|
|
|
kube_cert_alt_names: "{{ kube_cert_alt_names + [apiserver_loadbalancer_domain_name] }}"
|
2017-11-23 16:15:48 +00:00
|
|
|
when: loadbalancer_apiserver is defined
|
2017-08-30 13:03:22 +00:00
|
|
|
run_once: true
|
|
|
|
|
2017-09-01 19:51:37 +00:00
|
|
|
# Issue master components certs to kube-master hosts
|
2018-01-29 11:37:48 +00:00
|
|
|
- include_tasks: ../../../vault/tasks/shared/issue_cert.yml
|
2017-02-08 21:41:36 +00:00
|
|
|
vars:
|
2017-09-01 19:51:37 +00:00
|
|
|
issue_cert_common_name: "kubernetes"
|
2017-08-30 13:03:22 +00:00
|
|
|
issue_cert_alt_names: "{{ kube_cert_alt_names }}"
|
2017-02-08 21:41:36 +00:00
|
|
|
issue_cert_file_group: "{{ kube_cert_group }}"
|
|
|
|
issue_cert_file_owner: kube
|
|
|
|
issue_cert_hosts: "{{ groups['kube-master'] }}"
|
|
|
|
issue_cert_ip_sans: >-
|
|
|
|
[
|
|
|
|
{%- for host in groups['kube-master'] -%}
|
|
|
|
"{{ hostvars[host]['ansible_default_ipv4']['address'] }}",
|
2017-08-20 10:53:58 +00:00
|
|
|
{%- if hostvars[host]['ip'] is defined -%}
|
|
|
|
"{{ hostvars[host]['ip'] }}",
|
|
|
|
{%- endif -%}
|
2017-02-08 21:41:36 +00:00
|
|
|
{%- endfor -%}
|
|
|
|
"127.0.0.1","::1","{{ kube_apiserver_ip }}"
|
|
|
|
]
|
|
|
|
issue_cert_path: "{{ item }}"
|
2017-09-01 19:51:37 +00:00
|
|
|
issue_cert_role: kube-master
|
2017-02-08 21:41:36 +00:00
|
|
|
issue_cert_url: "{{ hostvars[groups.vault|first]['vault_leader_url'] }}"
|
2017-08-30 13:03:22 +00:00
|
|
|
issue_cert_mount_path: "{{ kube_vault_mount_path }}"
|
2017-08-20 10:53:58 +00:00
|
|
|
with_items: "{{ kube_master_components_certs_needed|d([]) }}"
|
2017-02-08 21:41:36 +00:00
|
|
|
when: inventory_hostname in groups['kube-master']
|
2017-08-30 13:03:22 +00:00
|
|
|
notify: set secret_changed
|
2017-02-08 21:41:36 +00:00
|
|
|
|
|
|
|
# Issue node certs to k8s-cluster nodes
|
2018-01-29 11:37:48 +00:00
|
|
|
- include_tasks: ../../../vault/tasks/shared/issue_cert.yml
|
2017-02-08 21:41:36 +00:00
|
|
|
vars:
|
2017-09-06 07:55:08 +00:00
|
|
|
# Need to strip out the 'node-' prefix from the cert name so it can be used
|
|
|
|
# with the node authorization plugin ( CN matches kubelet node name )
|
|
|
|
issue_cert_common_name: "system:node:{{ item.rsplit('/', 1)[1].rsplit('.', 1)[0] | regex_replace('^node-', '') }}"
|
2017-02-08 21:41:36 +00:00
|
|
|
issue_cert_copy_ca: "{{ item == kube_node_certs_needed|first }}"
|
|
|
|
issue_cert_file_group: "{{ kube_cert_group }}"
|
|
|
|
issue_cert_file_owner: kube
|
|
|
|
issue_cert_hosts: "{{ groups['k8s-cluster'] }}"
|
|
|
|
issue_cert_path: "{{ item }}"
|
2017-09-01 19:51:37 +00:00
|
|
|
issue_cert_role: kube-node
|
2017-02-08 21:41:36 +00:00
|
|
|
issue_cert_url: "{{ hostvars[groups.vault|first]['vault_leader_url'] }}"
|
2017-08-30 13:03:22 +00:00
|
|
|
issue_cert_mount_path: "{{ kube_vault_mount_path }}"
|
2017-02-08 21:41:36 +00:00
|
|
|
with_items: "{{ kube_node_certs_needed|d([]) }}"
|
|
|
|
when: inventory_hostname in groups['k8s-cluster']
|
2017-08-20 10:53:58 +00:00
|
|
|
|
2017-09-01 19:51:37 +00:00
|
|
|
# Issue proxy certs to k8s-cluster nodes
|
2018-01-29 11:37:48 +00:00
|
|
|
- include_tasks: ../../../vault/tasks/shared/issue_cert.yml
|
2017-08-20 10:53:58 +00:00
|
|
|
vars:
|
2017-09-05 11:40:26 +00:00
|
|
|
issue_cert_common_name: "system:kube-proxy"
|
2017-08-20 10:53:58 +00:00
|
|
|
issue_cert_copy_ca: "{{ item == kube_proxy_certs_needed|first }}"
|
|
|
|
issue_cert_file_group: "{{ kube_cert_group }}"
|
|
|
|
issue_cert_file_owner: kube
|
|
|
|
issue_cert_hosts: "{{ groups['k8s-cluster'] }}"
|
|
|
|
issue_cert_path: "{{ item }}"
|
2017-09-01 19:51:37 +00:00
|
|
|
issue_cert_role: kube-proxy
|
2017-08-20 10:53:58 +00:00
|
|
|
issue_cert_url: "{{ hostvars[groups.vault|first]['vault_leader_url'] }}"
|
2017-08-30 13:03:22 +00:00
|
|
|
issue_cert_mount_path: "{{ kube_vault_mount_path }}"
|
2017-08-20 10:53:58 +00:00
|
|
|
with_items: "{{ kube_proxy_certs_needed|d([]) }}"
|
|
|
|
when: inventory_hostname in groups['k8s-cluster']
|
2018-02-07 10:03:07 +00:00
|
|
|
|
|
|
|
# Issue front proxy cert to kube-master hosts
|
|
|
|
- include_tasks: ../../../vault/tasks/shared/issue_cert.yml
|
|
|
|
vars:
|
|
|
|
issue_cert_common_name: "front-proxy-client"
|
2018-04-05 19:32:12 +00:00
|
|
|
issue_cert_copy_ca: "{{ item == kube_front_proxy_clients_certs_needed|first }}"
|
|
|
|
issue_cert_ca_filename: front-proxy-ca.pem
|
2018-02-07 10:03:07 +00:00
|
|
|
issue_cert_alt_names: "{{ kube_cert_alt_names }}"
|
|
|
|
issue_cert_file_group: "{{ kube_cert_group }}"
|
|
|
|
issue_cert_file_owner: kube
|
|
|
|
issue_cert_hosts: "{{ groups['kube-master'] }}"
|
|
|
|
issue_cert_ip_sans: >-
|
|
|
|
[
|
|
|
|
{%- for host in groups['kube-master'] -%}
|
|
|
|
"{{ hostvars[host]['ansible_default_ipv4']['address'] }}",
|
|
|
|
{%- if hostvars[host]['ip'] is defined -%}
|
|
|
|
"{{ hostvars[host]['ip'] }}",
|
|
|
|
{%- endif -%}
|
|
|
|
{%- endfor -%}
|
|
|
|
"127.0.0.1","::1","{{ kube_apiserver_ip }}"
|
|
|
|
]
|
|
|
|
issue_cert_path: "{{ item }}"
|
|
|
|
issue_cert_role: front-proxy-client
|
|
|
|
issue_cert_url: "{{ hostvars[groups.vault|first]['vault_leader_url'] }}"
|
2018-04-05 19:32:12 +00:00
|
|
|
issue_cert_mount_path: "{{ front_proxy_vault_mount_path }}"
|
2018-02-22 12:08:50 +00:00
|
|
|
with_items: "{{ kube_front_proxy_clients_certs_needed|d([]) }}"
|
2018-02-07 10:03:07 +00:00
|
|
|
when: inventory_hostname in groups['kube-master']
|
|
|
|
notify: set secret_changed
|