blob: 6e66fc42c0252944cdfd7f8dcaa2d94653e43c3c [file] [log] [blame]
vrovachevbc2f5ce2017-05-22 19:37:24 +04001{% from 'virtual-mcp11-k8s-calico/underlay.yaml' import HOSTNAME_CTL02 with context %}
vrovachev99228d32017-06-08 19:46:10 +04002{% from 'virtual-mcp11-k8s-calico/underlay.yaml' import HOSTNAME_CFG01 with context %}
vrovachevbc2f5ce2017-05-22 19:37:24 +04003
4# Clone virtlet project from git to the ctl01 node for start virtlet pod from yaml
5- description: Cloning virtlet project on ctl02
6 cmd: git clone -b master https://github.com/Mirantis/virtlet.git
7 node_name: {{ HOSTNAME_CTL02 }}
8 retry: {count: 1, delay: 1}
9 skip_fail: false
10
11# Add 'virtlet' label for ctl02
12- description: Adding virtlet label for ctl02
13 cmd: kubectl label node ctl02 extraRuntime=virtlet
14 node_name: {{ HOSTNAME_CTL02 }}
15 retry: {count: 1, delay: 1}
16 skip_fail: false
17
vrovachev99228d32017-06-08 19:46:10 +040018# Add route for internal kube-services if necessary
19- description: Adding route for internal kube-services if necessary
20 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@kubernetes:pool' cmd.run "ip r | grep 10.254 || ip ro add 10.254.0.0/16 dev ens4"
21 node_name: {{ HOSTNAME_CFG01 }}
22 retry: {count: 1, delay: 1}
23 skip_fail: false
24
25
26# Install jq
27- description: Install jq
28 cmd: apt-get install jq -y
29 node_name: {{ HOSTNAME_CTL02 }}
30 retry: {count: 1, delay: 1}
31 skip_fail: false
32
vrovachevbc2f5ce2017-05-22 19:37:24 +040033# Add extra parameter for kubelet service on virtlet node
34- description: Adding extra parameter for kubelet service on virtlet node
35 cmd: sed -i.bak "s|^\"|--feature-gates=DynamicKubeletConfig=true \\\\\\n\"|" /etc/default/kubelet
36 node_name: {{ HOSTNAME_CTL02 }}
37 retry: {count: 1, delay: 1}
38 skip_fail: false
39
vrovachev99228d32017-06-08 19:46:10 +040040# Restart kubelet service on virtlet node
41- description: Restart kubelet service on ctl02
42 cmd: systemctl restart kubelet
vrovachevbc2f5ce2017-05-22 19:37:24 +040043 node_name: {{ HOSTNAME_CTL02 }}
44 retry: {count: 1, delay: 1}
45 skip_fail: false
46
47# Create virtlet pod
48- description: Creating virtlet pod
vrovachev99228d32017-06-08 19:46:10 +040049 cmd: |
50 kubectl convert -f virtlet/deploy/virtlet-ds.yaml --local -o json | jq \
51 '.items[0].spec.template.spec.containers[0].env|=.+[{"name":"VIRTLET_DISABLE_KVM","value":"y"}] | .items[0].spec.template.spec.volumes|=.+[{"name":"etcd","hostPath":{"path":"/var/lib/etcd"}},{"name":"kubernetes","hostPath":{"path":"/etc/kubernetes"}}] | .items[0].spec.template.spec.containers[0].volumeMounts|=.+[{"mountPath":"/etc/kubernetes","name":"kubernetes"},{"mountPath":"/var/lib/etcd","name":"etcd"}]' | \
52 kubectl create -f -
vrovachevbc2f5ce2017-05-22 19:37:24 +040053 node_name: {{ HOSTNAME_CTL02 }}
54 retry: {count: 1, delay: 1}
55 skip_fail: false
56
57# Virtlet pod will likely stay in Init:0/1 state because there's a problem
58# with automatic kubelet restart after applying the configmap.
59# As of now, you'll need to restart kubelet after ~30-60 seconds.
60- description: Restarting kubelet service on virtlet node
61 cmd: |
62 COUNTER=0
63 while [[ $(kubectl get pods -n kube-system | awk '/virtlet/{print $3}') != 'Init:0/1' ]]; do
64 COUNTER=$((COUNTER+1))
65 sleep 5
66 if [[ $COUNTER -eq 36 ]]; then
67 echo "We havenot Init:0/1 state for virtlet pod. Aborting.";
68 exit 1
69 fi
70 done
71 sleep 60
72 systemctl restart kubelet
73 node_name: {{ HOSTNAME_CTL02 }}
74 retry: {count: 1, delay: 1}
75 skip_fail: false
76
77# Wait Active state for virtlet pod
78- description: Waiting 'Active' state for virtlet pod
79 cmd: |
80 COUNTER=0
81 while [[ $(kubectl get pods -n kube-system | awk '/virtlet/{print $3}') != 'Running' ]]; do
82 COUNTER=$((COUNTER+1))
83 sleep 5
84 if [[ $COUNTER -eq 36 ]]; then
85 echo "We havenot Active state for virtlet pod. Aborting.";
86 exit 1
87 fi
88 done
89 node_name: {{ HOSTNAME_CTL02 }}
90 retry: {count: 1, delay: 1}
91 skip_fail: false