You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

170 lines
5.2 KiB

  1. ---
  2. # Tests for contrib/terraform/
  3. .terraform_install:
  4. extends: .job
  5. before_script:
  6. - update-alternatives --install /usr/bin/python python /usr/bin/python3 1
  7. - ./tests/scripts/rebase.sh
  8. - ./tests/scripts/testcases_prepare.sh
  9. - ./tests/scripts/terraform_install.sh
  10. # Set Ansible config
  11. - cp ansible.cfg ~/.ansible.cfg
  12. # Prepare inventory
  13. - cp contrib/terraform/$PROVIDER/sample-inventory/cluster.tfvars .
  14. - ln -s contrib/terraform/$PROVIDER/hosts
  15. - terraform init contrib/terraform/$PROVIDER
  16. # Copy SSH keypair
  17. - mkdir -p ~/.ssh
  18. - echo "$PACKET_PRIVATE_KEY" | base64 -d > ~/.ssh/id_rsa
  19. - chmod 400 ~/.ssh/id_rsa
  20. - echo "$PACKET_PUBLIC_KEY" | base64 -d > ~/.ssh/id_rsa.pub
  21. - mkdir -p group_vars
  22. # Random subnet to avoid routing conflicts
  23. - export TF_VAR_subnet_cidr="10.$(( $RANDOM % 256 )).$(( $RANDOM % 256 )).0/24"
  24. .terraform_validate:
  25. extends: .terraform_install
  26. stage: unit-tests
  27. tags: [light]
  28. only: ['master', /^pr-.*$/]
  29. script:
  30. - terraform validate -var-file=cluster.tfvars contrib/terraform/$PROVIDER
  31. - terraform fmt -check -diff contrib/terraform/$PROVIDER
  32. .terraform_apply:
  33. extends: .terraform_install
  34. tags: [light]
  35. stage: deploy-part3
  36. when: manual
  37. only: [/^pr-.*$/]
  38. artifacts:
  39. paths:
  40. - cluster-dump/
  41. variables:
  42. ANSIBLE_INVENTORY_UNPARSED_FAILED: "true"
  43. ANSIBLE_INVENTORY: hosts
  44. CI_PLATFORM: tf
  45. TF_VAR_ssh_user: $SSH_USER
  46. TF_VAR_cluster_name: $CI_JOB_ID
  47. script:
  48. - tests/scripts/testcases_run.sh
  49. after_script:
  50. # Cleanup regardless of exit code
  51. - chronic ./tests/scripts/testcases_cleanup.sh
  52. tf-validate-openstack:
  53. extends: .terraform_validate
  54. variables:
  55. TF_VERSION: 0.12.24
  56. PROVIDER: openstack
  57. CLUSTER: $CI_COMMIT_REF_NAME
  58. tf-validate-packet:
  59. extends: .terraform_validate
  60. variables:
  61. TF_VERSION: 0.12.24
  62. PROVIDER: packet
  63. CLUSTER: $CI_COMMIT_REF_NAME
  64. tf-validate-aws:
  65. extends: .terraform_validate
  66. variables:
  67. TF_VERSION: 0.12.24
  68. PROVIDER: aws
  69. CLUSTER: $CI_COMMIT_REF_NAME
  70. # tf-packet-ubuntu16-default:
  71. # extends: .terraform_apply
  72. # variables:
  73. # TF_VERSION: 0.12.24
  74. # PROVIDER: packet
  75. # CLUSTER: $CI_COMMIT_REF_NAME
  76. # TF_VAR_number_of_k8s_masters: "1"
  77. # TF_VAR_number_of_k8s_nodes: "1"
  78. # TF_VAR_plan_k8s_masters: t1.small.x86
  79. # TF_VAR_plan_k8s_nodes: t1.small.x86
  80. # TF_VAR_facility: ewr1
  81. # TF_VAR_public_key_path: ""
  82. # TF_VAR_operating_system: ubuntu_16_04
  83. #
  84. # tf-packet-ubuntu18-default:
  85. # extends: .terraform_apply
  86. # variables:
  87. # TF_VERSION: 0.12.24
  88. # PROVIDER: packet
  89. # CLUSTER: $CI_COMMIT_REF_NAME
  90. # TF_VAR_number_of_k8s_masters: "1"
  91. # TF_VAR_number_of_k8s_nodes: "1"
  92. # TF_VAR_plan_k8s_masters: t1.small.x86
  93. # TF_VAR_plan_k8s_nodes: t1.small.x86
  94. # TF_VAR_facility: ams1
  95. # TF_VAR_public_key_path: ""
  96. # TF_VAR_operating_system: ubuntu_18_04
  97. # .ovh_variables: &ovh_variables
  98. # OS_AUTH_URL: https://auth.cloud.ovh.net/v3
  99. # OS_PROJECT_ID: 8d3cd5d737d74227ace462dee0b903fe
  100. # OS_PROJECT_NAME: "9361447987648822"
  101. # OS_USER_DOMAIN_NAME: Default
  102. # OS_PROJECT_DOMAIN_ID: default
  103. # OS_USERNAME: 8XuhBMfkKVrk
  104. # OS_REGION_NAME: UK1
  105. # OS_INTERFACE: public
  106. # OS_IDENTITY_API_VERSION: "3"
  107. # Elastx is generously donating resources for Kubespray on Openstack CI
  108. # Contacts: @gix @bl0m1
  109. .elastx_variables: &elastx_variables
  110. OS_AUTH_URL: https://ops.elastx.cloud:5000
  111. OS_PROJECT_ID: 564c6b461c6b44b1bb19cdb9c2d928e4
  112. OS_PROJECT_NAME: kubespray_ci
  113. OS_USER_DOMAIN_NAME: Default
  114. OS_PROJECT_DOMAIN_ID: default
  115. OS_USERNAME: kubespray@root314.com
  116. OS_REGION_NAME: se-sto
  117. OS_INTERFACE: public
  118. OS_IDENTITY_API_VERSION: "3"
  119. TF_VAR_router_id: "ab95917c-41fb-4881-b507-3a6dfe9403df"
  120. # Since ELASTX is in Stockholm, Mitogen helps with latency
  121. MITOGEN_ENABLE: "true"
  122. tf-elastx_cleanup:
  123. stage: unit-tests
  124. tags: [light]
  125. image: python
  126. variables:
  127. <<: *elastx_variables
  128. before_script:
  129. - pip install -r scripts/openstack-cleanup/requirements.txt
  130. script:
  131. - ./scripts/openstack-cleanup/main.py
  132. tf-elastx_ubuntu18-calico:
  133. extends: .terraform_apply
  134. when: on_success
  135. variables:
  136. <<: *elastx_variables
  137. TF_VERSION: 0.12.24
  138. PROVIDER: openstack
  139. CLUSTER: $CI_COMMIT_REF_NAME
  140. ANSIBLE_TIMEOUT: "60"
  141. SSH_USER: ubuntu
  142. TF_VAR_number_of_k8s_masters: "1"
  143. TF_VAR_number_of_k8s_masters_no_floating_ip: "0"
  144. TF_VAR_number_of_k8s_masters_no_floating_ip_no_etcd: "0"
  145. TF_VAR_number_of_etcd: "0"
  146. TF_VAR_number_of_k8s_nodes: "1"
  147. TF_VAR_number_of_k8s_nodes_no_floating_ip: "0"
  148. TF_VAR_number_of_gfs_nodes_no_floating_ip: "0"
  149. TF_VAR_number_of_bastions: "0"
  150. TF_VAR_number_of_k8s_masters_no_etcd: "0"
  151. TF_VAR_floatingip_pool: "elx-public1"
  152. TF_VAR_dns_nameservers: '["1.1.1.1", "8.8.8.8", "8.8.4.4"]'
  153. TF_VAR_use_access_ip: "0"
  154. TF_VAR_external_net: "600b8501-78cb-4155-9c9f-23dfcba88828"
  155. TF_VAR_network_name: "ci-$CI_JOB_ID"
  156. TF_VAR_az_list: '["sto1"]'
  157. TF_VAR_az_list_node: '["sto1"]'
  158. TF_VAR_flavor_k8s_master: 3f73fc93-ec61-4808-88df-2580d94c1a9b # v1-standard-2
  159. TF_VAR_flavor_k8s_node: 3f73fc93-ec61-4808-88df-2580d94c1a9b # v1-standard-2
  160. TF_VAR_image: ubuntu-18.04-server-latest
  161. TF_VAR_k8s_allowed_remote_ips: '["0.0.0.0/0"]'