Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 1 | /** |
| 2 | * |
| 3 | * Launch heat stack with basic k8s |
| 4 | * Flow parameters: |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 5 | * STACK_NAME Heat stack name |
| 6 | * STACK_TYPE Orchestration engine: heat, '' |
| 7 | * STACK_INSTALL What should be installed (k8s, openstack, ...) |
| 8 | * STACK_TEST What should be tested (k8s, openstack, ...) |
| 9 | * |
| 10 | * STACK_TEMPLATE_URL URL to git repo with stack templates |
| 11 | * STACK_TEMPLATE_BRANCH Stack templates repo branch |
| 12 | * STACK_TEMPLATE_CREDENTIALS Credentials to the stack templates repo |
| 13 | * STACK_TEMPLATE Heat stack HOT template |
| 14 | * STACK_DELETE Delete stack when finished (bool) |
| 15 | * STACK_REUSE Reuse stack (don't create one) |
| 16 | * STACK_CLEANUP_JOB Name of job for deleting Heat stack |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 17 | * |
| 18 | * Expected parameters: |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 19 | * required for STACK_TYPE=heat |
Matthew Mosesohn | 59fc648 | 2017-06-01 18:53:10 +0300 | [diff] [blame] | 20 | * HEAT_STACK_ENVIRONMENT Heat stack environmental parameters |
| 21 | * HEAT_STACK_ZONE Heat stack availability zone |
| 22 | * HEAT_STACK_PUBLIC_NET Heat stack floating IP pool |
| 23 | * OPENSTACK_API_URL OpenStack API address |
| 24 | * OPENSTACK_API_CREDENTIALS Credentials to the OpenStack API |
| 25 | * OPENSTACK_API_PROJECT OpenStack project to connect to |
| 26 | * OPENSTACK_API_PROJECT_DOMAIN Domain for OpenStack project |
| 27 | * OPENSTACK_API_PROJECT_ID ID for OpenStack project |
| 28 | * OPENSTACK_API_USER_DOMAIN Domain for OpenStack user |
| 29 | * OPENSTACK_API_CLIENT Versions of OpenStack python clients |
| 30 | * OPENSTACK_API_VERSION Version of the OpenStack API (2/3) |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 31 | * |
| 32 | * SALT_MASTER_CREDENTIALS Credentials to the Salt API |
| 33 | * |
| 34 | * required for STACK_TYPE=NONE or empty string |
| 35 | * SALT_MASTER_URL URL of Salt-API |
| 36 | |
| 37 | * K8S_API_SERVER Kubernetes API address |
| 38 | * K8S_CONFORMANCE_IMAGE Path to docker image with conformance e2e tests |
| 39 | * |
Victor Ryzhenkin | 5f3b7e6 | 2017-03-09 16:02:58 +0400 | [diff] [blame] | 40 | * TEMPEST_IMAGE_LINK Tempest image link |
| 41 | * |
Matthew Mosesohn | a85f24e | 2017-04-28 13:45:19 +0300 | [diff] [blame] | 42 | * optional parameters for overwriting soft params |
Matthew Mosesohn | 1393344 | 2017-07-04 21:20:08 +0300 | [diff] [blame] | 43 | * SALT_OVERRIDES YAML with overrides for Salt deployment |
Matthew Mosesohn | a85f24e | 2017-04-28 13:45:19 +0300 | [diff] [blame] | 44 | * KUBERNETES_HYPERKUBE_IMAGE Docker repository and tag for hyperkube image |
Matthew Mosesohn | d00a8f5 | 2017-05-22 17:07:19 +0300 | [diff] [blame] | 45 | * CALICO_CNI_IMAGE Docker repository and tag for calico CNI image |
| 46 | * CALICO_NODE_IMAGE Docker repository and tag for calico node image |
| 47 | * CALICOCTL_IMAGE Docker repository and tag for calicoctl image |
Matthew Mosesohn | 21a0e8e | 2017-06-06 16:35:08 +0300 | [diff] [blame] | 48 | * MTU MTU for Calico |
Matthew Mosesohn | 3f2e10a | 2017-05-24 17:25:37 +0300 | [diff] [blame] | 49 | * NETCHECKER_AGENT_IMAGE Docker repository and tag for netchecker agent image |
Matthew Mosesohn | 21a0e8e | 2017-06-06 16:35:08 +0300 | [diff] [blame] | 50 | * NETCHECKER_SERVER_IMAGE Docker repository and tag for netchecker server image |
Matthew Mosesohn | a85f24e | 2017-04-28 13:45:19 +0300 | [diff] [blame] | 51 | * |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 52 | */ |
| 53 | |
Tomáš Kukrál | 1f8b501 | 2017-04-28 21:07:10 +0200 | [diff] [blame] | 54 | common = new com.mirantis.mk.Common() |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 55 | git = new com.mirantis.mk.Git() |
| 56 | openstack = new com.mirantis.mk.Openstack() |
Tomáš Kukrál | 1f8b501 | 2017-04-28 21:07:10 +0200 | [diff] [blame] | 57 | orchestrate = new com.mirantis.mk.Orchestrate() |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 58 | salt = new com.mirantis.mk.Salt() |
Ondrej Smola | 8f35e48 | 2017-03-30 14:04:36 +0200 | [diff] [blame] | 59 | test = new com.mirantis.mk.Test() |
Tomáš Kukrál | 1f8b501 | 2017-04-28 21:07:10 +0200 | [diff] [blame] | 60 | |
Tomáš Kukrál | ab2f370 | 2017-05-11 09:17:43 +0200 | [diff] [blame] | 61 | _MAX_PERMITTED_STACKS = 2 |
Tomáš Kukrál | e80680a | 2017-03-02 16:34:35 +0100 | [diff] [blame] | 62 | |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 63 | timestamps { |
| 64 | node { |
Jakub Josef | 96ec3aa | 2017-05-29 17:53:56 +0200 | [diff] [blame] | 65 | // try to get STACK_INSTALL or fallback to INSTALL if exists |
| 66 | try { |
| 67 | def temporary = STACK_INSTALL |
| 68 | } catch (MissingPropertyException e) { |
| 69 | try { |
| 70 | STACK_INSTALL = INSTALL |
| 71 | env['STACK_INSTALL'] = INSTALL |
| 72 | } catch (MissingPropertyException e2) { |
| 73 | common.errorMsg("Property STACK_INSTALL or INSTALL not found!") |
| 74 | } |
| 75 | } |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 76 | try { |
| 77 | // |
| 78 | // Prepare machines |
| 79 | // |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 80 | stage ('Create infrastructure') { |
Tomáš Kukrál | 6d627d6 | 2017-03-23 17:39:07 +0100 | [diff] [blame] | 81 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 82 | if (STACK_TYPE == 'heat') { |
| 83 | // value defaults |
| 84 | def openstackCloud |
| 85 | def openstackVersion = OPENSTACK_API_CLIENT ? OPENSTACK_API_CLIENT : 'liberty' |
| 86 | def openstackEnv = "${env.WORKSPACE}/venv" |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 87 | |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 88 | if (STACK_REUSE.toBoolean() == true && STACK_NAME == '') { |
Filip Pytloun | 794ad95 | 2017-03-03 10:39:26 +0100 | [diff] [blame] | 89 | error("If you want to reuse existing stack you need to provide it's name") |
| 90 | } |
| 91 | |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 92 | if (STACK_REUSE.toBoolean() == false) { |
Filip Pytloun | 794ad95 | 2017-03-03 10:39:26 +0100 | [diff] [blame] | 93 | // Don't allow to set custom heat stack name |
| 94 | wrap([$class: 'BuildUser']) { |
Tomáš Kukrál | 24d7fe6 | 2017-03-03 10:57:11 +0100 | [diff] [blame] | 95 | if (env.BUILD_USER_ID) { |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 96 | STACK_NAME = "${env.BUILD_USER_ID}-${JOB_NAME}-${BUILD_NUMBER}" |
Tomáš Kukrál | 24d7fe6 | 2017-03-03 10:57:11 +0100 | [diff] [blame] | 97 | } else { |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 98 | STACK_NAME = "jenkins-${JOB_NAME}-${BUILD_NUMBER}" |
Tomáš Kukrál | 24d7fe6 | 2017-03-03 10:57:11 +0100 | [diff] [blame] | 99 | } |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 100 | currentBuild.description = STACK_NAME |
Filip Pytloun | 794ad95 | 2017-03-03 10:39:26 +0100 | [diff] [blame] | 101 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 102 | } |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 103 | |
Tomáš Kukrál | cbabec4 | 2017-03-02 16:24:04 +0100 | [diff] [blame] | 104 | // set description |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 105 | currentBuild.description = "${STACK_NAME}" |
Tomáš Kukrál | cbabec4 | 2017-03-02 16:24:04 +0100 | [diff] [blame] | 106 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 107 | // get templates |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 108 | git.checkoutGitRepository('template', STACK_TEMPLATE_URL, STACK_TEMPLATE_BRANCH, STACK_TEMPLATE_CREDENTIALS) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 109 | |
| 110 | // create openstack env |
| 111 | openstack.setupOpenstackVirtualenv(openstackEnv, openstackVersion) |
Matthew Mosesohn | bd7976b | 2017-05-29 19:35:44 +0300 | [diff] [blame] | 112 | openstackCloud = openstack.createOpenstackEnv( |
| 113 | OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS, |
Matthew Mosesohn | 59fc648 | 2017-06-01 18:53:10 +0300 | [diff] [blame] | 114 | OPENSTACK_API_PROJECT, OPENSTACK_API_PROJECT_DOMAIN, |
| 115 | OPENSTACK_API_PROJECT_ID, OPENSTACK_API_USER_DOMAIN, |
Matthew Mosesohn | bd7976b | 2017-05-29 19:35:44 +0300 | [diff] [blame] | 116 | OPENSTACK_API_VERSION) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 117 | openstack.getKeystoneToken(openstackCloud, openstackEnv) |
Jakub Josef | 458913d | 2017-05-10 15:37:56 +0200 | [diff] [blame] | 118 | // |
| 119 | // Verify possibility of create stack for given user and stack type |
| 120 | // |
| 121 | wrap([$class: 'BuildUser']) { |
chnyda | f23f46b | 2017-06-05 14:54:27 +0200 | [diff] [blame] | 122 | if (env.BUILD_USER_ID && !env.BUILD_USER_ID.equals("jenkins") && !env.BUILD_USER_ID.equals("mceloud") && !STACK_REUSE.toBoolean()) { |
Jakub Josef | 78c3f8b | 2017-05-10 15:45:29 +0200 | [diff] [blame] | 123 | def existingStacks = openstack.getStacksForNameContains(openstackCloud, "${env.BUILD_USER_ID}-${JOB_NAME}", openstackEnv) |
| 124 | if(existingStacks.size() >= _MAX_PERMITTED_STACKS){ |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 125 | STACK_DELETE = "false" |
Jakub Josef | 78c3f8b | 2017-05-10 15:45:29 +0200 | [diff] [blame] | 126 | throw new Exception("You cannot create new stack, you already have ${_MAX_PERMITTED_STACKS} stacks of this type (${JOB_NAME}). \nStack names: ${existingStacks}") |
| 127 | } |
Jakub Josef | 458913d | 2017-05-10 15:37:56 +0200 | [diff] [blame] | 128 | } |
| 129 | } |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 130 | // launch stack |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 131 | if (STACK_REUSE.toBoolean() == false) { |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 132 | stage('Launch new Heat stack') { |
| 133 | // create stack |
| 134 | envParams = [ |
| 135 | 'instance_zone': HEAT_STACK_ZONE, |
| 136 | 'public_net': HEAT_STACK_PUBLIC_NET |
| 137 | ] |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 138 | openstack.createHeatStack(openstackCloud, STACK_NAME, STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, openstackEnv) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 139 | } |
| 140 | } |
| 141 | |
| 142 | // get SALT_MASTER_URL |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 143 | saltMasterHost = openstack.getHeatStackOutputParam(openstackCloud, STACK_NAME, 'salt_master_ip', openstackEnv) |
| 144 | currentBuild.description = "${STACK_NAME}: ${saltMasterHost}" |
Tomáš Kukrál | 615aa9c | 2017-03-04 15:29:08 +0100 | [diff] [blame] | 145 | |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 146 | SALT_MASTER_URL = "http://${saltMasterHost}:6969" |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 147 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 148 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 149 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 150 | // |
| 151 | // Connect to Salt master |
| 152 | // |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 153 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 154 | def saltMaster |
| 155 | stage('Connect to Salt API') { |
| 156 | saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS) |
| 157 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 158 | |
Matthew Mosesohn | 1393344 | 2017-07-04 21:20:08 +0300 | [diff] [blame] | 159 | // Set up override params |
| 160 | if (env.getEnvironment().containsKey('SALT_OVERRIDES')) { |
| 161 | stage('Set Salt overrides') { |
| 162 | salt.setSaltOverrides(saltMaster, SALT_OVERRIDES) |
| 163 | } |
| 164 | } |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 165 | // |
| 166 | // Install |
| 167 | // |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 168 | |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 169 | if (common.checkContains('STACK_INSTALL', 'core')) { |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 170 | stage('Install core infrastructure') { |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 171 | orchestrate.installFoundationInfra(saltMaster) |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 172 | |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 173 | if (common.checkContains('STACK_INSTALL', 'kvm')) { |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 174 | orchestrate.installInfraKvm(saltMaster) |
| 175 | orchestrate.installFoundationInfra(saltMaster) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 176 | } |
| 177 | |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 178 | orchestrate.validateFoundationInfra(saltMaster) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 179 | } |
| 180 | } |
| 181 | |
| 182 | // install k8s |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 183 | if (common.checkContains('STACK_INSTALL', 'k8s')) { |
vrovachev | 48ea862 | 2017-06-28 10:28:56 +0400 | [diff] [blame] | 184 | |
Matthew Mosesohn | 1393344 | 2017-07-04 21:20:08 +0300 | [diff] [blame] | 185 | // Deprecated stage. Use SALT_OVERRIDES instead. |
vrovachev | 48ea862 | 2017-06-28 10:28:56 +0400 | [diff] [blame] | 186 | stage('Overwrite Kubernetes parameters') { |
| 187 | |
| 188 | // Overwrite Kubernetes vars if specified |
| 189 | if (env.getEnvironment().containsKey('KUBERNETES_HYPERKUBE_IMAGE')) { |
| 190 | salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_hyperkube_image', KUBERNETES_HYPERKUBE_IMAGE]) |
| 191 | } |
| 192 | if (env.getEnvironment().containsKey('MTU')) { |
| 193 | salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_mtu', MTU]) |
| 194 | } |
| 195 | |
| 196 | // Overwrite Calico vars if specified |
| 197 | if (env.getEnvironment().containsKey('CALICO_CNI_IMAGE')) { |
| 198 | salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_calico_cni_image', CALICO_CNI_IMAGE]) |
| 199 | } |
| 200 | if (env.getEnvironment().containsKey('CALICO_NODE_IMAGE')) { |
| 201 | salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_calico_image', CALICO_NODE_IMAGE]) |
| 202 | } |
| 203 | if (env.getEnvironment().containsKey('CALICOCTL_IMAGE')) { |
| 204 | salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_calicoctl_image', CALICOCTL_IMAGE]) |
| 205 | } |
| 206 | if (env.getEnvironment().containsKey('CALICO_POLICY_IMAGE')) { |
| 207 | salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_calico_policy_image', CALICO_POLICY_IMAGE]) |
| 208 | } |
| 209 | |
| 210 | // Overwrite Virtlet image if specified |
| 211 | if (env.getEnvironment().containsKey('VIRTLET_IMAGE')) { |
| 212 | salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_virtlet_image', VIRTLET_IMAGE]) |
| 213 | } |
| 214 | |
| 215 | // Overwrite netchecker vars if specified |
| 216 | if (env.getEnvironment().containsKey('NETCHECKER_AGENT_IMAGE')) { |
| 217 | salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_netchecker_agent_image', NETCHECKER_AGENT_IMAGE]) |
| 218 | } |
| 219 | if (env.getEnvironment().containsKey('NETCHECKER_SERVER_IMAGE')) { |
| 220 | salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_netchecker_server_image', NETCHECKER_SERVER_IMAGE]) |
| 221 | } |
| 222 | |
| 223 | // Overwrite docker version if specified |
| 224 | if (env.getEnvironment().containsKey('DOCKER_ENGINE')) { |
| 225 | salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_docker_package', DOCKER_ENGINE]) |
| 226 | } |
| 227 | |
| 228 | // Overwrite addons vars if specified |
| 229 | if (env.getEnvironment().containsKey('HELM_ENABLED')) { |
| 230 | salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_helm_enabled', HELM_ENABLED]) |
| 231 | } |
| 232 | if (env.getEnvironment().containsKey('NETCHECKER_ENABLED')) { |
| 233 | salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_netchecker_enabled', NETCHECKER_ENABLED]) |
| 234 | } |
| 235 | if (env.getEnvironment().containsKey('CALICO_POLICY_ENABLED')) { |
| 236 | salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_calico_policy_enabled', CALICO_POLICY_ENABLED]) |
| 237 | } |
| 238 | if (env.getEnvironment().containsKey('VIRTLET_ENABLED')) { |
| 239 | salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_virtlet_enabled', VIRTLET_ENABLED]) |
| 240 | } |
| 241 | if (env.getEnvironment().containsKey('KUBE_NET_MANAGER_ENABLED')) { |
| 242 | salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_kube_network_manager_enabled', KUBE_NET_MANAGER_ENABLED]) |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | // If k8s install with contrail network manager then contrail need to be install first |
| 247 | if (common.checkContains('STACK_INSTALL', 'contrail')) { |
| 248 | stage('Install Contrail for Kubernetes') { |
| 249 | orchestrate.installContrailNetwork(saltMaster) |
| 250 | orchestrate.installContrailCompute(saltMaster) |
| 251 | orchestrate.installKubernetesContrailCompute(saltMaster) |
| 252 | } |
| 253 | } |
| 254 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 255 | stage('Install Kubernetes infra') { |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 256 | orchestrate.installKubernetesInfra(saltMaster) |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 257 | } |
| 258 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 259 | stage('Install Kubernetes control') { |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 260 | orchestrate.installKubernetesControl(saltMaster) |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 261 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 262 | } |
| 263 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 264 | // install openstack |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 265 | if (common.checkContains('STACK_INSTALL', 'openstack')) { |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 266 | // install Infra and control, tests, ... |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 267 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 268 | stage('Install OpenStack infra') { |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 269 | orchestrate.installOpenstackInfra(saltMaster) |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 270 | } |
| 271 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 272 | stage('Install OpenStack control') { |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 273 | orchestrate.installOpenstackControl(saltMaster) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | stage('Install OpenStack network') { |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 277 | |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 278 | if (common.checkContains('STACK_INSTALL', 'contrail')) { |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 279 | orchestrate.installContrailNetwork(saltMaster) |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 280 | } else if (common.checkContains('STACK_INSTALL', 'ovs')) { |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 281 | orchestrate.installOpenstackNetwork(saltMaster) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 282 | } |
| 283 | |
Tomáš Kukrál | fbb9832 | 2017-05-02 10:38:05 +0200 | [diff] [blame] | 284 | salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron net-list']) |
| 285 | salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova net-list']) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | stage('Install OpenStack compute') { |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 289 | orchestrate.installOpenstackCompute(saltMaster) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 290 | |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 291 | if (common.checkContains('STACK_INSTALL', 'contrail')) { |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 292 | orchestrate.installContrailCompute(saltMaster) |
Tomáš Kukrál | d5a40af | 2017-03-07 15:34:58 +0100 | [diff] [blame] | 293 | } |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 294 | } |
Tomáš Kukrál | 2b4c128 | 2017-03-03 17:25:26 +0100 | [diff] [blame] | 295 | |
Tomáš Kukrál | 00ed130 | 2017-03-03 17:38:40 +0100 | [diff] [blame] | 296 | } |
Tomáš Kukrál | 2b4c128 | 2017-03-03 17:25:26 +0100 | [diff] [blame] | 297 | |
Tomáš Kukrál | 00ed130 | 2017-03-03 17:38:40 +0100 | [diff] [blame] | 298 | |
Martin Polreich | bb6f575 | 2017-06-30 12:37:41 +0200 | [diff] [blame] | 299 | if (common.checkContains('STACK_INSTALL', 'sl-legacy')) { |
| 300 | stage('Install StackLight v1') { |
| 301 | orchestrate.installStacklightv1Control(saltMaster) |
| 302 | orchestrate.installStacklightv1Client(saltMaster) |
| 303 | } |
| 304 | } |
| 305 | |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 306 | if (common.checkContains('STACK_INSTALL', 'stacklight')) { |
Tomáš Kukrál | 2b4c128 | 2017-03-03 17:25:26 +0100 | [diff] [blame] | 307 | stage('Install StackLight') { |
Martin Polreich | bb6f575 | 2017-06-30 12:37:41 +0200 | [diff] [blame] | 308 | orchestrate.installDockerSwarm(saltMaster) |
| 309 | orchestrate.installStacklight(saltMaster) |
Tomáš Kukrál | 2b4c128 | 2017-03-03 17:25:26 +0100 | [diff] [blame] | 310 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 311 | } |
| 312 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 313 | // |
| 314 | // Test |
| 315 | // |
Tomáš Kukrál | 695d646 | 2017-04-21 16:31:52 +0200 | [diff] [blame] | 316 | def artifacts_dir = '_artifacts/' |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 317 | |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 318 | if (common.checkContains('STACK_TEST', 'k8s')) { |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 319 | stage('Run k8s bootstrap tests') { |
Tomáš Kukrál | 695d646 | 2017-04-21 16:31:52 +0200 | [diff] [blame] | 320 | def image = 'tomkukral/k8s-scripts' |
Tomáš Kukrál | 44ca7fe | 2017-04-21 16:44:19 +0200 | [diff] [blame] | 321 | def output_file = image.replaceAll('/', '-') + '.output' |
Tomáš Kukrál | 695d646 | 2017-04-21 16:31:52 +0200 | [diff] [blame] | 322 | |
Tomáš Kukrál | b22826d | 2017-04-21 16:38:00 +0200 | [diff] [blame] | 323 | // run image |
| 324 | test.runConformanceTests(saltMaster, K8S_API_SERVER, image) |
Tomáš Kukrál | f56beed | 2017-04-21 16:21:06 +0200 | [diff] [blame] | 325 | |
| 326 | // collect output |
Tomáš Kukrál | f56beed | 2017-04-21 16:21:06 +0200 | [diff] [blame] | 327 | sh "mkdir -p ${artifacts_dir}" |
Tomáš Kukrál | b22826d | 2017-04-21 16:38:00 +0200 | [diff] [blame] | 328 | file_content = salt.getFileContent(saltMaster, 'ctl01*', '/tmp/' + output_file) |
Tomáš Kukrál | f56beed | 2017-04-21 16:21:06 +0200 | [diff] [blame] | 329 | writeFile file: "${artifacts_dir}${output_file}", text: file_content |
Tomáš Kukrál | f56beed | 2017-04-21 16:21:06 +0200 | [diff] [blame] | 330 | sh "cat ${artifacts_dir}${output_file}" |
| 331 | |
| 332 | // collect artifacts |
| 333 | archiveArtifacts artifacts: "${artifacts_dir}${output_file}" |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 334 | } |
| 335 | |
Tomáš Kukrál | b22826d | 2017-04-21 16:38:00 +0200 | [diff] [blame] | 336 | stage('Run k8s conformance e2e tests') { |
| 337 | //test.runConformanceTests(saltMaster, K8S_API_SERVER, K8S_CONFORMANCE_IMAGE) |
| 338 | |
| 339 | def image = K8S_CONFORMANCE_IMAGE |
Tomáš Kukrál | 44ca7fe | 2017-04-21 16:44:19 +0200 | [diff] [blame] | 340 | def output_file = image.replaceAll('/', '-') + '.output' |
Tomáš Kukrál | b22826d | 2017-04-21 16:38:00 +0200 | [diff] [blame] | 341 | |
| 342 | // run image |
| 343 | test.runConformanceTests(saltMaster, K8S_API_SERVER, image) |
| 344 | |
| 345 | // collect output |
| 346 | sh "mkdir -p ${artifacts_dir}" |
| 347 | file_content = salt.getFileContent(saltMaster, 'ctl01*', '/tmp/' + output_file) |
| 348 | writeFile file: "${artifacts_dir}${output_file}", text: file_content |
| 349 | sh "cat ${artifacts_dir}${output_file}" |
| 350 | |
| 351 | // collect artifacts |
| 352 | archiveArtifacts artifacts: "${artifacts_dir}${output_file}" |
| 353 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 354 | } |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 355 | |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 356 | if (common.checkContains('STACK_TEST', 'openstack')) { |
Victor Ryzhenkin | 5f3b7e6 | 2017-03-09 16:02:58 +0400 | [diff] [blame] | 357 | stage('Run OpenStack tests') { |
| 358 | test.runTempestTests(saltMaster, TEMPEST_IMAGE_LINK) |
| 359 | } |
| 360 | |
| 361 | stage('Copy Tempest results to config node') { |
| 362 | test.copyTempestResults(saltMaster) |
| 363 | } |
| 364 | } |
| 365 | |
Tomáš Kukrál | 420d7ff | 2017-03-21 11:38:33 +0100 | [diff] [blame] | 366 | stage('Finalize') { |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 367 | if (STACK_INSTALL != '') { |
Tomáš Kukrál | 38ab6bb | 2017-04-21 21:29:31 +0200 | [diff] [blame] | 368 | try { |
| 369 | salt.runSaltProcessStep(saltMaster, '*', 'state.apply', [], null, true) |
| 370 | } catch (Exception e) { |
| 371 | common.warningMsg('State apply failed but we should continue to run') |
Jakub Josef | a6904f1 | 2017-05-22 16:37:27 +0200 | [diff] [blame] | 372 | throw e |
Tomáš Kukrál | 38ab6bb | 2017-04-21 21:29:31 +0200 | [diff] [blame] | 373 | } |
Tomáš Kukrál | 420d7ff | 2017-03-21 11:38:33 +0100 | [diff] [blame] | 374 | } |
| 375 | } |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 376 | } catch (Throwable e) { |
| 377 | currentBuild.result = 'FAILURE' |
| 378 | throw e |
Tomáš Kukrál | 65fb5fd | 2017-03-02 14:56:49 +0100 | [diff] [blame] | 379 | } finally { |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 380 | |
Tomáš Kukrál | 96b12d5 | 2017-03-07 22:43:37 +0100 | [diff] [blame] | 381 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 382 | // |
| 383 | // Clean |
| 384 | // |
| 385 | |
Tomáš Kukrál | c9a630a | 2017-03-07 17:28:53 +0100 | [diff] [blame] | 386 | if (STACK_TYPE == 'heat') { |
Tomáš Kukrál | 4507c6a | 2017-03-23 19:00:39 +0100 | [diff] [blame] | 387 | // send notification |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 388 | common.sendNotification(currentBuild.result, STACK_NAME, ["slack"]) |
Tomáš Kukrál | 4507c6a | 2017-03-23 19:00:39 +0100 | [diff] [blame] | 389 | |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 390 | if (STACK_DELETE.toBoolean() == true) { |
Tomáš Kukrál | c9a630a | 2017-03-07 17:28:53 +0100 | [diff] [blame] | 391 | common.errorMsg('Heat job cleanup triggered') |
| 392 | stage('Trigger cleanup job') { |
Tomáš Kukrál | ea07992 | 2017-06-22 09:12:15 +0200 | [diff] [blame] | 393 | build(job: STACK_CLEANUP_JOB, parameters: [ |
| 394 | [$class: 'StringParameterValue', name: 'STACK_NAME', value: STACK_NAME], |
| 395 | [$class: 'StringParameterValue', name: 'STACK_TYPE', value: STACK_TYPE], |
| 396 | [$class: 'StringParameterValue', name: 'OPENSTACK_API_URL', value: OPENSTACK_API_URL], |
| 397 | [$class: 'StringParameterValue', name: 'OPENSTACK_API_CREDENTIALS', value: OPENSTACK_API_CREDENTIALS], |
| 398 | [$class: 'StringParameterValue', name: 'OPENSTACK_API_PROJECT', value: OPENSTACK_API_PROJECT], |
| 399 | [$class: 'StringParameterValue', name: 'OPENSTACK_API_PROJECT_DOMAIN', value: OPENSTACK_API_PROJECT_DOMAIN], |
| 400 | [$class: 'StringParameterValue', name: 'OPENSTACK_API_PROJECT_ID', value: OPENSTACK_API_PROJECT_ID], |
| 401 | [$class: 'StringParameterValue', name: 'OPENSTACK_API_USER_DOMAIN', value: OPENSTACK_API_USER_DOMAIN], |
| 402 | [$class: 'StringParameterValue', name: 'OPENSTACK_API_CLIENT', value: OPENSTACK_API_CLIENT], |
| 403 | [$class: 'StringParameterValue', name: 'OPENSTACK_API_VERSION', value: OPENSTACK_API_VERSION] |
| 404 | ]) |
Tomáš Kukrál | c9a630a | 2017-03-07 17:28:53 +0100 | [diff] [blame] | 405 | } |
| 406 | } else { |
Tomáš Kukrál | bcc53ea | 2017-03-08 08:15:57 +0100 | [diff] [blame] | 407 | if (currentBuild.result == 'FAILURE') { |
| 408 | common.errorMsg("Deploy job FAILED and was not deleted. Please fix the problem and delete stack on you own.") |
Tomáš Kukrál | c9a630a | 2017-03-07 17:28:53 +0100 | [diff] [blame] | 409 | |
Tomáš Kukrál | bcc53ea | 2017-03-08 08:15:57 +0100 | [diff] [blame] | 410 | if (SALT_MASTER_URL) { |
| 411 | common.errorMsg("Salt master URL: ${SALT_MASTER_URL}") |
| 412 | } |
Tomáš Kukrál | b908dac | 2017-03-07 18:58:35 +0100 | [diff] [blame] | 413 | } |
| 414 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 415 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 416 | } |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 417 | } |
| 418 | } |
| 419 | } |