|
@@ -22,9 +22,17 @@
|
|
|
setup:
|
|
|
filter: ansible_default_ipv4.address
|
|
|
|
|
|
+- name: Check K8s nodes status
|
|
|
+ command: kubectl get nodes
|
|
|
+ changed_when: false
|
|
|
+ ignore_errors: True
|
|
|
+ register: k8s_nodes
|
|
|
+ tags: init
|
|
|
+
|
|
|
- name: Initialize kubeadm
|
|
|
command: "/bin/kubeadm init --pod-network-cidr='{{ pod_network_cidr_ip }}' --apiserver-advertise-address='{{ ansible_default_ipv4.address }}'"
|
|
|
changed_when: true
|
|
|
+ when: "'master' not in k8s_nodes.stdout"
|
|
|
register: init_output
|
|
|
tags: init
|
|
|
|
|
@@ -74,6 +82,7 @@
|
|
|
token: "{{ K8S_TOKEN.stdout }}"
|
|
|
hash: "{{ K8S_MANAGER_CA_HASH.stdout }}"
|
|
|
ip: "{{ ansible_default_ipv4.address }}"
|
|
|
+ k8s_nodes: "{{ k8s_nodes.stdout }}"
|
|
|
tags: init
|
|
|
|
|
|
- name: Print k8s token
|
|
@@ -96,12 +105,12 @@
|
|
|
|
|
|
- name: Setup Calico SDN network
|
|
|
command: "kubectl apply -f '{{ calico_yml_url }}'"
|
|
|
- when: k8s_cni == "calico"
|
|
|
+ when: hostvars['127.0.0.1']['k8s_cni'] == "calico"
|
|
|
tags: init
|
|
|
|
|
|
- name: Setup Flannel SDN network
|
|
|
command: "kubectl apply -f '{{ flannel_yml_url }}'"
|
|
|
- when: k8s_cni == "flannel"
|
|
|
+ when: hostvars['127.0.0.1']['k8s_cni'] == "flannel"
|
|
|
tags: init
|
|
|
|
|
|
- name: Create yaml repo for setup
|
|
@@ -120,9 +129,16 @@
|
|
|
mode: "{{ k8s_service_account_file_mode }}"
|
|
|
tags: init
|
|
|
|
|
|
+- name: Check K8s service accounts status
|
|
|
+ command: "kubectl get serviceaccounts"
|
|
|
+ changed_when: false
|
|
|
+ register: k8s_service_accounts
|
|
|
+ tags: init
|
|
|
+
|
|
|
- name: Create service account (K8s dashboard)
|
|
|
command: "kubectl create -f '{{ k8s_service_account_file_dest }}'"
|
|
|
changed_when: true
|
|
|
+ when: "'default' not in k8s_service_accounts.stdout"
|
|
|
tags: init
|
|
|
|
|
|
- name: Create clusterRoleBinding (K8s dashboard) files
|
|
@@ -137,6 +153,7 @@
|
|
|
- name: Create clusterRoleBinding (K8s dashboard)
|
|
|
command: "kubectl create -f '{{ k8s_clusterRoleBinding_file_dest }}'"
|
|
|
changed_when: true
|
|
|
+ ignore_errors: True
|
|
|
tags: init
|
|
|
|
|
|
- name: Dump bearer token for K8s dashboard login
|
|
@@ -146,7 +163,7 @@
|
|
|
changed_when: true
|
|
|
tags: init
|
|
|
|
|
|
-- name: Edge / Workstation Install allows pods to schedule on manager
|
|
|
+- name: Edge / Workstation Install allows pods to scheudle on manager
|
|
|
command: kubectl taint nodes --all node-role.kubernetes.io/master-
|
|
|
- when: single_node
|
|
|
- tags: init
|
|
|
+ when: groups['manager'][0] == groups['compute'][0] and groups['compute']|length == 1
|
|
|
+ tags: init
|