blob: d8847137afe214ad5c620513cc12d7c950f7a3e2 [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 Josefa63f9862018-01-11 17:58:38 +010027 salt.runSaltProcessStep(
28 master,
29 'I@kubernetes:master',
30 'state.sls',
31 ['kubernetes.control'],
32 )
33 }
Tomáš Kukrál2712be72017-02-23 10:24:31 +010034
Jakub Josefa63f9862018-01-11 17:58:38 +010035 stage("setup-components") {
36 common.infoMsg('Setting up components')
Tomáš Kukrál2712be72017-02-23 10:24:31 +010037
Jakub Josefa63f9862018-01-11 17:58:38 +010038 salt.runSaltProcessStep(
39 master,
40 'I@kubernetes:master',
41 'cmd.run',
42 ['/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;\'']
43 )
44
45 }
Tomáš Kukrál2712be72017-02-23 10:24:31 +010046
47 }
Tomáš Kukrál2712be72017-02-23 10:24:31 +010048}