Tomáš Kukrál | e8ebe79 | 2017-01-09 10:24:00 +0100 | [diff] [blame] | 1 | /** |
Tomáš Kukrál | 511be61 | 2017-02-20 14:50:18 +0100 | [diff] [blame] | 2 | * DO NOT USE THIS OUTDATED PIPELINE - add your steps to mk-lab-pipeline |
Tomáš Kukrál | e8ebe79 | 2017-01-09 10:24:00 +0100 | [diff] [blame] | 3 | * |
| 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 Leontovich | 3754a90 | 2017-01-20 18:48:55 +0200 | [diff] [blame] | 21 | * CONFORMANCE_IMAGE Path to docker image with conformance e2e tests |
| 22 | * K8S_API_SERVER Kubernetes API address |
Tomáš Kukrál | 9f3f887 | 2017-01-25 10:30:27 +0100 | [diff] [blame] | 23 | * RUN_TESTS Run test (0/1) |
| 24 | * HEAT_STACK_DELETE Delete Heat stack when finished (0/1) |
Tomáš Kukrál | e8ebe79 | 2017-01-09 10:24:00 +0100 | [diff] [blame] | 25 | */ |
| 26 | |
Tomáš Kukrál | fe063c6 | 2017-02-21 09:37:27 +0100 | [diff] [blame] | 27 | git = new com.mirantis.mk.Git() |
| 28 | openstack = new com.mirantis.mk.Openstack() |
| 29 | salt = new com.mirantis.mk.Salt() |
| 30 | orchestrate = new com.mirantis.mk.Orchestrate() |
Tatyana Leontovich | ebee21c | 2017-02-28 15:06:17 +0200 | [diff] [blame^] | 31 | test = new com.mirantis.mk.Test() |
Tomáš Kukrál | e8ebe79 | 2017-01-09 10:24:00 +0100 | [diff] [blame] | 32 | |
| 33 | node { |
| 34 | |
| 35 | // connection objects |
| 36 | def openstackCloud |
| 37 | def saltMaster |
| 38 | |
| 39 | // value defaults |
Tomáš Kukrál | fe063c6 | 2017-02-21 09:37:27 +0100 | [diff] [blame] | 40 | def openstackVersion = OPENSTACK_API_CLIENT ? OPENSTACK_API_CLIENT : 'liberty' |
Tomáš Kukrál | e8ebe79 | 2017-01-09 10:24:00 +0100 | [diff] [blame] | 41 | def openstackEnv = "${env.WORKSPACE}/venv" |
| 42 | |
Tomáš Kukrál | 00c7bf4 | 2017-01-13 13:27:23 +0100 | [diff] [blame] | 43 | if (HEAT_STACK_NAME == "") { |
Tomáš Kukrál | fe063c6 | 2017-02-21 09:37:27 +0100 | [diff] [blame] | 44 | HEAT_STACK_NAME = BUILD_TAG |
Tomáš Kukrál | 00c7bf4 | 2017-01-13 13:27:23 +0100 | [diff] [blame] | 45 | } |
| 46 | |
Tomáš Kukrál | e8ebe79 | 2017-01-09 10:24:00 +0100 | [diff] [blame] | 47 | stage ('Download Heat templates') { |
| 48 | git.checkoutGitRepository('template', HEAT_TEMPLATE_URL, HEAT_TEMPLATE_BRANCH, HEAT_TEMPLATE_CREDENTIALS) |
| 49 | } |
| 50 | |
| 51 | stage('Install OpenStack env') { |
| 52 | openstack.setupOpenstackVirtualenv(openstackEnv, openstackVersion) |
| 53 | } |
| 54 | |
| 55 | stage('Connect to OpenStack cloud') { |
| 56 | openstackCloud = openstack.createOpenstackEnv(OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS, OPENSTACK_API_PROJECT) |
| 57 | openstack.getKeystoneToken(openstackCloud, openstackEnv) |
| 58 | } |
| 59 | |
| 60 | stage('Launch new Heat stack') { |
Tomáš Kukrál | 843b1c1 | 2017-02-23 11:37:05 +0100 | [diff] [blame] | 61 | envParams = [ |
| 62 | 'instance_zone': HEAT_STACK_ZONE, |
| 63 | 'public_net': HEAT_STACK_PUBLIC_NET |
| 64 | ] |
Tomáš Kukrál | e8ebe79 | 2017-01-09 10:24:00 +0100 | [diff] [blame] | 65 | openstack.createHeatStack(openstackCloud, HEAT_STACK_NAME, HEAT_STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, openstackEnv) |
| 66 | } |
| 67 | |
| 68 | stage("Connect to Salt master") { |
| 69 | saltMasterHost = openstack.getHeatStackOutputParam(openstackCloud, HEAT_STACK_NAME, 'salt_master_ip', openstackEnv) |
Tomáš Kukrál | 658944b | 2017-02-21 18:05:05 +0100 | [diff] [blame] | 70 | saltMasterUrl = "http://${saltMasterHost}:8088" |
Tomáš Kukrál | fe063c6 | 2017-02-21 09:37:27 +0100 | [diff] [blame] | 71 | saltMaster = salt.connection(saltMasterUrl, SALT_MASTER_CREDENTIALS) |
Tomáš Kukrál | e8ebe79 | 2017-01-09 10:24:00 +0100 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | stage("Install core infra") { |
Tomáš Kukrál | fe063c6 | 2017-02-21 09:37:27 +0100 | [diff] [blame] | 75 | orchestrate.installFoundationInfra(saltMaster) |
| 76 | orchestrate.validateFoundationInfra(saltMaster) |
Tomáš Kukrál | e8ebe79 | 2017-01-09 10:24:00 +0100 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | stage("Install Kubernetes infra") { |
Tomáš Kukrál | fe063c6 | 2017-02-21 09:37:27 +0100 | [diff] [blame] | 80 | orchestrate.installOpenstackMcpInfra(saltMaster) |
Tomáš Kukrál | e8ebe79 | 2017-01-09 10:24:00 +0100 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | stage("Install Kubernetes control") { |
Tomáš Kukrál | fe063c6 | 2017-02-21 09:37:27 +0100 | [diff] [blame] | 84 | orchestrate.installOpenstackMcpControl(saltMaster) |
Tomáš Kukrál | e8ebe79 | 2017-01-09 10:24:00 +0100 | [diff] [blame] | 85 | } |
| 86 | |
Tomáš Kukrál | 75d4bb1 | 2017-01-25 10:40:28 +0100 | [diff] [blame] | 87 | if (RUN_TESTS == "1") { |
Tomáš Kukrál | 060ddc2 | 2017-02-20 00:55:08 +0100 | [diff] [blame] | 88 | sleep(30000) |
Tomáš Kukrál | 023a40b | 2017-02-20 00:17:00 +0100 | [diff] [blame] | 89 | stage('Run k8s bootstrap tests') { |
Tatyana Leontovich | ebee21c | 2017-02-28 15:06:17 +0200 | [diff] [blame^] | 90 | test.runConformanceTests(saltMaster, K8S_API_SERVER, 'tomkukral/k8s-scripts') |
Tomáš Kukrál | 023a40b | 2017-02-20 00:17:00 +0100 | [diff] [blame] | 91 | } |
| 92 | |
Tomáš Kukrál | 9f3f887 | 2017-01-25 10:30:27 +0100 | [diff] [blame] | 93 | stage("Run k8s conformance e2e tests") { |
Tatyana Leontovich | ebee21c | 2017-02-28 15:06:17 +0200 | [diff] [blame^] | 94 | test.runConformanceTests(saltMaster, K8S_API_SERVER, CONFORMANCE_IMAGE) |
| 95 | } |
| 96 | |
| 97 | stage("Copy k8s e2e test output to config node ") { |
| 98 | test.copyTestsOutput(saltMaster,CONFORMANCE_IMAGE) |
Tomáš Kukrál | 9f3f887 | 2017-01-25 10:30:27 +0100 | [diff] [blame] | 99 | } |
Tatyana Leontovich | 3754a90 | 2017-01-20 18:48:55 +0200 | [diff] [blame] | 100 | } |
| 101 | |
Tomáš Kukrál | 7568ca7 | 2017-01-16 09:40:35 +0100 | [diff] [blame] | 102 | if (HEAT_STACK_DELETE == "1") { |
| 103 | stage('Trigger cleanup job') { |
| 104 | build job: 'mk-k8s-cleanup', parameters: [[$class: 'StringParameterValue', name: 'HEAT_STACK_NAME', value: HEAT_STACK_NAME]] |
| 105 | } |
Tomáš Kukrál | aba0a7d | 2017-01-13 14:05:12 +0100 | [diff] [blame] | 106 | } |
Tomáš Kukrál | e8ebe79 | 2017-01-09 10:24:00 +0100 | [diff] [blame] | 107 | |
| 108 | } |