sgudz | 33280bd | 2018-11-01 14:32:05 +0200 | [diff] [blame] | 1 | {% from 'cookied-bm-k8s-contrail/underlay.yaml' import HOSTNAME_CFG01 with context %} |
| 2 | {% from 'cookied-bm-k8s-contrail/underlay.yaml' import HOSTNAME_CTL01 with context %} |
sgudz | fc5b22f | 2018-08-23 17:45:04 +0300 | [diff] [blame] | 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 Tyzhnenko | 7c7b7d8 | 2018-07-20 15:35:07 +0300 | [diff] [blame] | 15 | |
| 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 Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 36 | |
| 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 }} |
sgudz | fc5b22f | 2018-08-23 17:45:04 +0300 | [diff] [blame] | 41 | retry: {count: 3, delay: 30} |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 42 | skip_fail: false |
| 43 | |
Dmitry Tyzhnenko | 7c7b7d8 | 2018-07-20 15:35:07 +0300 | [diff] [blame] | 44 | - description: Install certs |
| 45 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
sgudz | fc5b22f | 2018-08-23 17:45:04 +0300 | [diff] [blame] | 46 | -C 'I@etcd:server' state.sls salt.minion -b 1 |
Dmitry Tyzhnenko | 7c7b7d8 | 2018-07-20 15:35:07 +0300 | [diff] [blame] | 47 | node_name: {{ HOSTNAME_CFG01 }} |
| 48 | retry: {count: 2, delay: 5} |
| 49 | skip_fail: false |
| 50 | |
sgudz | fc5b22f | 2018-08-23 17:45:04 +0300 | [diff] [blame] | 51 | # Install opencontrail database services |
| 52 | - description: Install opencontrail database services for 01 |
sgudz | c8e0f48 | 2018-08-22 22:42:07 +0300 | [diff] [blame] | 53 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
sgudz | fc5b22f | 2018-08-23 17:45:04 +0300 | [diff] [blame] | 54 | -C 'I@opencontrail:database and *01*' state.sls opencontrail.database |
sgudz | c8e0f48 | 2018-08-22 22:42:07 +0300 | [diff] [blame] | 55 | node_name: {{ HOSTNAME_CFG01 }} |
sgudz | fc5b22f | 2018-08-23 17:45:04 +0300 | [diff] [blame] | 56 | 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} |
sgudz | c8e0f48 | 2018-08-22 22:42:07 +0300 | [diff] [blame] | 121 | skip_fail: false |
| 122 | |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 123 | - 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 | |
sgudz | fc5b22f | 2018-08-23 17:45:04 +0300 | [diff] [blame] | 130 | {{ MACRO_CHECK_SYSTEMCTL() }} |
| 131 | |
| 132 | - description: Run Kubernetes master setup |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 133 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
sgudz | 21ab5d7 | 2018-10-10 15:26:45 +0300 | [diff] [blame] | 134 | -C 'I@kubernetes:master' state.sls kubernetes.master.setup |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 135 | node_name: {{ HOSTNAME_CFG01 }} |
| 136 | retry: {count: 1, delay: 5} |
Dmitry Tyzhnenko | 7c7b7d8 | 2018-07-20 15:35:07 +0300 | [diff] [blame] | 137 | skip_fail: false |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 138 | |
sgudz | fc5b22f | 2018-08-23 17:45:04 +0300 | [diff] [blame] | 139 | - description: Restart Kubelet |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 140 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
sgudz | fc5b22f | 2018-08-23 17:45:04 +0300 | [diff] [blame] | 141 | -C 'I@kubernetes:master' service.restart 'kubelet' |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 142 | node_name: {{ HOSTNAME_CFG01 }} |
| 143 | retry: {count: 1, delay: 5} |
| 144 | skip_fail: false |
| 145 | |
sgudz | fc5b22f | 2018-08-23 17:45:04 +0300 | [diff] [blame] | 146 | - 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 Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 165 | retry: {count: 1, delay: 5} |
| 166 | skip_fail: true |
| 167 | |
sgudz | fc5b22f | 2018-08-23 17:45:04 +0300 | [diff] [blame] | 168 | - description: Check all pods |
| 169 | cmd: | |
| 170 | salt 'ctl*' cmd.run "kubectl -o wide get pods --all-namespaces"; |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 171 | node_name: {{ HOSTNAME_CFG01 }} |
| 172 | retry: {count: 1, delay: 5} |
sgudz | fc5b22f | 2018-08-23 17:45:04 +0300 | [diff] [blame] | 173 | skip_fail: false |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 174 | |
sgudz | fc5b22f | 2018-08-23 17:45:04 +0300 | [diff] [blame] | 175 | # Install contrail computes |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 176 | - 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 }} |
sgudz | fc5b22f | 2018-08-23 17:45:04 +0300 | [diff] [blame] | 180 | 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 Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 209 | retry: {count: 1, delay: 5} |
| 210 | skip_fail: false |
| 211 | |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 212 | - 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 | |
sgudz | fc5b22f | 2018-08-23 17:45:04 +0300 | [diff] [blame] | 226 | - description: Install docker host |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 227 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
sgudz | fc5b22f | 2018-08-23 17:45:04 +0300 | [diff] [blame] | 228 | -C 'I@kubernetes:master' state.sls salt.minion.cert |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 229 | node_name: {{ HOSTNAME_CFG01 }} |
sgudz | fc5b22f | 2018-08-23 17:45:04 +0300 | [diff] [blame] | 230 | retry: {count: 2, delay: 30} |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 231 | skip_fail: false |
| 232 | |
sgudz | fc5b22f | 2018-08-23 17:45:04 +0300 | [diff] [blame] | 233 | - 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 Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 236 | node_name: {{ HOSTNAME_CFG01 }} |
| 237 | retry: {count: 1, delay: 30} |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 238 | skip_fail: false |
| 239 | |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 240 | - description: Restart Kubelet |
| 241 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
sgudz | fc5b22f | 2018-08-23 17:45:04 +0300 | [diff] [blame] | 242 | -C 'I@kubernetes:pool and not I@kubernetes:master' service.restart 'kubelet' |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 243 | node_name: {{ HOSTNAME_CFG01 }} |
| 244 | retry: {count: 1, delay: 5} |
sgudz | fc5b22f | 2018-08-23 17:45:04 +0300 | [diff] [blame] | 245 | skip_fail: false |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 246 | |
sgudz | fc5b22f | 2018-08-23 17:45:04 +0300 | [diff] [blame] | 247 | - description: Configure OpenContrail as an add-on for Kubernetes |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 248 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False |
sgudz | fc5b22f | 2018-08-23 17:45:04 +0300 | [diff] [blame] | 249 | -C 'I@kubernetes:master' state.sls kubernetes.master.kube-addons |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 250 | node_name: {{ HOSTNAME_CFG01 }} |
| 251 | retry: {count: 1, delay: 5} |
sgudz | fc5b22f | 2018-08-23 17:45:04 +0300 | [diff] [blame] | 252 | skip_fail: false |
Dmitry Tyzhnenko | 34595f8 | 2018-06-12 19:03:12 +0300 | [diff] [blame] | 253 | |
| 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 |
sgudz | fc5b22f | 2018-08-23 17:45:04 +0300 | [diff] [blame] | 259 | |
| 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 |