Tomáš Kukrál | e8ebe79 | 2017-01-09 10:24:00 +0100 | [diff] [blame] | 1 | /** |
| 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 Leontovich | 3754a90 | 2017-01-20 18:48:55 +0200 | [diff] [blame^] | 20 | * CONFORMANCE_IMAGE Path to docker image with conformance e2e tests |
| 21 | * K8S_API_SERVER Kubernetes API address |
Tomáš Kukrál | e8ebe79 | 2017-01-09 10:24:00 +0100 | [diff] [blame] | 22 | */ |
| 23 | |
| 24 | git = new com.mirantis.mk.git() |
| 25 | openstack = new com.mirantis.mk.openstack() |
| 26 | salt = new com.mirantis.mk.salt() |
| 27 | |
| 28 | node { |
| 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ál | 00c7bf4 | 2017-01-13 13:27:23 +0100 | [diff] [blame] | 38 | if (HEAT_STACK_NAME == "") { |
Tomáš Kukrál | 7568ca7 | 2017-01-16 09:40:35 +0100 | [diff] [blame] | 39 | HEAT_STACK_NAME = JOB_NAME + "-b" + BUILD_NUMBER |
Tomáš Kukrál | 00c7bf4 | 2017-01-13 13:27:23 +0100 | [diff] [blame] | 40 | } |
| 41 | |
Tomáš Kukrál | e8ebe79 | 2017-01-09 10:24:00 +0100 | [diff] [blame] | 42 | 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 Leontovich | 3754a90 | 2017-01-20 18:48:55 +0200 | [diff] [blame^] | 86 | stage("Run k8s conformance e2e tests") { |
| 87 | salt.runConformanceTest(saltMaster, K8S_API_SERVER, CONFORMANCE_IMAGE) |
| 88 | } |
| 89 | |
Tomáš Kukrál | 7568ca7 | 2017-01-16 09:40:35 +0100 | [diff] [blame] | 90 | 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ál | aba0a7d | 2017-01-13 14:05:12 +0100 | [diff] [blame] | 94 | } |
Tomáš Kukrál | e8ebe79 | 2017-01-09 10:24:00 +0100 | [diff] [blame] | 95 | |
| 96 | } |