blob: a5f2eb4b1bdce69469d07d0076df384af23771c0 [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 *
Tomáš Kukráld92ab802017-02-17 11:34:07 +010029 * INSTALL What should be installed (k8s, openstack, ...)
30 * TESTS Run tests (bool)
Tomáš Kukrál5a343902017-02-16 11:01:11 +010031 */
32
Tomáš Kukrálffd93972017-02-20 14:23:55 +010033git = new com.mirantis.mk.Git()
34openstack = new com.mirantis.mk.Openstack()
35salt = new com.mirantis.mk.Salt()
36orchestrate = new com.mirantis.mk.Orchestrate()
Tatyana Leontovichebee21c2017-02-28 15:06:17 +020037test = new com.mirantis.mk.Test()
Tomáš Kukrál5a343902017-02-16 11:01:11 +010038
39node {
40
41 // connection objects
42 def openstackCloud
43 def saltMaster
44
45 // value defaults
Tomáš Kukráld92ab802017-02-17 11:34:07 +010046 def openstackVersion = OPENSTACK_API_CLIENT ? OPENSTACK_API_CLIENT : 'liberty'
Tomáš Kukrál5a343902017-02-16 11:01:11 +010047 def openstackEnv = "${env.WORKSPACE}/venv"
48
Tomáš Kukráld92ab802017-02-17 11:34:07 +010049 if (HEAT_STACK_NAME == '') {
Tomáš Kukrál5a343902017-02-16 11:01:11 +010050 HEAT_STACK_NAME = BUILD_TAG
51 }
52
Tomáš Kukráld92ab802017-02-17 11:34:07 +010053 //
54 // Bootstrap
55 //
56
Tomáš Kukrál5a343902017-02-16 11:01:11 +010057 stage ('Download Heat templates') {
58 git.checkoutGitRepository('template', HEAT_TEMPLATE_URL, HEAT_TEMPLATE_BRANCH, HEAT_TEMPLATE_CREDENTIALS)
59 }
60
Tomáš Kukrál75467092017-02-16 19:48:05 +010061 stage('Install OpenStack CLI') {
Tomáš Kukrál5a343902017-02-16 11:01:11 +010062 openstack.setupOpenstackVirtualenv(openstackEnv, openstackVersion)
63 }
64
65 stage('Connect to OpenStack cloud') {
66 openstackCloud = openstack.createOpenstackEnv(OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS, OPENSTACK_API_PROJECT)
67 openstack.getKeystoneToken(openstackCloud, openstackEnv)
68 }
69
Tomáš Kukrál7170d7d2017-02-21 13:11:48 +010070 if (HEAT_STACK_REUSE == 'false') {
71 stage('Launch new Heat stack') {
Tomas Kukral09f6df02017-02-23 09:38:02 +000072 envParams = [
Tomáš Kukrál843b1c12017-02-23 11:37:05 +010073 'instance_zone': HEAT_STACK_ZONE,
Tomas Kukral09f6df02017-02-23 09:38:02 +000074 'public_net': HEAT_STACK_PUBLIC_NET
75 ]
Tomáš Kukrál7170d7d2017-02-21 13:11:48 +010076 openstack.createHeatStack(openstackCloud, HEAT_STACK_NAME, HEAT_STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, openstackEnv)
77 }
Tomáš Kukrál5a343902017-02-16 11:01:11 +010078 }
79
Tomáš Kukráld92ab802017-02-17 11:34:07 +010080 stage('Connect to Salt master') {
Tomáš Kukrál5a343902017-02-16 11:01:11 +010081 saltMasterHost = openstack.getHeatStackOutputParam(openstackCloud, HEAT_STACK_NAME, 'salt_master_ip', openstackEnv)
Tomáš Kukrál4b5f1242017-02-16 19:15:02 +010082 saltMasterUrl = "http://${saltMasterHost}:8088"
Tomáš Kukrálffd93972017-02-20 14:23:55 +010083 saltMaster = salt.connection(saltMasterUrl, SALT_MASTER_CREDENTIALS)
Tomáš Kukrál5a343902017-02-16 11:01:11 +010084 }
85
Tomáš Kukráld92ab802017-02-17 11:34:07 +010086 //
87 // Install
88 //
89
90 stage('Install core infra') {
Tomáš Kukrál5a343902017-02-16 11:01:11 +010091 // salt.master, reclass
92 // refresh_pillar
93 // sync_all
94 // linux,openssh,salt.minion.ntp
95
Tomáš Kukrálffd93972017-02-20 14:23:55 +010096 orchestrate.installFoundationInfra(saltMaster)
97 orchestrate.validateFoundationInfra(saltMaster)
Tomáš Kukrál5a343902017-02-16 11:01:11 +010098 }
99
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100100
101 if (INSTALL.toLowerCase().contains('k8s')) {
102 stage('Install Kubernetes infra') {
Tomáš Kukrálffd93972017-02-20 14:23:55 +0100103 orchestrate.installOpenstackMcpInfra(saltMaster)
Tomáš Kukrál5a343902017-02-16 11:01:11 +0100104 }
105
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100106 stage('Install Kubernetes control') {
Tomáš Kukrálffd93972017-02-20 14:23:55 +0100107 orchestrate.installOpenstackMcpControl(saltMaster)
Tomáš Kukrál5a343902017-02-16 11:01:11 +0100108 }
109
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100110 if (TESTS.toLowerCase().contains('k8s')) {
Tomáš Kukrál490d9752017-02-19 19:23:20 +0100111 stage('Run k8s bootstrap tests') {
Tatyana Leontovichebee21c2017-02-28 15:06:17 +0200112 test.runConformanceTests(saltMaster, K8S_API_SERVER, 'tomkukral/k8s-scripts')
Tomáš Kukrál490d9752017-02-19 19:23:20 +0100113 }
114
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100115 stage('Run k8s conformance e2e tests') {
Tatyana Leontovichebee21c2017-02-28 15:06:17 +0200116 test.runConformanceTests(saltMaster, K8S_API_SERVER, K8S_CONFORMANCE_IMAGE)
117 }
118
119 stage("Copy k8s e2e test output to config node ") {
120 test.copyTestsOutput(saltMaster,K8S_CONFORMANCE_IMAGE)
Tomáš Kukrál5a343902017-02-16 11:01:11 +0100121 }
122 }
123 }
124
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100125 if (INSTALL.toLowerCase().contains('openstack')) {
Tomáš Kukrál22a65002017-02-16 15:06:43 +0100126 // install Infra and control, tests, ...
127
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100128 stage('Install OpenStack infra') {
Tomáš Kukrálffd93972017-02-20 14:23:55 +0100129 orchestrate.installOpenstackMkInfra(saltMaster)
Tomáš Kukrál22a65002017-02-16 15:06:43 +0100130 }
131
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100132 stage('Install OpenStack control') {
Tomáš Kukrálffd93972017-02-20 14:23:55 +0100133 orchestrate.installOpenstackMkControl(saltMaster)
Tomáš Kukrál22a65002017-02-16 15:06:43 +0100134 }
135
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100136 stage('Install OpenStack network') {
Tomáš Kukrálffd93972017-02-20 14:23:55 +0100137 orchestrate.installOpenstackMkNetwork(saltMaster)
Tomáš Kukrál22a65002017-02-16 15:06:43 +0100138 }
139
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100140 stage('Install OpenStack compute') {
Tomáš Kukrálffd93972017-02-20 14:23:55 +0100141 orchestrate.installOpenstackMkCompute(saltMaster)
Tomáš Kukrál22a65002017-02-16 15:06:43 +0100142 }
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100143
144 //if (TESTS.toLowerCase().contains('openstack')) {
145 // stage('Run OpenStack tests') {
Tomáš Kukrálffd93972017-02-20 14:23:55 +0100146 // orchestrate...
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100147 // }
148 //}
Tomáš Kukrál22a65002017-02-16 15:06:43 +0100149 }
Tomáš Kukrál5a343902017-02-16 11:01:11 +0100150
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100151 //
152 // Cleanup
153 //
154
Tomáš Kukráladccdba2017-02-16 23:56:22 +0100155 if (HEAT_STACK_DELETE == 'true') {
Tomáš Kukrál5a343902017-02-16 11:01:11 +0100156 stage('Trigger cleanup job') {
Tomáš Kukrál22a65002017-02-16 15:06:43 +0100157 build job: 'deploy_heat_cleanup', parameters: [[$class: 'StringParameterValue', name: 'HEAT_STACK_NAME', value: HEAT_STACK_NAME]]
Tomáš Kukrál5a343902017-02-16 11:01:11 +0100158 }
159 }
Tomáš Kukrál5a343902017-02-16 11:01:11 +0100160}