2017-10-26 08:10:33 +00:00
|
|
|
---
|
|
|
|
- name: Kubernetes Apps | Wait for kube-apiserver
|
|
|
|
uri:
|
2017-11-06 20:01:10 +00:00
|
|
|
url: "{{ kube_apiserver_endpoint }}/healthz"
|
|
|
|
validate_certs: no
|
|
|
|
client_cert: "{{ kube_apiserver_client_cert }}"
|
|
|
|
client_key: "{{ kube_apiserver_client_key }}"
|
2017-10-26 08:10:33 +00:00
|
|
|
register: result
|
|
|
|
until: result.status == 200
|
|
|
|
retries: 10
|
|
|
|
delay: 6
|
|
|
|
when: inventory_hostname == groups['kube-master'][0]
|
|
|
|
|
|
|
|
- name: Kubernetes Apps | Add ClusterRoleBinding to admit nodes
|
|
|
|
template:
|
|
|
|
src: "node-crb.yml.j2"
|
|
|
|
dest: "{{ kube_config_dir }}/node-crb.yml"
|
|
|
|
register: node_crb_manifest
|
|
|
|
when: rbac_enabled
|
|
|
|
|
|
|
|
- name: Apply workaround to allow all nodes with cert O=system:nodes to register
|
|
|
|
kube:
|
2018-03-09 05:56:46 +00:00
|
|
|
name: "kubespray:system:node"
|
2017-10-26 08:10:33 +00:00
|
|
|
kubectl: "{{bin_dir}}/kubectl"
|
|
|
|
resource: "clusterrolebinding"
|
|
|
|
filename: "{{ kube_config_dir }}/node-crb.yml"
|
|
|
|
state: latest
|
|
|
|
when:
|
|
|
|
- rbac_enabled
|
|
|
|
- node_crb_manifest.changed
|
|
|
|
|
2018-01-21 10:34:37 +00:00
|
|
|
- name: Kubernetes Apps | Add webhook ClusterRole that grants access to proxy, stats, log, spec, and metrics on a kubelet
|
|
|
|
template:
|
|
|
|
src: "node-webhook-cr.yml.j2"
|
|
|
|
dest: "{{ kube_config_dir }}/node-webhook-cr.yml"
|
|
|
|
register: node_webhook_cr_manifest
|
|
|
|
when:
|
|
|
|
- rbac_enabled
|
|
|
|
- kubelet_authorization_mode_webhook
|
|
|
|
tags: node-webhook
|
|
|
|
|
|
|
|
- name: Apply webhook ClusterRole
|
|
|
|
kube:
|
|
|
|
name: "system:node-webhook"
|
|
|
|
kubectl: "{{bin_dir}}/kubectl"
|
|
|
|
resource: "clusterrole"
|
|
|
|
filename: "{{ kube_config_dir }}/node-webhook-cr.yml"
|
|
|
|
state: latest
|
|
|
|
when:
|
|
|
|
- rbac_enabled
|
|
|
|
- kubelet_authorization_mode_webhook
|
|
|
|
- node_webhook_cr_manifest.changed
|
|
|
|
tags: node-webhook
|
|
|
|
|
|
|
|
- name: Kubernetes Apps | Add ClusterRoleBinding for system:nodes to webhook ClusterRole
|
|
|
|
template:
|
|
|
|
src: "node-webhook-crb.yml.j2"
|
|
|
|
dest: "{{ kube_config_dir }}/node-webhook-crb.yml"
|
|
|
|
register: node_webhook_crb_manifest
|
|
|
|
when:
|
|
|
|
- rbac_enabled
|
|
|
|
- kubelet_authorization_mode_webhook
|
|
|
|
tags: node-webhook
|
|
|
|
|
|
|
|
- name: Grant system:nodes the webhook ClusterRole
|
|
|
|
kube:
|
|
|
|
name: "system:node-webhook"
|
|
|
|
kubectl: "{{bin_dir}}/kubectl"
|
|
|
|
resource: "clusterrolebinding"
|
|
|
|
filename: "{{ kube_config_dir }}/node-webhook-crb.yml"
|
|
|
|
state: latest
|
|
|
|
when:
|
|
|
|
- rbac_enabled
|
|
|
|
- kubelet_authorization_mode_webhook
|
|
|
|
- node_webhook_crb_manifest.changed
|
|
|
|
tags: node-webhook
|
|
|
|
|
2018-03-14 11:23:22 +00:00
|
|
|
- name: Check if vsphere-cloud-provider ClusterRole exists
|
|
|
|
command: "{{ bin_dir }}/kubectl get clusterroles system:vsphere-cloud-provider"
|
|
|
|
register: vsphere_cloud_provider
|
|
|
|
ignore_errors: true
|
|
|
|
when:
|
|
|
|
- rbac_enabled
|
|
|
|
- cloud_provider is defined
|
|
|
|
- cloud_provider == 'vsphere'
|
|
|
|
- kube_version | version_compare('v1.9.0', '>=')
|
|
|
|
- kube_version | version_compare('v1.9.3', '<=')
|
|
|
|
tags: vsphere
|
|
|
|
|
2018-03-12 18:07:08 +00:00
|
|
|
- name: Write vsphere-cloud-provider ClusterRole manifest
|
|
|
|
template:
|
|
|
|
src: "vsphere-rbac.yml.j2"
|
|
|
|
dest: "{{ kube_config_dir }}/vsphere-rbac.yml"
|
|
|
|
register: vsphere_rbac_manifest
|
|
|
|
when:
|
|
|
|
- rbac_enabled
|
|
|
|
- cloud_provider is defined
|
|
|
|
- cloud_provider == 'vsphere'
|
2018-03-14 11:23:22 +00:00
|
|
|
- vsphere_cloud_provider.rc != 0
|
2018-03-12 18:07:08 +00:00
|
|
|
- kube_version | version_compare('v1.9.0', '>=')
|
2018-03-14 11:23:22 +00:00
|
|
|
- kube_version | version_compare('v1.9.3', '<=')
|
2018-03-12 18:07:08 +00:00
|
|
|
tags: vsphere
|
|
|
|
|
|
|
|
- name: Apply vsphere-cloud-provider ClusterRole
|
|
|
|
kube:
|
|
|
|
name: "system:vsphere-cloud-provider"
|
|
|
|
kubectl: "{{bin_dir}}/kubectl"
|
|
|
|
resource: "clusterrolebinding"
|
|
|
|
filename: "{{ kube_config_dir }}/vsphere-rbac.yml"
|
|
|
|
state: latest
|
|
|
|
when:
|
|
|
|
- rbac_enabled
|
|
|
|
- cloud_provider is defined
|
|
|
|
- cloud_provider == 'vsphere'
|
2018-03-14 11:23:22 +00:00
|
|
|
- vsphere_cloud_provider.rc != 0
|
2018-03-12 18:07:08 +00:00
|
|
|
- kube_version | version_compare('v1.9.0', '>=')
|
2018-03-14 11:23:22 +00:00
|
|
|
- kube_version | version_compare('v1.9.3', '<=')
|
2018-03-12 18:07:08 +00:00
|
|
|
tags: vsphere
|
|
|
|
|
2017-10-26 08:10:33 +00:00
|
|
|
# This is not a cluster role, but should be run after kubeconfig is set on master
|
|
|
|
- name: Write kube system namespace manifest
|
|
|
|
template:
|
|
|
|
src: namespace.j2
|
|
|
|
dest: "{{kube_config_dir}}/{{system_namespace}}-ns.yml"
|
|
|
|
when: inventory_hostname == groups['kube-master'][0]
|
|
|
|
tags:
|
|
|
|
- apps
|
|
|
|
|
|
|
|
- name: Check if kube system namespace exists
|
|
|
|
command: "{{ bin_dir }}/kubectl get ns {{system_namespace}}"
|
|
|
|
register: 'kubesystem'
|
|
|
|
changed_when: False
|
|
|
|
failed_when: False
|
|
|
|
when: inventory_hostname == groups['kube-master'][0]
|
|
|
|
tags:
|
|
|
|
- apps
|
|
|
|
|
|
|
|
- name: Create kube system namespace
|
|
|
|
command: "{{ bin_dir }}/kubectl create -f {{kube_config_dir}}/{{system_namespace}}-ns.yml"
|
|
|
|
retries: 4
|
|
|
|
delay: "{{ retry_stagger | random + 3 }}"
|
|
|
|
register: create_system_ns
|
|
|
|
until: create_system_ns.rc == 0
|
|
|
|
changed_when: False
|
|
|
|
when: inventory_hostname == groups['kube-master'][0] and kubesystem.rc != 0
|
|
|
|
tags:
|
|
|
|
- apps
|