blob: a4b1a9b8287279a190f591a6b70f23b22c159f6c [file] [log] [blame]
Tomáš Kukrále8ebe792017-01-09 10:24:00 +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 * OPENSTACK_API_URL OpenStack API address
10 * OPENSTACK_API_CREDENTIALS Credentials to the OpenStack API
11 * OPENSTACK_API_PROJECT OpenStack project to connect to
12 * OPENSTACK_API_CLIENT Versions of OpenStack python clients
13 * OPENSTACK_API_VERSION Version of the OpenStack API (2/3)
14 * SALT_MASTER_CREDENTIALS Credentials to the Salt API
15 * HEAT_STACK_NAME Heat stack name
16 * HEAT_STACK_TEMPLATE Heat stack HOT template
17 * HEAT_STACK_ENVIRONMENT Heat stack environmental parameters
18 * HEAT_STACK_ZONE Heat stack availability zone
19 * HEAT_STACK_PUBLIC_NET Heat stack floating IP pool
20 */
21
22git = new com.mirantis.mk.git()
23openstack = new com.mirantis.mk.openstack()
24salt = new com.mirantis.mk.salt()
25
26node {
27
28 // connection objects
29 def openstackCloud
30 def saltMaster
31
32 // value defaults
33 def openstackVersion = OPENSTACK_API_CLIENT ? OPENSTACK_API_CLIENT : "liberty"
34 def openstackEnv = "${env.WORKSPACE}/venv"
35
Tomáš Kukrál00c7bf42017-01-13 13:27:23 +010036 if (HEAT_STACK_NAME == "") {
Tomáš Kukrál25b9e672017-01-13 13:47:50 +010037 HEAT_STACK_NAME = JOB_NAME + "-b" + BUILD_NUMBER
Tomáš Kukrál00c7bf42017-01-13 13:27:23 +010038 }
39
Tomáš Kukrále8ebe792017-01-09 10:24:00 +010040 stage ('Download Heat templates') {
41 git.checkoutGitRepository('template', HEAT_TEMPLATE_URL, HEAT_TEMPLATE_BRANCH, HEAT_TEMPLATE_CREDENTIALS)
42 }
43
44 stage('Install OpenStack env') {
45 openstack.setupOpenstackVirtualenv(openstackEnv, openstackVersion)
46 }
47
48 stage('Connect to OpenStack cloud') {
49 openstackCloud = openstack.createOpenstackEnv(OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS, OPENSTACK_API_PROJECT)
50 openstack.getKeystoneToken(openstackCloud, openstackEnv)
51 }
52
53 stage('Launch new Heat stack') {
54 envParams = [
55 'availability_zone': HEAT_STACK_ZONE,
56 'public_net': HEAT_STACK_PUBLIC_NET
57 ]
58 openstack.createHeatStack(openstackCloud, HEAT_STACK_NAME, HEAT_STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, openstackEnv)
59 }
60
61 stage("Connect to Salt master") {
62 saltMasterHost = openstack.getHeatStackOutputParam(openstackCloud, HEAT_STACK_NAME, 'salt_master_ip', openstackEnv)
63 saltMasterUrl = "http://${saltMasterHost}:8000"
64 saltMaster = salt.createSaltConnection(saltMasterUrl, SALT_MASTER_CREDENTIALS)
65 }
66
67 stage("Install core infra") {
68 salt.installFoundationInfra(saltMaster)
69 salt.validateFoundationInfra(saltMaster)
70 }
71
72 stage("Install Kubernetes infra") {
73 salt.installOpenstackMcpInfra(saltMaster)
74 }
75
76 stage("Install Kubernetes control") {
77 salt.installOpenstackMcpControl(saltMaster)
78 }
79
80 //stage("Install Kubernetes compute") {
81 // salt.installOpenstackMcpCompute(saltMaster)
82 //}
83
Tomáš Kukrálaba0a7d2017-01-13 14:05:12 +010084 stage('Trigger cleanup job') {
Tomáš Kukrále8ebe792017-01-09 10:24:00 +010085 // openstack.deleteHeatStack(openstackCloud, HEAT_STACK_NAME, openstackEnv)
Tomáš Kukrálaba0a7d2017-01-13 14:05:12 +010086 build job: 'mk-k8s-cleanup', parameters: [[$class: 'StringParameterValue', name: 'HEAT_STACK_NAME', value: HEAT_STACK_NAME]]
87 }
Tomáš Kukrále8ebe792017-01-09 10:24:00 +010088
89}