Merge pull request #53 from palankarravi/cni

calico cni choice
This commit is contained in:
Jeff Geerling 2019-12-14 19:52:01 -06:00 committed by GitHub
commit 8d4e1b4dfc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 4 deletions

View File

@ -22,7 +22,12 @@ 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_pod_network_cidr: '10.244.0.0/16' kubernetes_cni: 'calico'
kubernetes_pod_network:
- name: 'flannel'
cidr: '10.244.0.0/16'
- name: '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'
@ -37,3 +42,6 @@ kubernetes_yum_arch: x86_64
# Flannel config files. # Flannel config files.
kubernetes_flannel_manifest_file_rbac: https://raw.githubusercontent.com/coreos/flannel/master/Documentation/k8s-manifests/kube-flannel-rbac.yml kubernetes_flannel_manifest_file_rbac: https://raw.githubusercontent.com/coreos/flannel/master/Documentation/k8s-manifests/kube-flannel-rbac.yml
kubernetes_flannel_manifest_file: https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml kubernetes_flannel_manifest_file: https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
# Calico config files
kubernetes_calico_manifest_file: https://docs.projectcalico.org/v3.7/manifests/calico.yaml

View File

@ -2,15 +2,15 @@
- name: Initialize Kubernetes master with kubeadm init. - name: Initialize Kubernetes master with kubeadm init.
command: > command: >
kubeadm init kubeadm init
--pod-network-cidr={{ kubernetes_pod_network_cidr }} --pod-network-cidr={{ item.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 }}
{{ kubernetes_kubeadm_init_extra_opts }} {{ kubernetes_kubeadm_init_extra_opts }}
with_items: "{{ kubernetes_pod_network }}"
register: kubeadmin_init register: kubeadmin_init
failed_when: false failed_when: false
when: not kubernetes_init_stat.stat.exists when: not kubernetes_init_stat.stat.exists and item.name == kubernetes_cni
- name: Print the init output to screen. - name: Print the init output to screen.
debug: debug:
@ -36,6 +36,15 @@
- 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'
- name: Configure Calico networking.
command: "{{ item }}"
with_items:
- kubectl apply -f {{ kubernetes_calico_manifest_file }}
register: calico_result
changed_when: "'created' in calico_result.stdout"
when: kubernetes_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.