blob: 5a0bf9dcc601815afe807e0d0662fb902c55984e [file] [log] [blame]
def common = new com.mirantis.mk.Common()
def salt = new com.mirantis.mk.Salt()
targetExpression = TARGET_MINIONS ? TARGET_MINIONS : "E@kvm01.*"
node() {
def saltMaster
stage('Connect to Salt master') {
saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
}
common.infoMsg("Enforcing kubernetes state..")
stage("Update k8s control") {
salt.enforceState(
saltMaster,
targetExpression,
'kubernetes.control',
true
)
}
stage("Update components") {
common.infoMsg("Setting up components..")
def extraCommand
try {
extraCommand = EXTRA_COMMAND
} catch (Throwable e) {
extraCommand = null
}
if (extraCommand) {
salt.cmdRun(
saltMaster,
targetExpression,
extraCommand
)
}
out = salt.cmdRun(
saltMaster,
targetExpression,
'/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\''
)
for (entry in out['return']) {
for (node in entry) {
if (node.value =~ /Command failed/) {
error("$node.key: $node.value")
} else {
println "$node.key: $node.value"
}
}
}
}
}