PR #53 follow-up: Requested changes for simplicity.

This commit is contained in:
Jeff Geerling 2019-12-14 19:57:24 -06:00
parent 8d4e1b4dfc
commit 825d6f5e37
3 changed files with 20 additions and 9 deletions

View File

@ -55,7 +55,16 @@ Whether to remove the taint that denies pods from being deployed to the Kubernet
Whether to enable the Kubernetes web dashboard UI (only accessible on the master itself, or proxied), and the file containing the web dashboard UI manifest. Whether to enable the Kubernetes web dashboard UI (only accessible on the master itself, or proxied), and the file containing the web dashboard UI manifest.
kubernetes_pod_network_cidr: '10.244.0.0/16' kubernetes_pod_network:
# Flannel CNI.
cni: 'flannel'
cidr: '10.244.0.0/16'
# Calico CNI.
# cni: 'calico'
# cidr: '192.168.0.0/16'
This role currently supports `flannel` (default) or `calico` for cluster pod networking. Choose one or the other for your cluster; converting between the two is not done automatically and could result in broken networking, and should be done outside of this role.
kubernetes_apiserver_advertise_address: '' kubernetes_apiserver_advertise_address: ''
kubernetes_version_kubeadm: 'stable-{{ kubernetes_version }}' kubernetes_version_kubeadm: 'stable-{{ kubernetes_version }}'
kubernetes_ignore_preflight_errors: 'all' kubernetes_ignore_preflight_errors: 'all'

View File

@ -22,12 +22,14 @@ kubernetes_allow_pods_on_master: true
kubernetes_enable_web_ui: true kubernetes_enable_web_ui: true
kubernetes_web_ui_manifest_file: https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml kubernetes_web_ui_manifest_file: https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml
kubernetes_cni: 'calico'
kubernetes_pod_network: kubernetes_pod_network:
- name: 'flannel' # Flannel CNI.
cidr: '10.244.0.0/16' cni: 'flannel'
- name: 'calico' cidr: '10.244.0.0/16'
cidr: '192.168.0.0/16' # Calico CNI.
# cni: 'calico'
# cidr: '192.168.0.0/16'
kubernetes_apiserver_advertise_address: '' kubernetes_apiserver_advertise_address: ''
kubernetes_version_kubeadm: 'stable-{{ kubernetes_version }}' kubernetes_version_kubeadm: 'stable-{{ kubernetes_version }}'
kubernetes_ignore_preflight_errors: 'all' kubernetes_ignore_preflight_errors: 'all'

View File

@ -2,7 +2,7 @@
- name: Initialize Kubernetes master with kubeadm init. - name: Initialize Kubernetes master with kubeadm init.
command: > command: >
kubeadm init kubeadm init
--pod-network-cidr={{ item.cidr }} --pod-network-cidr={{ kubernetes_pod_network.cidr }}
--apiserver-advertise-address={{ kubernetes_apiserver_advertise_address | default(ansible_default_ipv4.address, true) }} --apiserver-advertise-address={{ kubernetes_apiserver_advertise_address | default(ansible_default_ipv4.address, true) }}
--kubernetes-version {{ kubernetes_version_kubeadm }} --kubernetes-version {{ kubernetes_version_kubeadm }}
--ignore-preflight-errors={{ kubernetes_ignore_preflight_errors }} --ignore-preflight-errors={{ kubernetes_ignore_preflight_errors }}
@ -36,7 +36,7 @@
- kubectl apply -f {{ kubernetes_flannel_manifest_file }} - kubectl apply -f {{ kubernetes_flannel_manifest_file }}
register: flannel_result register: flannel_result
changed_when: "'created' in flannel_result.stdout" changed_when: "'created' in flannel_result.stdout"
when: kubernetes_cni == 'flannel' when: kubernetes_pod_network.cni == 'flannel'
- name: Configure Calico networking. - name: Configure Calico networking.
command: "{{ item }}" command: "{{ item }}"
@ -44,7 +44,7 @@
- kubectl apply -f {{ kubernetes_calico_manifest_file }} - kubectl apply -f {{ kubernetes_calico_manifest_file }}
register: calico_result register: calico_result
changed_when: "'created' in calico_result.stdout" changed_when: "'created' in calico_result.stdout"
when: kubernetes_cni == 'calico' when: kubernetes_pod_network.cni == 'calico'
# TODO: Check if taint exists with something like `kubectl describe nodes` # TODO: Check if taint exists with something like `kubectl describe nodes`
# instead of using kubernetes_init_stat.stat.exists check. # instead of using kubernetes_init_stat.stat.exists check.