blob: 9f9d399456a8349bdb499419e267b997b2cff1c7 [file] [log] [blame]
Tomáš Kukrále8ebe792017-01-09 10:24:00 +01001/**
Tomáš Kukrál511be612017-02-20 14:50:18 +01002 * DO NOT USE THIS OUTDATED PIPELINE - add your steps to mk-lab-pipeline
Tomáš Kukrále8ebe792017-01-09 10:24:00 +01003 *
4 * Launch heat stack with basic k8s
5 *
6 * Expected parameters:
7 * HEAT_TEMPLATE_URL URL to git repo with Heat templates
8 * HEAT_TEMPLATE_CREDENTIALS Credentials to the Heat templates repo
9 * HEAT_TEMPLATE_BRANCH Heat templates repo branch
10 * OPENSTACK_API_URL OpenStack API address
11 * OPENSTACK_API_CREDENTIALS Credentials to the OpenStack API
12 * OPENSTACK_API_PROJECT OpenStack project to connect to
13 * OPENSTACK_API_CLIENT Versions of OpenStack python clients
14 * OPENSTACK_API_VERSION Version of the OpenStack API (2/3)
15 * SALT_MASTER_CREDENTIALS Credentials to the Salt API
16 * HEAT_STACK_NAME Heat stack name
17 * HEAT_STACK_TEMPLATE Heat stack HOT template
18 * HEAT_STACK_ENVIRONMENT Heat stack environmental parameters
19 * HEAT_STACK_ZONE Heat stack availability zone
20 * HEAT_STACK_PUBLIC_NET Heat stack floating IP pool
Tatyana Leontovich3754a902017-01-20 18:48:55 +020021 * CONFORMANCE_IMAGE Path to docker image with conformance e2e tests
22 * K8S_API_SERVER Kubernetes API address
Tomáš Kukrál9f3f8872017-01-25 10:30:27 +010023 * RUN_TESTS Run test (0/1)
24 * HEAT_STACK_DELETE Delete Heat stack when finished (0/1)
Tomáš Kukrále8ebe792017-01-09 10:24:00 +010025 */
26
Tomáš Kukrálfe063c62017-02-21 09:37:27 +010027git = new com.mirantis.mk.Git()
28openstack = new com.mirantis.mk.Openstack()
29salt = new com.mirantis.mk.Salt()
30orchestrate = new com.mirantis.mk.Orchestrate()
Tomáš Kukrále8ebe792017-01-09 10:24:00 +010031
32node {
33
34 // connection objects
35 def openstackCloud
36 def saltMaster
37
38 // value defaults
Tomáš Kukrálfe063c62017-02-21 09:37:27 +010039 def openstackVersion = OPENSTACK_API_CLIENT ? OPENSTACK_API_CLIENT : 'liberty'
Tomáš Kukrále8ebe792017-01-09 10:24:00 +010040 def openstackEnv = "${env.WORKSPACE}/venv"
41
Tomáš Kukrál00c7bf42017-01-13 13:27:23 +010042 if (HEAT_STACK_NAME == "") {
Tomáš Kukrálfe063c62017-02-21 09:37:27 +010043 HEAT_STACK_NAME = BUILD_TAG
Tomáš Kukrál00c7bf42017-01-13 13:27:23 +010044 }
45
Tomáš Kukrále8ebe792017-01-09 10:24:00 +010046 stage ('Download Heat templates') {
47 git.checkoutGitRepository('template', HEAT_TEMPLATE_URL, HEAT_TEMPLATE_BRANCH, HEAT_TEMPLATE_CREDENTIALS)
48 }
49
50 stage('Install OpenStack env') {
51 openstack.setupOpenstackVirtualenv(openstackEnv, openstackVersion)
52 }
53
54 stage('Connect to OpenStack cloud') {
55 openstackCloud = openstack.createOpenstackEnv(OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS, OPENSTACK_API_PROJECT)
56 openstack.getKeystoneToken(openstackCloud, openstackEnv)
57 }
58
59 stage('Launch new Heat stack') {
60 envParams = [
61 'availability_zone': HEAT_STACK_ZONE,
62 'public_net': HEAT_STACK_PUBLIC_NET
63 ]
64 openstack.createHeatStack(openstackCloud, HEAT_STACK_NAME, HEAT_STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, openstackEnv)
65 }
66
67 stage("Connect to Salt master") {
68 saltMasterHost = openstack.getHeatStackOutputParam(openstackCloud, HEAT_STACK_NAME, 'salt_master_ip', openstackEnv)
69 saltMasterUrl = "http://${saltMasterHost}:8000"
Tomáš Kukrálfe063c62017-02-21 09:37:27 +010070 saltMaster = salt.connection(saltMasterUrl, SALT_MASTER_CREDENTIALS)
Tomáš Kukrále8ebe792017-01-09 10:24:00 +010071 }
72
73 stage("Install core infra") {
Tomáš Kukrálfe063c62017-02-21 09:37:27 +010074 orchestrate.installFoundationInfra(saltMaster)
75 orchestrate.validateFoundationInfra(saltMaster)
Tomáš Kukrále8ebe792017-01-09 10:24:00 +010076 }
77
78 stage("Install Kubernetes infra") {
Tomáš Kukrálfe063c62017-02-21 09:37:27 +010079 orchestrate.installOpenstackMcpInfra(saltMaster)
Tomáš Kukrále8ebe792017-01-09 10:24:00 +010080 }
81
82 stage("Install Kubernetes control") {
Tomáš Kukrálfe063c62017-02-21 09:37:27 +010083 orchestrate.installOpenstackMcpControl(saltMaster)
Tomáš Kukrále8ebe792017-01-09 10:24:00 +010084 }
85
Tomáš Kukrál75d4bb12017-01-25 10:40:28 +010086 if (RUN_TESTS == "1") {
Tomáš Kukrál060ddc22017-02-20 00:55:08 +010087 sleep(30000)
Tomáš Kukrál023a40b2017-02-20 00:17:00 +010088 stage('Run k8s bootstrap tests') {
Tomáš Kukrálfe063c62017-02-21 09:37:27 +010089 orchestrate.runConformanceTests(saltMaster, K8S_API_SERVER, 'tomkukral/k8s-scripts')
Tomáš Kukrál023a40b2017-02-20 00:17:00 +010090 }
91
Tomáš Kukrál9f3f8872017-01-25 10:30:27 +010092 stage("Run k8s conformance e2e tests") {
Tomáš Kukrálfe063c62017-02-21 09:37:27 +010093 orchestrate.runConformanceTests(saltMaster, K8S_API_SERVER, CONFORMANCE_IMAGE)
Tomáš Kukrál9f3f8872017-01-25 10:30:27 +010094 }
Tatyana Leontovich3754a902017-01-20 18:48:55 +020095 }
96
Tomáš Kukrál7568ca72017-01-16 09:40:35 +010097 if (HEAT_STACK_DELETE == "1") {
98 stage('Trigger cleanup job') {
99 build job: 'mk-k8s-cleanup', parameters: [[$class: 'StringParameterValue', name: 'HEAT_STACK_NAME', value: HEAT_STACK_NAME]]
100 }
Tomáš Kukrálaba0a7d2017-01-13 14:05:12 +0100101 }
Tomáš Kukrále8ebe792017-01-09 10:24:00 +0100102
103}