blob: 308051ae09eeb265b9f2d703483325d5d610a57d [file] [log] [blame]
Dmitry Tyzhnenko7c7b7d82018-07-20 15:35:07 +03001{% from 'cookied-bm-mcp-pike-k8s-contrail/underlay.yaml' import HOSTNAME_CFG01 with context %}
sgudzfc5b22f2018-08-23 17:45:04 +03002{% from 'cookied-bm-mcp-pike-k8s-contrail/underlay.yaml' import HOSTNAME_CTL01 with context %}
3
4{%- macro MACRO_CHECK_SYSTEMCTL() %}
5{#######################################}
6- description: Check systemctl on compute
7 cmd: |
8 set -ex;
9 salt 'cmp*' cmd.run "systemctl --version";
10 salt 'cmp*' cmd.run "journalctl -u dbus";
11 node_name: {{ HOSTNAME_CFG01 }}
12 retry: {count: 1, delay: 1}
13 skip_fail: true
14{%- endmacro %}
Dmitry Tyzhnenko7c7b7d82018-07-20 15:35:07 +030015
16- description: Install keepalived on primary controller
17 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
18 -C 'I@keepalived:cluster and *01*' state.sls keepalived
19 node_name: {{ HOSTNAME_CFG01 }}
20 retry: {count: 1, delay: 10}
21 skip_fail: false
22
23- description: Install keepalived
24 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
25 -C 'I@keepalived:cluster' state.sls keepalived
26 node_name: {{ HOSTNAME_CFG01 }}
27 retry: {count: 1, delay: 10}
28 skip_fail: false
29
30- description: Install haproxy
31 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
32 -C 'I@haproxy:proxy' state.sls haproxy
33 node_name: {{ HOSTNAME_CFG01 }}
34 retry: {count: 1, delay: 5}
35 skip_fail: false
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +030036
37- description: Install etcd
38 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
39 -C 'I@etcd:server' state.sls etcd.server.service
40 node_name: {{ HOSTNAME_CFG01 }}
sgudzfc5b22f2018-08-23 17:45:04 +030041 retry: {count: 3, delay: 30}
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +030042 skip_fail: false
43
Dmitry Tyzhnenko7c7b7d82018-07-20 15:35:07 +030044- description: Install certs
45 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
sgudzfc5b22f2018-08-23 17:45:04 +030046 -C 'I@etcd:server' state.sls salt.minion -b 1
Dmitry Tyzhnenko7c7b7d82018-07-20 15:35:07 +030047 node_name: {{ HOSTNAME_CFG01 }}
48 retry: {count: 2, delay: 5}
49 skip_fail: false
50
sgudzfc5b22f2018-08-23 17:45:04 +030051# Install opencontrail database services
52- description: Install opencontrail database services for 01
sgudzc8e0f482018-08-22 22:42:07 +030053 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
sgudzfc5b22f2018-08-23 17:45:04 +030054 -C 'I@opencontrail:database and *01*' state.sls opencontrail.database
sgudzc8e0f482018-08-22 22:42:07 +030055 node_name: {{ HOSTNAME_CFG01 }}
sgudzfc5b22f2018-08-23 17:45:04 +030056 retry: {count: 2, delay: 30}
57 skip_fail: false
58
59- description: Install opencontrail database services
60 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
61 -C 'I@opencontrail:database' state.sls opencontrail.database
62 node_name: {{ HOSTNAME_CFG01 }}
63 retry: {count: 2, delay: 30}
64 skip_fail: false
65
66# Install opencontrail control services
67- description: Install opencontrail services for 01
68 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
69 -C 'I@opencontrail:control and *01*' state.sls opencontrail exclude=opencontrail.client
70 node_name: {{ HOSTNAME_CFG01 }}
71 retry: {count: 2, delay: 30}
72 skip_fail: false
73
74- description: Install opencontrail services
75 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
76 -C 'I@opencontrail:control' state.sls opencontrail exclude=opencontrail.client
77 node_name: {{ HOSTNAME_CFG01 }}
78 retry: {count: 2, delay: 30}
79 skip_fail: false
80
81- description: Install docker host
82 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
83 -C 'I@kubernetes:master' state.sls salt.minion.cert
84 node_name: {{ HOSTNAME_CFG01 }}
85 retry: {count: 2, delay: 30}
86 skip_fail: false
87
88- description: Install docker host
89 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
90 -C 'I@docker:host' state.sls docker.host
91 node_name: {{ HOSTNAME_CFG01 }}
92 retry: {count: 2, delay: 30}
93 skip_fail: false
94
95 #- description: Configure OpenContrail as an add-on for Kubernetes
96 # cmd: salt --hard-crash --state-output=mixed --state-verbose=False
97 # -C 'I@kubernetes:master' state.sls kubernetes.master.kube-addons
98 # node_name: {{ HOSTNAME_CFG01 }}
99 # retry: {count: 1, delay: 5}
100 # skip_fail: false
101
102- description: Install Kubernetes components
103 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
104 -C 'I@kubernetes:master' state.sls kubernetes.pool
105 node_name: {{ HOSTNAME_CFG01 }}
106 retry: {count: 1, delay: 30}
107 skip_fail: false
108
109- description: "Run k8s master at *01* to simplify namespaces creation"
110 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
111 -C 'I@kubernetes:master and *01*' state.sls kubernetes.master exclude=kubernetes.master.setup,kubernetes.master.kube-addons
112 node_name: {{ HOSTNAME_CFG01 }}
113 retry: {count: 2, delay: 15}
114 skip_fail: false
115
116- description: Run k8s without master.setup
117 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
118 -C 'I@kubernetes:master' state.sls kubernetes exclude=kubernetes.master.setup,kubernetes.master.kube-addons
119 node_name: {{ HOSTNAME_CFG01 }}
120 retry: {count: 2, delay: 15}
sgudzc8e0f482018-08-22 22:42:07 +0300121 skip_fail: false
122
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +0300123- description: Check the etcd health
124 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
125 -C 'I@etcd:server' cmd.run '. /var/lib/etcd/configenv && etcdctl cluster-health'
126 node_name: {{ HOSTNAME_CFG01 }}
127 retry: {count: 1, delay: 5}
128 skip_fail: false
129
sgudzfc5b22f2018-08-23 17:45:04 +0300130{{ MACRO_CHECK_SYSTEMCTL() }}
131
132- description: Run Kubernetes master setup
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +0300133 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
sgudzfc5b22f2018-08-23 17:45:04 +0300134 -C 'I@kubernetes:master and *01*' state.sls kubernetes.master.setup
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +0300135 node_name: {{ HOSTNAME_CFG01 }}
136 retry: {count: 1, delay: 5}
Dmitry Tyzhnenko7c7b7d82018-07-20 15:35:07 +0300137 skip_fail: false
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +0300138
sgudzfc5b22f2018-08-23 17:45:04 +0300139- description: Restart Kubelet
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +0300140 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
sgudzfc5b22f2018-08-23 17:45:04 +0300141 -C 'I@kubernetes:master' service.restart 'kubelet'
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +0300142 node_name: {{ HOSTNAME_CFG01 }}
143 retry: {count: 1, delay: 5}
144 skip_fail: false
145
sgudzfc5b22f2018-08-23 17:45:04 +0300146- description: Waiting for contrail-containers up. opencontrail.client state should be run only after that
147 cmd: |
148 sleep 30;
149 total_pods=`kubectl get pods --all-namespaces | awk '/opencontrail/ {print $3}' | cut -d "/" -f2`
150 for i in `seq 1 10`; do
151 ready_pods=`kubectl get pods --all-namespaces | awk '/opencontrail/ {print $3}' | cut -d "/" -f1`
152 if [ "$ready_pods" == "$total_pods" ];then
153 echo "containers are ready. Going to the next step"
154 break
155 elif [ "$i" -ne "10" ]; then
156 echo "Opencontrail containers is not ready. $ready_pods from $total_pods is ready."
157 sleep 60
158 continue
159 else
160 echo "Failed to up contrail containers in 10 minutes"
161 exit 1
162 fi
163 done
164 node_name: {{ HOSTNAME_CTL01 }}
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +0300165 retry: {count: 1, delay: 5}
166 skip_fail: true
167
sgudzfc5b22f2018-08-23 17:45:04 +0300168- description: Check all pods
169 cmd: |
170 salt 'ctl*' cmd.run "kubectl -o wide get pods --all-namespaces";
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +0300171 node_name: {{ HOSTNAME_CFG01 }}
172 retry: {count: 1, delay: 5}
sgudzfc5b22f2018-08-23 17:45:04 +0300173 skip_fail: false
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +0300174
sgudzfc5b22f2018-08-23 17:45:04 +0300175# Install contrail computes
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +0300176- description: Set up the OpenContrail resources
177 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
178 -C 'I@opencontrail:database:id:1' state.sls opencontrail.client
179 node_name: {{ HOSTNAME_CFG01 }}
sgudzfc5b22f2018-08-23 17:45:04 +0300180 retry: {count: 3, delay: 60}
181 skip_fail: false
182
183- description: Apply opencontrail.client on contrail computes
184 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
185 -C 'I@opencontrail:compute' state.sls opencontrail exclude=opencontrail.client
186 node_name: {{ HOSTNAME_CFG01 }}
187 retry: {count: 2, delay: 5}
188 skip_fail: false
189
190- description: Reboot contrail computes
191 cmd: |
192 salt --async -C 'I@opencontrail:compute' system.reboot;
193 sleep 450;
194 node_name: {{ HOSTNAME_CFG01 }}
195 retry: {count: 1, delay: 30}
196 skip_fail: true
197
198- description: Apply opencontrail.client on contrail computes
199 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
200 -C 'I@opencontrail:compute' state.sls opencontrail.client
201 node_name: {{ HOSTNAME_CFG01 }}
202 retry: {count: 2, delay: 5}
203 skip_fail: false
204
205- description: Apply opencontrail.client on contrail computes
206 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
207 -C 'I@opencontrail:compute' state.sls opencontrail
208 node_name: {{ HOSTNAME_CFG01 }}
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +0300209 retry: {count: 1, delay: 5}
210 skip_fail: false
211
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +0300212- description: Refresh pillars on cmp*
213 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
214 -C 'cmp*' saltutil.refresh_pillar
215 node_name: {{ HOSTNAME_CFG01 }}
216 retry: {count: 1, delay: 5}
217 skip_fail: false
218
219- description: Sync all on contrail computes
220 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
221 -C 'I@opencontrail:compute' saltutil.sync_all
222 node_name: {{ HOSTNAME_CFG01 }}
223 retry: {count: 1, delay: 5}
224 skip_fail: false
225
sgudzfc5b22f2018-08-23 17:45:04 +0300226- description: Install docker host
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +0300227 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
sgudzfc5b22f2018-08-23 17:45:04 +0300228 -C 'I@kubernetes:master' state.sls salt.minion.cert
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +0300229 node_name: {{ HOSTNAME_CFG01 }}
sgudzfc5b22f2018-08-23 17:45:04 +0300230 retry: {count: 2, delay: 30}
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +0300231 skip_fail: false
232
sgudzfc5b22f2018-08-23 17:45:04 +0300233- description: Install Kubernetes components
234 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
235 -C 'I@kubernetes:pool and not I@kubernetes:master' state.sls kubernetes.pool
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +0300236 node_name: {{ HOSTNAME_CFG01 }}
237 retry: {count: 1, delay: 30}
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +0300238 skip_fail: false
239
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +0300240- description: Restart Kubelet
241 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
sgudzfc5b22f2018-08-23 17:45:04 +0300242 -C 'I@kubernetes:pool and not I@kubernetes:master' service.restart 'kubelet'
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +0300243 node_name: {{ HOSTNAME_CFG01 }}
244 retry: {count: 1, delay: 5}
sgudzfc5b22f2018-08-23 17:45:04 +0300245 skip_fail: false
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +0300246
sgudzfc5b22f2018-08-23 17:45:04 +0300247- description: Configure OpenContrail as an add-on for Kubernetes
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +0300248 cmd: salt --hard-crash --state-output=mixed --state-verbose=False
sgudzfc5b22f2018-08-23 17:45:04 +0300249 -C 'I@kubernetes:master' state.sls kubernetes.master.kube-addons
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +0300250 node_name: {{ HOSTNAME_CFG01 }}
251 retry: {count: 1, delay: 5}
sgudzfc5b22f2018-08-23 17:45:04 +0300252 skip_fail: false
Dmitry Tyzhnenko34595f82018-06-12 19:03:12 +0300253
254- description: Renew hosts file on a whole cluster
255 cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C '*' state.sls linux.network.host;
256 node_name: {{ HOSTNAME_CFG01 }}
257 retry: {count: 1, delay: 5}
258 skip_fail: false
sgudzfc5b22f2018-08-23 17:45:04 +0300259
260- description: Final check all pods
261 cmd: |
262 sleep 60;
263 salt 'ctl*' cmd.run "kubectl -o wide get pods --all-namespaces";
264 node_name: {{ HOSTNAME_CFG01 }}
265 retry: {count: 1, delay: 5}
266 skip_fail: false
267
268- description: Check contrail status on all pods
269 cmd: |
270 pods=`kubectl get pods --all-namespaces | awk '/opencontrail/ {print $2}'`
271 for i in $pods; do
272 kubectl exec $i -c opencontrail-controller -n kube-system contrail-status;
273 kubectl exec $i -c opencontrail-analytics -n kube-system contrail-status;
274 kubectl exec $i -c opencontrail-analyticsdb -n kube-system contrail-status;
275 done
276 node_name: {{ HOSTNAME_CTL01 }}
277 retry: {count: 1, delay: 5}
278 skip_fail: false