blob: 94efef309d9c8de7d7e0beacfa7221f413d5d492 [file] [log] [blame]
Filip Pytloune08c4882017-07-03 10:58:26 +02001def common = new com.mirantis.mk.Common()
2def salt = new com.mirantis.mk.Salt()
3
4targetExpression = TARGET_MINIONS ? TARGET_MINIONS : "E@kvm01.*"
5
6node() {
Filip Pytloun5bd1f2c2017-07-03 11:11:16 +02007 def saltMaster
8 stage('Connect to Salt master') {
9 saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
10 }
Filip Pytloune08c4882017-07-03 10:58:26 +020011 common.infoMsg("Enforcing kubernetes state..")
12 stage("Update k8s control") {
13 salt.enforceState(
Filip Pytloun5bd1f2c2017-07-03 11:11:16 +020014 saltMaster,
15 targetExpression,
16 'kubernetes.control',
Filip Pytloune08c4882017-07-03 10:58:26 +020017 true
18 )
19 }
20 stage("Update components") {
21 common.info("Setting up components..")
22 out = salt.cmdRun(
23 master,
Filip Pytloun5bd1f2c2017-07-03 11:11:16 +020024 targetExpression,
Filip Pytloune08c4882017-07-03 10:58:26 +020025 '/bin/bash -c \'find /srv/kubernetes/ -type d | grep -v jobs | while read i; do ls $i/*.yml &>/dev/null && (set -x; hyperkube kubectl apply -f $i || echo Command failed; set +x); done; jobs=$(hyperkube kubectl get jobs -o name); find /srv/kubernetes/jobs -type f -name "*.yml" | while read i; do name=$(grep "name:" $i | head -1 | awk "{print $NF}"); echo $jobs|grep $name >/dev/null || (set -x; hyperkube kubectl apply -f $i || echo Command failed; set +x);done\''
26 )
27 for (entry in out['return']) {
28 for (node in entry) {
29 if (node.value =~ /Command failed/) {
30 error("$node.key: $node.value")
31 } else {
32 println "$node.key: $node.value"
33 }
34 }
35 }
36 }
37}