odl: Make odl_hostconfig patching idempotent
[fuel.git] / mcp / config / states / kubernetes
1 #!/bin/bash -e
2 ##############################################################################
3 # Copyright (c) 2019 Mirantis Inc., Enea AB and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9
10 CI_DEBUG=${CI_DEBUG:-0}; [[ "${CI_DEBUG}" =~ (false|0) ]] || set -x
11
12 # Create and distribute SSL certificates for services
13 salt-call state.sls salt.minion
14
15 # Install etcd
16 salt -I 'etcd:server' state.sls etcd.server.service
17 salt -I 'etcd:server' cmd.run ". /var/lib/etcd/configenv && etcdctl cluster-health"
18
19 # Install Kubernetes and Calico
20 salt -I 'kubernetes:master' state.sls kubernetes.master.kube-addons
21 salt -I 'kubernetes:pool' state.sls kubernetes.pool
22 salt -I 'kubernetes:pool' cmd.run "calicoctl node status"
23 salt -I 'kubernetes:pool' cmd.run "calicoctl get ippool"
24
25 # Setup NAT for Calico
26 salt -I 'kubernetes:master' state.sls etcd.server.setup
27
28 # Run whole master to check consistency
29 salt -I 'kubernetes:master' state.sls kubernetes exclude=kubernetes.master.setup
30
31 # Register addons
32 salt -I 'kubernetes:master' state.sls kubernetes.master.setup
33
34 # Upload config
35 K8S_CONFIG=kubernetes.config
36 K8S_HOST_ID=$(salt -I 'kubernetes:master' --out=yaml cp.push \
37   /etc/kubernetes/admin-kube-config \
38   upload_path="$K8S_CONFIG" | cut -d':' -f1)
39 cd /opt && ln -sf "/var/cache/salt/master/minions/${K8S_HOST_ID}/files/${K8S_CONFIG}"