blob: 28d72b3e8db47d53ddd19cb31abf8207bce58423 [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()
Tomáš Kukrál5a343902017-02-16 11:01:11 +010037
38node {
39
40 // connection objects
41 def openstackCloud
42 def saltMaster
43
44 // value defaults
Tomáš Kukráld92ab802017-02-17 11:34:07 +010045 def openstackVersion = OPENSTACK_API_CLIENT ? OPENSTACK_API_CLIENT : 'liberty'
Tomáš Kukrál5a343902017-02-16 11:01:11 +010046 def openstackEnv = "${env.WORKSPACE}/venv"
47
Tomáš Kukráld92ab802017-02-17 11:34:07 +010048 if (HEAT_STACK_NAME == '') {
Tomáš Kukrál5a343902017-02-16 11:01:11 +010049 HEAT_STACK_NAME = BUILD_TAG
50 }
51
Tomáš Kukráld92ab802017-02-17 11:34:07 +010052 //
53 // Bootstrap
54 //
55
Tomáš Kukrál5a343902017-02-16 11:01:11 +010056 stage ('Download Heat templates') {
57 git.checkoutGitRepository('template', HEAT_TEMPLATE_URL, HEAT_TEMPLATE_BRANCH, HEAT_TEMPLATE_CREDENTIALS)
58 }
59
Tomáš Kukrál75467092017-02-16 19:48:05 +010060 stage('Install OpenStack CLI') {
Tomáš Kukrál5a343902017-02-16 11:01:11 +010061 openstack.setupOpenstackVirtualenv(openstackEnv, openstackVersion)
62 }
63
64 stage('Connect to OpenStack cloud') {
65 openstackCloud = openstack.createOpenstackEnv(OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS, OPENSTACK_API_PROJECT)
66 openstack.getKeystoneToken(openstackCloud, openstackEnv)
67 }
68
Tomáš Kukrál7170d7d2017-02-21 13:11:48 +010069 if (HEAT_STACK_REUSE == 'false') {
70 stage('Launch new Heat stack') {
71 envParams = [
72 'availability_zone': HEAT_STACK_ZONE,
73 'public_net': HEAT_STACK_PUBLIC_NET
74 ]
75 openstack.createHeatStack(openstackCloud, HEAT_STACK_NAME, HEAT_STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, openstackEnv)
76 }
Tomáš Kukrál5a343902017-02-16 11:01:11 +010077 }
78
Tomáš Kukráld92ab802017-02-17 11:34:07 +010079 stage('Connect to Salt master') {
Tomáš Kukrál5a343902017-02-16 11:01:11 +010080 saltMasterHost = openstack.getHeatStackOutputParam(openstackCloud, HEAT_STACK_NAME, 'salt_master_ip', openstackEnv)
Tomáš Kukrál4b5f1242017-02-16 19:15:02 +010081 saltMasterUrl = "http://${saltMasterHost}:8088"
Tomáš Kukrálffd93972017-02-20 14:23:55 +010082 saltMaster = salt.connection(saltMasterUrl, SALT_MASTER_CREDENTIALS)
Tomáš Kukrál5a343902017-02-16 11:01:11 +010083 }
84
Tomáš Kukráld92ab802017-02-17 11:34:07 +010085 //
86 // Install
87 //
88
89 stage('Install core infra') {
Tomáš Kukrál5a343902017-02-16 11:01:11 +010090 // salt.master, reclass
91 // refresh_pillar
92 // sync_all
93 // linux,openssh,salt.minion.ntp
94
Tomáš Kukrálffd93972017-02-20 14:23:55 +010095 orchestrate.installFoundationInfra(saltMaster)
96 orchestrate.validateFoundationInfra(saltMaster)
Tomáš Kukrál5a343902017-02-16 11:01:11 +010097 }
98
Tomáš Kukráld92ab802017-02-17 11:34:07 +010099
100 if (INSTALL.toLowerCase().contains('k8s')) {
101 stage('Install Kubernetes infra') {
Tomáš Kukrálffd93972017-02-20 14:23:55 +0100102 orchestrate.installOpenstackMcpInfra(saltMaster)
Tomáš Kukrál5a343902017-02-16 11:01:11 +0100103 }
104
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100105 stage('Install Kubernetes control') {
Tomáš Kukrálffd93972017-02-20 14:23:55 +0100106 orchestrate.installOpenstackMcpControl(saltMaster)
Tomáš Kukrál5a343902017-02-16 11:01:11 +0100107 }
108
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100109 if (TESTS.toLowerCase().contains('k8s')) {
Tomáš Kukrál490d9752017-02-19 19:23:20 +0100110 stage('Run k8s bootstrap tests') {
Tomáš Kukrálffd93972017-02-20 14:23:55 +0100111 orchestrate.runConformanceTests(saltMaster, K8S_API_SERVER, 'tomkukral/k8s-scripts')
Tomáš Kukrál490d9752017-02-19 19:23:20 +0100112 }
113
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100114 stage('Run k8s conformance e2e tests') {
Tomáš Kukrálffd93972017-02-20 14:23:55 +0100115 orchestrate.runConformanceTests(saltMaster, K8S_API_SERVER, K8S_CONFORMANCE_IMAGE)
Tomáš Kukrál5a343902017-02-16 11:01:11 +0100116 }
117 }
118 }
119
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100120 if (INSTALL.toLowerCase().contains('openstack')) {
Tomáš Kukrál22a65002017-02-16 15:06:43 +0100121 // install Infra and control, tests, ...
122
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100123 stage('Install OpenStack infra') {
Tomáš Kukrálffd93972017-02-20 14:23:55 +0100124 orchestrate.installOpenstackMkInfra(saltMaster)
Tomáš Kukrál22a65002017-02-16 15:06:43 +0100125 }
126
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100127 stage('Install OpenStack control') {
Tomáš Kukrálffd93972017-02-20 14:23:55 +0100128 orchestrate.installOpenstackMkControl(saltMaster)
Tomáš Kukrál22a65002017-02-16 15:06:43 +0100129 }
130
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100131 stage('Install OpenStack network') {
Tomáš Kukrálffd93972017-02-20 14:23:55 +0100132 orchestrate.installOpenstackMkNetwork(saltMaster)
Tomáš Kukrál22a65002017-02-16 15:06:43 +0100133 }
134
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100135 stage('Install OpenStack compute') {
Tomáš Kukrálffd93972017-02-20 14:23:55 +0100136 orchestrate.installOpenstackMkCompute(saltMaster)
Tomáš Kukrál22a65002017-02-16 15:06:43 +0100137 }
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100138
139 //if (TESTS.toLowerCase().contains('openstack')) {
140 // stage('Run OpenStack tests') {
Tomáš Kukrálffd93972017-02-20 14:23:55 +0100141 // orchestrate...
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100142 // }
143 //}
Tomáš Kukrál22a65002017-02-16 15:06:43 +0100144 }
Tomáš Kukrál5a343902017-02-16 11:01:11 +0100145
Tomáš Kukráld92ab802017-02-17 11:34:07 +0100146 //
147 // Cleanup
148 //
149
Tomáš Kukráladccdba2017-02-16 23:56:22 +0100150 if (HEAT_STACK_DELETE == 'true') {
Tomáš Kukrál5a343902017-02-16 11:01:11 +0100151 stage('Trigger cleanup job') {
Tomáš Kukrál22a65002017-02-16 15:06:43 +0100152 build job: 'deploy_heat_cleanup', parameters: [[$class: 'StringParameterValue', name: 'HEAT_STACK_NAME', value: HEAT_STACK_NAME]]
Tomáš Kukrál5a343902017-02-16 11:01:11 +0100153 }
154 }
Tomáš Kukrál5a343902017-02-16 11:01:11 +0100155}