blob: 87f20ed953690900d133ced7c46473d20066e55a [file] [log] [blame]
Tomáš Kukrál2712be72017-02-23 10:24:31 +01001/**
2 *
3 * Run states on K8s
4 *
5 * Expected parameters:
6 * SALT_MASTER_CREDENTIALS Credentials used to access Salt API
7 * SALT_URL URL usedd to connect to Salt API
8 */
9
10common = new com.mirantis.mk.Common()
11salt = new com.mirantis.mk.Salt()
12orchestrate = new com.mirantis.mk.Orchestrate()
Jakub Josefa63f9862018-01-11 17:58:38 +010013timeout(time: 12, unit: 'HOURS') {
14 node {
Tomáš Kukrál2712be72017-02-23 10:24:31 +010015
Jakub Josefa63f9862018-01-11 17:58:38 +010016 // connection objects
17 def master
Tomáš Kukrál2712be72017-02-23 10:24:31 +010018
Jakub Josefa63f9862018-01-11 17:58:38 +010019 stage("Connect to Salt master") {
20 master = salt.connection(SALT_URL, SALT_MASTER_CREDENTIALS)
21 }
Tomáš Kukrál2712be72017-02-23 10:24:31 +010022
23
Jakub Josefa63f9862018-01-11 17:58:38 +010024 stage("Enforce kubernetes.control") {
25 common.infoMsg('Enforcing kubernetes.control on I@kubernetes:master')
Tomáš Kukrál2712be72017-02-23 10:24:31 +010026
Jakub Josef2c21c6c2018-02-08 18:51:42 +010027 salt.enforceState(
Jakub Josefa63f9862018-01-11 17:58:38 +010028 master,
29 'I@kubernetes:master',
Jakub Josef2c21c6c2018-02-08 18:51:42 +010030 'kubernetes.control'
Jakub Josefa63f9862018-01-11 17:58:38 +010031 )
32 }
Tomáš Kukrál2712be72017-02-23 10:24:31 +010033
Jakub Josefa63f9862018-01-11 17:58:38 +010034 stage("setup-components") {
35 common.infoMsg('Setting up components')
Tomáš Kukrál2712be72017-02-23 10:24:31 +010036
Jakub Josef2c21c6c2018-02-08 18:51:42 +010037 salt.cmdRun(
Jakub Josefa63f9862018-01-11 17:58:38 +010038 master,
39 'I@kubernetes:master',
Jakub Josef2c21c6c2018-02-08 18:51:42 +010040 '/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;\'')
Jakub Josefa63f9862018-01-11 17:58:38 +010041
42 }
Tomáš Kukrál2712be72017-02-23 10:24:31 +010043
44 }
Tomáš Kukrál2712be72017-02-23 10:24:31 +010045}