blob: 9e9a28d173ab654ec8902f44c215b7a7701fbf17 [file] [log] [blame]
Tomáš Kukrál5a343902017-02-16 11:01:11 +01001/**
2 *
3 * Launch heat stack with basic k8s
4 *
5 * Expected parameters:
6 * HEAT_TEMPLATE_URL URL to git repo with Heat templates
7 * HEAT_TEMPLATE_CREDENTIALS Credentials to the Heat templates repo
8 * HEAT_TEMPLATE_BRANCH Heat templates repo branch
9 * HEAT_STACK_NAME Heat stack name
10 * HEAT_STACK_TEMPLATE Heat stack HOT template
11 * HEAT_STACK_ENVIRONMENT Heat stack environmental parameters
12 * HEAT_STACK_ZONE Heat stack availability zone
13 * HEAT_STACK_PUBLIC_NET Heat stack floating IP pool
14 * HEAT_STACK_DELETE Delete Heat stack when finished (bool)
15 * HEAT_STACK_CLEANUP_JOB Name of job for deleting Heat stack
Tomáš Kukrál7170d7d2017-02-21 13:11:48 +010016 * HEAT_STACK_REUSE Reuse Heat stack (don't create one)
Tomáš Kukrál5a343902017-02-16 11:01:11 +010017 *
18 * SALT_MASTER_CREDENTIALS Credentials to the Salt API
19 *
20 * OPENSTACK_API_URL OpenStack API address
21 * OPENSTACK_API_CREDENTIALS Credentials to the OpenStack API
22 * OPENSTACK_API_PROJECT OpenStack project to connect to
23 * OPENSTACK_API_CLIENT Versions of OpenStack python clients
24 * OPENSTACK_API_VERSION Version of the OpenStack API (2/3)
25 *
26 * K8S_API_SERVER Kubernetes API address
27 * K8S_CONFORMANCE_IMAGE Path to docker image with conformance e2e tests
Tomáš Kukrál5a343902017-02-16 11:01:11 +010028 *
Victor Ryzhenkin5f3b7e62017-03-09 16:02:58 +040029 * TEMPEST_IMAGE_LINK Tempest image link
30 *
Tomáš Kukráld92ab802017-02-17 11:34:07 +010031 * INSTALL What should be installed (k8s, openstack, ...)
32 * TESTS Run tests (bool)
Tomáš Kukrál5a343902017-02-16 11:01:11 +010033 */
34
Tomáš Kukrálffd93972017-02-20 14:23:55 +010035git = new com.mirantis.mk.Git()
36openstack = new com.mirantis.mk.Openstack()
37salt = new com.mirantis.mk.Salt()
38orchestrate = new com.mirantis.mk.Orchestrate()
Tatyana Leontovichebee21c2017-02-28 15:06:17 +020039test = new com.mirantis.mk.Test()
Tomáš Kukrál5a343902017-02-16 11:01:11 +010040
41node {
42
43 // connection objects
44 def openstackCloud
45 def saltMaster
46
47 // value defaults
Tomáš Kukráld92ab802017-02-17 11:34:07 +010048 def openstackVersion = OPENSTACK_API_CLIENT ? OPENSTACK_API_CLIENT : 'liberty'
Tomáš Kukrál5a343902017-02-16 11:01:11 +010049 def openstackEnv = "${env.WORKSPACE}/venv"
50
Tomáš Kukráld92ab802017-02-17 11:34:07 +010051 if (HEAT_STACK_NAME == '') {
Tomáš Kukrál5a343902017-02-16 11:01:11 +010052 HEAT_STACK_NAME = BUILD_TAG
53 }
54
Tomáš Kukráld92ab802017-02-17 11:34:07 +010055 //
56 // Bootstrap
57 //
58
Tomáš Kukrál5a343902017-02-16 11:01:11 +010059 stage ('Download Heat templates') {
60 git.checkoutGitRepository('template', HEAT_TEMPLATE_URL, HEAT_TEMPLATE_BRANCH, HEAT_TEMPLATE_CREDENTIALS)
61 }
62
Tomáš Kukrál75467092017-02-16 19:48:05 +010063 stage('Install OpenStack CLI') {
Tomáš Kukrál5a343902017-02-16 11:01:11 +010064 openstack.setupOpenstackVirtualenv(openstackEnv, openstackVersion)
65 }
66
67 stage('Connect to OpenStack cloud') {
68 openstackCloud = openstack.createOpenstackEnv(OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS, OPENSTACK_API_PROJECT)
69 openstack.getKeystoneToken(openstackCloud, openstackEnv)
70 }
71
Tomáš Kukrál7170d7d2017-02-21 13:11:48 +010072 if (HEAT_STACK_REUSE == 'false') {
73 stage('Launch new Heat stack') {
Tomas Kukral09f6df02017-02-23 09:38:02 +000074 envParams = [
Tomáš Kukrál843b1c12017-02-23 11:37:05 +010075 'instance_zone': HEAT_STACK_ZONE,
Tomas Kukral09f6df02017-02-23 09:38:02 +000076 'public_net': HEAT_STACK_PUBLIC_NET
77 ]
Tomáš Kukrál7170d7d2017-02-21 13:11:48 +010078 openstack.createHeatStack(openstackCloud, HEAT_STACK_NAME, HEAT_STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, openstackEnv)
79 }
Tomáš Kukrál5a343902017-02-16 11:01:11 +010080 }
81
Tomáš Kukráld92ab802017-02-17 11:34:07 +010082 stage('Connect to Salt master') {
Tomáš Kukrál5a343902017-02-16 11:01:11 +010083 saltMasterHost = openstack.getHeatStackOutputParam(openstackCloud, HEAT_STACK_NAME, 'salt_master_ip', openstackEnv)
Tomáš Kukrál4b5f1242017-02-16 19:15:02 +010084 saltMasterUrl = "http://${saltMasterHost}:8088"
Tomáš Kukrálffd93972017-02-20 14:23:55 +010085 saltMaster = salt.connection(saltMasterUrl, SALT_MASTER_CREDENTIALS)
Tomáš Kukrál5a343902017-02-16 11:01:11 +010086 }
87
Tomáš Kukráld92ab802017-02-17 11:34:07 +010088 //
89 // Install
90 //
91
92 stage('Install core infra') {
Tomáš Kukrál5a343902017-02-16 11:01:11 +010093 // salt.master, reclass
94 // refresh_pillar
95 // sync_all
96 // linux,openssh,salt.minion.ntp
97
Tomáš Kukrálffd93972017-02-20 14:23:55 +010098 orchestrate.installFoundationInfra(saltMaster)
99 orchestrate.validateFoundationInfra(saltMaster)
Tomáš Kukrál5a343902017-02-16 11:01:11 +0100100 }
101
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100102
103 if (INSTALL.toLowerCase().contains('k8s')) {
104 stage('Install Kubernetes infra') {
Tomáš Kukrálffd93972017-02-20 14:23:55 +0100105 orchestrate.installOpenstackMcpInfra(saltMaster)
Tomáš Kukrál5a343902017-02-16 11:01:11 +0100106 }
107
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100108 stage('Install Kubernetes control') {
Tomáš Kukrálffd93972017-02-20 14:23:55 +0100109 orchestrate.installOpenstackMcpControl(saltMaster)
Tomáš Kukrál5a343902017-02-16 11:01:11 +0100110 }
111
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100112 if (TESTS.toLowerCase().contains('k8s')) {
Tomáš Kukrál490d9752017-02-19 19:23:20 +0100113 stage('Run k8s bootstrap tests') {
Tatyana Leontovichebee21c2017-02-28 15:06:17 +0200114 test.runConformanceTests(saltMaster, K8S_API_SERVER, 'tomkukral/k8s-scripts')
Tomáš Kukrál490d9752017-02-19 19:23:20 +0100115 }
116
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100117 stage('Run k8s conformance e2e tests') {
Tatyana Leontovichebee21c2017-02-28 15:06:17 +0200118 test.runConformanceTests(saltMaster, K8S_API_SERVER, K8S_CONFORMANCE_IMAGE)
119 }
120
121 stage("Copy k8s e2e test output to config node ") {
122 test.copyTestsOutput(saltMaster,K8S_CONFORMANCE_IMAGE)
Tomáš Kukrál5a343902017-02-16 11:01:11 +0100123 }
124 }
125 }
126
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100127 if (INSTALL.toLowerCase().contains('openstack')) {
Tomáš Kukrál22a65002017-02-16 15:06:43 +0100128 // install Infra and control, tests, ...
129
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100130 stage('Install OpenStack infra') {
Tomáš Kukrálffd93972017-02-20 14:23:55 +0100131 orchestrate.installOpenstackMkInfra(saltMaster)
Tomáš Kukrál22a65002017-02-16 15:06:43 +0100132 }
133
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100134 stage('Install OpenStack control') {
Tomáš Kukrálffd93972017-02-20 14:23:55 +0100135 orchestrate.installOpenstackMkControl(saltMaster)
Tomáš Kukrál22a65002017-02-16 15:06:43 +0100136 }
137
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100138 stage('Install OpenStack network') {
Tomáš Kukrálffd93972017-02-20 14:23:55 +0100139 orchestrate.installOpenstackMkNetwork(saltMaster)
Tomáš Kukrál22a65002017-02-16 15:06:43 +0100140 }
141
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100142 stage('Install OpenStack compute') {
Tomáš Kukrálffd93972017-02-20 14:23:55 +0100143 orchestrate.installOpenstackMkCompute(saltMaster)
Tomáš Kukrál22a65002017-02-16 15:06:43 +0100144 }
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100145
Victor Ryzhenkin5f3b7e62017-03-09 16:02:58 +0400146 if (TESTS.toLowerCase().contains('openstack')) {
147 stage('Run OpenStack tests') {
148 test.runTempestTests(saltMaster, TEMPEST_IMAGE_LINK)
149 }
150
151 stage('Copy Tempest results to config node') {
152 test.copyTempestResults(saltMaster)
153 }
154 }
Tomáš Kukrál22a65002017-02-16 15:06:43 +0100155 }
Tomáš Kukrál5a343902017-02-16 11:01:11 +0100156
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100157 //
158 // Cleanup
159 //
160
Tomáš Kukráladccdba2017-02-16 23:56:22 +0100161 if (HEAT_STACK_DELETE == 'true') {
Tomáš Kukrál5a343902017-02-16 11:01:11 +0100162 stage('Trigger cleanup job') {
Tomáš Kukrál22a65002017-02-16 15:06:43 +0100163 build job: 'deploy_heat_cleanup', parameters: [[$class: 'StringParameterValue', name: 'HEAT_STACK_NAME', value: HEAT_STACK_NAME]]
Tomáš Kukrál5a343902017-02-16 11:01:11 +0100164 }
165 }
Tomáš Kukrál5a343902017-02-16 11:01:11 +0100166}