blob: c044fdc1004f32e445179315da1ff72f71064c3c [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ál9f3f8872017-01-25 10:30:27 +010022 * RUN_TESTS Run test (0/1)
23 * HEAT_STACK_DELETE Delete Heat stack when finished (0/1)
Tomáš Kukrále8ebe792017-01-09 10:24:00 +010024 */
25
26git = new com.mirantis.mk.git()
27openstack = new com.mirantis.mk.openstack()
28salt = new com.mirantis.mk.salt()
29
30node {
31
32 // connection objects
33 def openstackCloud
34 def saltMaster
35
36 // value defaults
37 def openstackVersion = OPENSTACK_API_CLIENT ? OPENSTACK_API_CLIENT : "liberty"
38 def openstackEnv = "${env.WORKSPACE}/venv"
39
Tomáš Kukrál00c7bf42017-01-13 13:27:23 +010040 if (HEAT_STACK_NAME == "") {
Tomáš Kukrál7568ca72017-01-16 09:40:35 +010041 HEAT_STACK_NAME = JOB_NAME + "-b" + BUILD_NUMBER
Tomáš Kukrál00c7bf42017-01-13 13:27:23 +010042 }
43
Tomáš Kukrále8ebe792017-01-09 10:24:00 +010044 stage ('Download Heat templates') {
45 git.checkoutGitRepository('template', HEAT_TEMPLATE_URL, HEAT_TEMPLATE_BRANCH, HEAT_TEMPLATE_CREDENTIALS)
46 }
47
48 stage('Install OpenStack env') {
49 openstack.setupOpenstackVirtualenv(openstackEnv, openstackVersion)
50 }
51
52 stage('Connect to OpenStack cloud') {
53 openstackCloud = openstack.createOpenstackEnv(OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS, OPENSTACK_API_PROJECT)
54 openstack.getKeystoneToken(openstackCloud, openstackEnv)
55 }
56
57 stage('Launch new Heat stack') {
58 envParams = [
59 'availability_zone': HEAT_STACK_ZONE,
60 'public_net': HEAT_STACK_PUBLIC_NET
61 ]
62 openstack.createHeatStack(openstackCloud, HEAT_STACK_NAME, HEAT_STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, openstackEnv)
63 }
64
65 stage("Connect to Salt master") {
66 saltMasterHost = openstack.getHeatStackOutputParam(openstackCloud, HEAT_STACK_NAME, 'salt_master_ip', openstackEnv)
67 saltMasterUrl = "http://${saltMasterHost}:8000"
68 saltMaster = salt.createSaltConnection(saltMasterUrl, SALT_MASTER_CREDENTIALS)
69 }
70
71 stage("Install core infra") {
72 salt.installFoundationInfra(saltMaster)
73 salt.validateFoundationInfra(saltMaster)
74 }
75
76 stage("Install Kubernetes infra") {
77 salt.installOpenstackMcpInfra(saltMaster)
78 }
79
80 stage("Install Kubernetes control") {
81 salt.installOpenstackMcpControl(saltMaster)
82 }
83
Tomáš Kukrál75d4bb12017-01-25 10:40:28 +010084 if (RUN_TESTS == "1") {
Tomáš Kukrál023a40b2017-02-20 00:17:00 +010085 stage('Run k8s bootstrap tests') {
86 salt.runConformanceTests(saltMaster, K8S_API_SERVER, 'tomkukral/k8s-scripts')
87 }
88
Tomáš Kukrál9f3f8872017-01-25 10:30:27 +010089 stage("Run k8s conformance e2e tests") {
90 salt.runConformanceTests(saltMaster, K8S_API_SERVER, CONFORMANCE_IMAGE)
91 }
Tatyana Leontovich3754a902017-01-20 18:48:55 +020092 }
93
Tomáš Kukrál7568ca72017-01-16 09:40:35 +010094 if (HEAT_STACK_DELETE == "1") {
95 stage('Trigger cleanup job') {
96 build job: 'mk-k8s-cleanup', parameters: [[$class: 'StringParameterValue', name: 'HEAT_STACK_NAME', value: HEAT_STACK_NAME]]
97 }
Tomáš Kukrálaba0a7d2017-01-13 14:05:12 +010098 }
Tomáš Kukrále8ebe792017-01-09 10:24:00 +010099
100}