2018-09-29 09:06:19 +08:00
|
|
|
# [optional] to synchronize time of nodes with 'chrony'
|
2019-06-23 07:36:51 +08:00
|
|
|
- hosts:
|
2021-01-19 17:41:00 +08:00
|
|
|
- kube_master
|
|
|
|
- kube_node
|
2019-06-23 07:36:51 +08:00
|
|
|
- etcd
|
2021-01-19 17:41:00 +08:00
|
|
|
- ex_lb
|
2019-06-23 07:36:51 +08:00
|
|
|
- chrony
|
2018-08-17 09:18:55 +08:00
|
|
|
roles:
|
2021-01-19 23:35:31 +08:00
|
|
|
- { role: os-harden, when: "OS_HARDEN|bool" }
|
2019-05-29 20:45:25 +08:00
|
|
|
- { role: chrony, when: "groups['chrony']|length > 0" }
|
2018-08-17 09:18:55 +08:00
|
|
|
|
2019-05-29 20:45:25 +08:00
|
|
|
# to create CA, kubeconfig, kube-proxy.kubeconfig etc.
|
|
|
|
- hosts: localhost
|
2017-11-11 19:14:21 +08:00
|
|
|
roles:
|
2017-12-08 17:43:51 +08:00
|
|
|
- deploy
|
2017-11-11 19:14:21 +08:00
|
|
|
|
2018-09-29 09:06:19 +08:00
|
|
|
# prepare tasks for all nodes
|
2017-11-21 11:27:06 +08:00
|
|
|
- hosts:
|
2021-01-19 17:41:00 +08:00
|
|
|
- kube_master
|
|
|
|
- kube_node
|
2017-11-21 11:27:06 +08:00
|
|
|
- etcd
|
2017-11-11 19:14:21 +08:00
|
|
|
roles:
|
2017-11-12 14:54:20 +08:00
|
|
|
- prepare
|
2017-11-11 19:14:21 +08:00
|
|
|
|
2018-09-29 09:06:19 +08:00
|
|
|
# to install etcd cluster
|
2017-11-12 14:54:20 +08:00
|
|
|
- hosts: etcd
|
2017-11-11 19:14:21 +08:00
|
|
|
roles:
|
2017-11-12 14:54:20 +08:00
|
|
|
- etcd
|
2017-11-11 19:14:21 +08:00
|
|
|
|
2019-05-18 16:48:58 +08:00
|
|
|
# to install container runtime
|
2018-03-02 08:40:29 +08:00
|
|
|
- hosts:
|
2021-01-19 17:41:00 +08:00
|
|
|
- kube_master
|
|
|
|
- kube_node
|
2017-11-21 11:27:06 +08:00
|
|
|
roles:
|
2019-05-18 16:48:58 +08:00
|
|
|
- { role: docker, when: "CONTAINER_RUNTIME == 'docker'" }
|
|
|
|
- { role: containerd, when: "CONTAINER_RUNTIME == 'containerd'" }
|
2017-11-21 11:27:06 +08:00
|
|
|
|
2021-01-19 17:41:00 +08:00
|
|
|
# to set up 'kube_master' nodes
|
|
|
|
- hosts: kube_master
|
2017-11-11 19:14:21 +08:00
|
|
|
roles:
|
|
|
|
- kube-master
|
2018-03-16 18:23:34 +08:00
|
|
|
- kube-node
|
|
|
|
tasks:
|
2018-09-29 09:06:19 +08:00
|
|
|
- name: Making master nodes SchedulingDisabled
|
2018-06-09 22:19:20 +08:00
|
|
|
shell: "{{ bin_dir }}/kubectl cordon {{ inventory_hostname }} "
|
2021-01-19 17:41:00 +08:00
|
|
|
when: "inventory_hostname not in groups['kube_node']"
|
2018-03-16 18:23:34 +08:00
|
|
|
ignore_errors: true
|
2017-11-11 19:14:21 +08:00
|
|
|
|
2018-09-29 09:06:19 +08:00
|
|
|
- name: Setting master role name
|
2018-06-09 22:19:20 +08:00
|
|
|
shell: "{{ bin_dir }}/kubectl label node {{ inventory_hostname }} kubernetes.io/role=master --overwrite"
|
2018-05-23 09:45:06 +08:00
|
|
|
ignore_errors: true
|
|
|
|
|
2021-01-19 17:41:00 +08:00
|
|
|
# to set up 'kube_node' nodes
|
|
|
|
- hosts: kube_node
|
2017-11-11 19:14:21 +08:00
|
|
|
roles:
|
2021-01-19 17:41:00 +08:00
|
|
|
- { role: kube-node, when: "inventory_hostname not in groups['kube_master']" }
|
2018-01-02 22:12:51 +08:00
|
|
|
|
2018-09-29 09:06:19 +08:00
|
|
|
# to install network plugin, only one can be choosen
|
2018-03-02 08:40:29 +08:00
|
|
|
- hosts:
|
2021-01-19 17:41:00 +08:00
|
|
|
- kube_master
|
|
|
|
- kube_node
|
2018-01-02 22:12:51 +08:00
|
|
|
roles:
|
|
|
|
- { role: calico, when: "CLUSTER_NETWORK == 'calico'" }
|
2018-08-05 16:12:32 +08:00
|
|
|
- { role: cilium, when: "CLUSTER_NETWORK == 'cilium'" }
|
2018-01-02 22:12:51 +08:00
|
|
|
- { role: flannel, when: "CLUSTER_NETWORK == 'flannel'" }
|
2018-06-14 09:39:47 +08:00
|
|
|
- { role: kube-router, when: "CLUSTER_NETWORK == 'kube-router'" }
|
2019-05-22 11:17:42 +08:00
|
|
|
- { role: kube-ovn, when: "CLUSTER_NETWORK == 'kube-ovn'" }
|
2018-06-17 23:19:04 +08:00
|
|
|
|
2019-05-18 16:48:58 +08:00
|
|
|
# to install cluster-addons
|
2018-06-29 15:26:01 +08:00
|
|
|
- hosts:
|
2021-01-19 17:41:00 +08:00
|
|
|
- kube_node
|
2018-06-17 23:19:04 +08:00
|
|
|
roles:
|
2019-05-29 20:45:25 +08:00
|
|
|
- cluster-addon
|