blob: 6fe045646eb55321bad6320a55fdea8cb18ea08a [file] [log] [blame]
Richard Jankowskid7921b72018-02-20 16:55:12 -05001- name: Install Kubernetes dependencies
2 become: yes
3 apt:
4 name: "{{ item }}"
5 state: latest
6 with_items:
7 - apt-transport-https
8 - jq
9
10- name: Get apt signing key from Google Cloud
11 become: yes
12 apt_key:
13 url: https://packages.cloud.google.com/apt/doc/apt-key.gpg
14 state: present
15
16- name: Add Kubernetes apt repository
17 become: yes
18 apt_repository:
19 repo: 'deb http://apt.kubernetes.io/ kubernetes-xenial main'
20 filename: kubernetes
21 state: present
22 update_cache: yes
23
24- name: Install Kubernetes
25 become: yes
26 apt:
27 name: "{{ item }}"
28 state: present
29 with_items:
30 - kubeadm=1.8.5-00
31 - kubectl=1.8.5-00
32 - kubelet=1.8.5-00
33 - kubernetes-cni=0.6.0-00
34
35- name: Initialize node as Kubernetes master
36 become: yes
37 command: "kubeadm init --apiserver-advertise-address=10.100.198.220"
38
39- name: Create .kube directory under home
40 become: yes
41 file:
42 dest: /home/ubuntu/.kube
43 mode: 0755
44 owner: ubuntu
45 group: ubuntu
46 state: directory
47
48- name: Copy config to home directory
49 become: yes
50 command: "sudo cp /etc/kubernetes/admin.conf /home/ubuntu/.kube/config"
51
52- name: Change ownership of ~/.kube/config
53 become: yes
54 file:
55 path: /home/ubuntu/.kube/config
56 mode: 0600
57 owner: ubuntu
58 group: ubuntu
59
60- name: Set proxy-mode flag in kube-proxy daemonset (workaround for https://github.com/kubernetes/kubernetes/issues/34101)
61 become: yes
62 shell: "kubectl --kubeconfig=/etc/kubernetes/admin.conf -n kube-system get ds -l 'k8s-app==kube-proxy' -o json | jq '.items[0].spec.template.spec.containers[0].command |= .+ [\"--proxy-mode=userspace\"]' | kubectl --kubeconfig=/etc/kubernetes/admin.conf apply -f - && kubectl --kubeconfig=/etc/kubernetes/admin.conf -n kube-system delete pods -l 'k8s-app==kube-proxy'"
63 register: proxy
64 until: proxy.rc == 0
65 retries: 60
66 delay: 10
67
68- name: Allow workloads on Kubernetes master
69 become: yes
70 command: "kubectl --kubeconfig=/etc/kubernetes/admin.conf taint nodes --all node-role.kubernetes.io/master-"
71
72- name: Install pod network
73 become: yes
74 command: "kubectl --kubeconfig=/etc/kubernetes/admin.conf apply -f /cord/incubator/voltha/k8s/weave-net-1.8.yml"