blob: a6f99385974bfe99a3f7fd72b054ce7f22e9f1cb [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
Tatyana Leontovich3754a902017-01-20 18:48:55 +020020 * CONFORMANCE_IMAGE Path to docker image with conformance e2e tests
21 * K8S_API_SERVER Kubernetes API address
Tomáš Kukrále8ebe792017-01-09 10:24:00 +010022 */
23
24git = new com.mirantis.mk.git()
25openstack = new com.mirantis.mk.openstack()
26salt = new com.mirantis.mk.salt()
27
28node {
29
30 // connection objects
31 def openstackCloud
32 def saltMaster
33
34 // value defaults
35 def openstackVersion = OPENSTACK_API_CLIENT ? OPENSTACK_API_CLIENT : "liberty"
36 def openstackEnv = "${env.WORKSPACE}/venv"
37
Tomáš Kukrál00c7bf42017-01-13 13:27:23 +010038 if (HEAT_STACK_NAME == "") {
Tomáš Kukrál7568ca72017-01-16 09:40:35 +010039 HEAT_STACK_NAME = JOB_NAME + "-b" + BUILD_NUMBER
Tomáš Kukrál00c7bf42017-01-13 13:27:23 +010040 }
41
Tomáš Kukrále8ebe792017-01-09 10:24:00 +010042 stage ('Download Heat templates') {
43 git.checkoutGitRepository('template', HEAT_TEMPLATE_URL, HEAT_TEMPLATE_BRANCH, HEAT_TEMPLATE_CREDENTIALS)
44 }
45
46 stage('Install OpenStack env') {
47 openstack.setupOpenstackVirtualenv(openstackEnv, openstackVersion)
48 }
49
50 stage('Connect to OpenStack cloud') {
51 openstackCloud = openstack.createOpenstackEnv(OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS, OPENSTACK_API_PROJECT)
52 openstack.getKeystoneToken(openstackCloud, openstackEnv)
53 }
54
55 stage('Launch new Heat stack') {
56 envParams = [
57 'availability_zone': HEAT_STACK_ZONE,
58 'public_net': HEAT_STACK_PUBLIC_NET
59 ]
60 openstack.createHeatStack(openstackCloud, HEAT_STACK_NAME, HEAT_STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, openstackEnv)
61 }
62
63 stage("Connect to Salt master") {
64 saltMasterHost = openstack.getHeatStackOutputParam(openstackCloud, HEAT_STACK_NAME, 'salt_master_ip', openstackEnv)
65 saltMasterUrl = "http://${saltMasterHost}:8000"
66 saltMaster = salt.createSaltConnection(saltMasterUrl, SALT_MASTER_CREDENTIALS)
67 }
68
69 stage("Install core infra") {
70 salt.installFoundationInfra(saltMaster)
71 salt.validateFoundationInfra(saltMaster)
72 }
73
74 stage("Install Kubernetes infra") {
75 salt.installOpenstackMcpInfra(saltMaster)
76 }
77
78 stage("Install Kubernetes control") {
79 salt.installOpenstackMcpControl(saltMaster)
80 }
81
82 //stage("Install Kubernetes compute") {
83 // salt.installOpenstackMcpCompute(saltMaster)
84 //}
85
Tatyana Leontovich3754a902017-01-20 18:48:55 +020086 stage("Run k8s conformance e2e tests") {
87 salt.runConformanceTest(saltMaster, K8S_API_SERVER, CONFORMANCE_IMAGE)
88 }
89
Tomáš Kukrál7568ca72017-01-16 09:40:35 +010090 if (HEAT_STACK_DELETE == "1") {
91 stage('Trigger cleanup job') {
92 build job: 'mk-k8s-cleanup', parameters: [[$class: 'StringParameterValue', name: 'HEAT_STACK_NAME', value: HEAT_STACK_NAME]]
93 }
Tomáš Kukrálaba0a7d2017-01-13 14:05:12 +010094 }
Tomáš Kukrále8ebe792017-01-09 10:24:00 +010095
96}