mirror of
https://github.com/phfroidmont/self-hosting.git
synced 2025-12-25 05:36:59 +01:00
Install Kubernetes 1.11 and go back to Ubuntu Xenial until Bionic is officially supported
This commit is contained in:
parent
5acc7652a9
commit
bf83e675f2
26 changed files with 765 additions and 7 deletions
58
roles/kubernetes/tasks/kubeadm-master.yml
Normal file
58
roles/kubernetes/tasks/kubeadm-master.yml
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
---
|
||||
# we get kubectl output to check if we have to add the node or not
|
||||
# errors are ignored in case of the first initialization on the first master
|
||||
- name: Getting kubectl output
|
||||
shell: "kubectl get nodes"
|
||||
register: kubectl_output
|
||||
changed_when: False
|
||||
check_mode: False
|
||||
failed_when: kubectl_output.rc != 0 and not 'did you specify the right host' in kubectl_output.stderr
|
||||
|
||||
- block:
|
||||
- name: Kubeadm init on first master in multimaster cluster
|
||||
shell: |
|
||||
kubeadm init \
|
||||
--config /tmp/kubeadm_config
|
||||
{%- if kubeadm_ignore_preflight_errors | length > 0 %} \
|
||||
--ignore-preflight-errors={{ kubeadm_ignore_preflight_errors }}
|
||||
{% endif %}
|
||||
register: kubeadm_output
|
||||
failed_when: "'Your Kubernetes master has initialized successfully' not in kubeadm_output.stdout"
|
||||
when: groups.k8s_masters | length > 1
|
||||
|
||||
- name: Kubeadm init on sole master
|
||||
shell: |
|
||||
kubeadm init \
|
||||
--apiserver-advertise-address={{ vpn_ip }} \
|
||||
--pod-network-cidr={{ pod_subnet }} \
|
||||
--kubernetes-version {{ kubernetes_version }}
|
||||
{%- if kubeadm_ignore_preflight_errors | length > 0 %} \
|
||||
--ignore-preflight-errors={{ kubeadm_ignore_preflight_errors }}
|
||||
{% endif %}
|
||||
# flannel has trouble unless we restart the kubelet service
|
||||
notify: restart kubelet
|
||||
when:
|
||||
- groups.k8s_masters | length == 1
|
||||
- inventory_hostname == initial_master
|
||||
|
||||
- name: Kubeadm output
|
||||
debug: var=kubeadm_output
|
||||
|
||||
when: ansible_hostname not in kubectl_output.stdout
|
||||
|
||||
- name: Copying /etc/kubernetes/admin.conf to ~/.kube/config
|
||||
copy:
|
||||
src: /etc/kubernetes/admin.conf
|
||||
dest: ~/.kube/config
|
||||
remote_src: yes
|
||||
|
||||
- include: cni.yml
|
||||
|
||||
- name: Wait for master to be ready
|
||||
shell: "kubectl get nodes $(hostname) | tail -n+2 | awk '{ print $2 }'"
|
||||
register: result
|
||||
until: result.stdout.find("Ready") == 0
|
||||
retries: 36
|
||||
delay: 10
|
||||
|
||||
- meta: flush_handlers
|
||||
Loading…
Add table
Add a link
Reference in a new issue