Tomáš Kukrál | 2712be7 | 2017-02-23 10:24:31 +0100 | [diff] [blame] | 1 | /** |
| 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 | |
| 10 | common = new com.mirantis.mk.Common() |
| 11 | salt = new com.mirantis.mk.Salt() |
| 12 | orchestrate = new com.mirantis.mk.Orchestrate() |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 13 | timeout(time: 12, unit: 'HOURS') { |
| 14 | node { |
Tomáš Kukrál | 2712be7 | 2017-02-23 10:24:31 +0100 | [diff] [blame] | 15 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 16 | // connection objects |
| 17 | def master |
Tomáš Kukrál | 2712be7 | 2017-02-23 10:24:31 +0100 | [diff] [blame] | 18 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 19 | stage("Connect to Salt master") { |
| 20 | master = salt.connection(SALT_URL, SALT_MASTER_CREDENTIALS) |
| 21 | } |
Tomáš Kukrál | 2712be7 | 2017-02-23 10:24:31 +0100 | [diff] [blame] | 22 | |
| 23 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 24 | stage("Enforce kubernetes.control") { |
| 25 | common.infoMsg('Enforcing kubernetes.control on I@kubernetes:master') |
Tomáš Kukrál | 2712be7 | 2017-02-23 10:24:31 +0100 | [diff] [blame] | 26 | |
Jakub Josef | 2c21c6c | 2018-02-08 18:51:42 +0100 | [diff] [blame] | 27 | salt.enforceState( |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 28 | master, |
| 29 | 'I@kubernetes:master', |
Jakub Josef | 2c21c6c | 2018-02-08 18:51:42 +0100 | [diff] [blame] | 30 | 'kubernetes.control' |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 31 | ) |
| 32 | } |
Tomáš Kukrál | 2712be7 | 2017-02-23 10:24:31 +0100 | [diff] [blame] | 33 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 34 | stage("setup-components") { |
| 35 | common.infoMsg('Setting up components') |
Tomáš Kukrál | 2712be7 | 2017-02-23 10:24:31 +0100 | [diff] [blame] | 36 | |
Jakub Josef | 2c21c6c | 2018-02-08 18:51:42 +0100 | [diff] [blame] | 37 | salt.cmdRun( |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 38 | master, |
| 39 | 'I@kubernetes:master', |
Jakub Josef | 2c21c6c | 2018-02-08 18:51:42 +0100 | [diff] [blame] | 40 | '/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 Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 41 | |
| 42 | } |
Tomáš Kukrál | 2712be7 | 2017-02-23 10:24:31 +0100 | [diff] [blame] | 43 | |
| 44 | } |
Tomáš Kukrál | 2712be7 | 2017-02-23 10:24:31 +0100 | [diff] [blame] | 45 | } |