diff --git a/defaults/main.yml b/defaults/main.yml index c762218..fd82102 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -17,8 +17,8 @@ kubernetes_allow_pods_on_master: True kubernetes_enable_web_ui: True kuberenetes_debug: False -kubernetes_pod_network_cidr: '10.0.1.0/16' -kubernetes_apiserver_advertise_address: '' +kubernetes_pod_network_cidr: '10.244.0.0/16' +kubernetes_apiserver_advertise_address: '0.0.0.0' kubernetes_version: 'stable-1.10' kubernetes_ignore_preflight_errors: 'all' diff --git a/tasks/main.yml b/tasks/main.yml index 72d040c..349f081 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -35,6 +35,12 @@ path: /etc/kubernetes/admin.conf register: kubernetes_init_stat +- name: configure docker cgroup driver + shell: sed -i "s/cgroup-driver=systemd/cgroup-driver=cgroupfs/g" /etc/systemd/system/kubelet.service.d/10-kubeadm.conf + +- name: restart docker services + shell: systemctl daemon-reload && service kubelet restart + # Set up master. - include_tasks: master-setup.yml when: kubernetes_role == 'master' @@ -43,8 +49,8 @@ - name: Get the kubeadm join command from the Kubernetes master. shell: kubeadm token create --print-join-command changed_when: False - when: kubernetes_role == 'master' - run_once: True + run_once: true + delegate_to: "{{ groups['master'][0] }}" register: kubernetes_join_command - include_tasks: node-setup.yml diff --git a/tasks/master-setup.yml b/tasks/master-setup.yml index 3b4a1bb..205aca7 100644 --- a/tasks/master-setup.yml +++ b/tasks/master-setup.yml @@ -44,7 +44,7 @@ - kubernetes_init_stat.stat.exists == False - name: Check if Kubernetes Dashboard UI service already exists. - shell: kubectl get services --namespace kube-system | grep -q kubernetes-dashboard + shell: kubectl get pods -n kube-system | grep kubernetes-dashboard changed_when: False failed_when: False register: kubernetes_dashboard_service @@ -54,4 +54,11 @@ command: "kubectl create -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml" when: - kubernetes_enable_web_ui - - kubernetes_dashboard_service is failed + - kubernetes_dashboard_service.stdout.find("kubernetes-dashboard") == -1 + +- name: Wait for cluster to be ready + shell: kubectl get nodes + register: cluster + until: cluster.stdout.find(" Ready") != -1 + retries: 30 + delay: 10 diff --git a/tasks/node-setup.yml b/tasks/node-setup.yml index 7a67963..cc3922b 100644 --- a/tasks/node-setup.yml +++ b/tasks/node-setup.yml @@ -1,4 +1,8 @@ --- +- name: print join command + debug: + msg: "{{ kubernetes_join_command }}" + - name: Join node to Kubernetes master shell: > {{ kubernetes_join_command.stdout }}