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.

217 lines
6.6 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. when: always
  40. paths:
  41. - cluster-dump/
  42. variables:
  43. ANSIBLE_INVENTORY_UNPARSED_FAILED: "true"
  44. ANSIBLE_INVENTORY: hosts
  45. CI_PLATFORM: tf
  46. TF_VAR_ssh_user: $SSH_USER
  47. TF_VAR_cluster_name: $CI_JOB_ID
  48. script:
  49. - tests/scripts/testcases_run.sh
  50. after_script:
  51. # Cleanup regardless of exit code
  52. - chronic ./tests/scripts/testcases_cleanup.sh
  53. tf-validate-openstack:
  54. extends: .terraform_validate
  55. variables:
  56. TF_VERSION: 0.12.24
  57. PROVIDER: openstack
  58. CLUSTER: $CI_COMMIT_REF_NAME
  59. tf-validate-packet:
  60. extends: .terraform_validate
  61. variables:
  62. TF_VERSION: 0.12.24
  63. PROVIDER: packet
  64. CLUSTER: $CI_COMMIT_REF_NAME
  65. tf-validate-aws:
  66. extends: .terraform_validate
  67. variables:
  68. TF_VERSION: 0.12.24
  69. PROVIDER: aws
  70. CLUSTER: $CI_COMMIT_REF_NAME
  71. # tf-packet-ubuntu16-default:
  72. # extends: .terraform_apply
  73. # variables:
  74. # TF_VERSION: 0.12.24
  75. # PROVIDER: packet
  76. # CLUSTER: $CI_COMMIT_REF_NAME
  77. # TF_VAR_number_of_k8s_masters: "1"
  78. # TF_VAR_number_of_k8s_nodes: "1"
  79. # TF_VAR_plan_k8s_masters: t1.small.x86
  80. # TF_VAR_plan_k8s_nodes: t1.small.x86
  81. # TF_VAR_facility: ewr1
  82. # TF_VAR_public_key_path: ""
  83. # TF_VAR_operating_system: ubuntu_16_04
  84. #
  85. # tf-packet-ubuntu18-default:
  86. # extends: .terraform_apply
  87. # variables:
  88. # TF_VERSION: 0.12.24
  89. # PROVIDER: packet
  90. # CLUSTER: $CI_COMMIT_REF_NAME
  91. # TF_VAR_number_of_k8s_masters: "1"
  92. # TF_VAR_number_of_k8s_nodes: "1"
  93. # TF_VAR_plan_k8s_masters: t1.small.x86
  94. # TF_VAR_plan_k8s_nodes: t1.small.x86
  95. # TF_VAR_facility: ams1
  96. # TF_VAR_public_key_path: ""
  97. # TF_VAR_operating_system: ubuntu_18_04
  98. .ovh_variables: &ovh_variables
  99. OS_AUTH_URL: https://auth.cloud.ovh.net/v3
  100. OS_PROJECT_ID: 8d3cd5d737d74227ace462dee0b903fe
  101. OS_PROJECT_NAME: "9361447987648822"
  102. OS_USER_DOMAIN_NAME: Default
  103. OS_PROJECT_DOMAIN_ID: default
  104. OS_USERNAME: 8XuhBMfkKVrk
  105. OS_REGION_NAME: UK1
  106. OS_INTERFACE: public
  107. OS_IDENTITY_API_VERSION: "3"
  108. # Elastx is generously donating resources for Kubespray on Openstack CI
  109. # Contacts: @gix @bl0m1
  110. .elastx_variables: &elastx_variables
  111. OS_AUTH_URL: https://ops.elastx.cloud:5000
  112. OS_PROJECT_ID: 564c6b461c6b44b1bb19cdb9c2d928e4
  113. OS_PROJECT_NAME: kubespray_ci
  114. OS_USER_DOMAIN_NAME: Default
  115. OS_PROJECT_DOMAIN_ID: default
  116. OS_USERNAME: kubespray@root314.com
  117. OS_REGION_NAME: se-sto
  118. OS_INTERFACE: public
  119. OS_IDENTITY_API_VERSION: "3"
  120. TF_VAR_router_id: "ab95917c-41fb-4881-b507-3a6dfe9403df"
  121. # Since ELASTX is in Stockholm, Mitogen helps with latency
  122. MITOGEN_ENABLE: "false"
  123. # Mitogen doesn't support interpreter discovery yet
  124. ANSIBLE_PYTHON_INTERPRETER: "/usr/bin/python3"
  125. tf-elastx_cleanup:
  126. stage: unit-tests
  127. tags: [light]
  128. image: python
  129. variables:
  130. <<: *elastx_variables
  131. before_script:
  132. - pip install -r scripts/openstack-cleanup/requirements.txt
  133. script:
  134. - ./scripts/openstack-cleanup/main.py
  135. tf-elastx_ubuntu18-calico:
  136. extends: .terraform_apply
  137. stage: deploy-part3
  138. when: on_success
  139. variables:
  140. <<: *elastx_variables
  141. TF_VERSION: 0.12.24
  142. PROVIDER: openstack
  143. CLUSTER: $CI_COMMIT_REF_NAME
  144. ANSIBLE_TIMEOUT: "60"
  145. SSH_USER: ubuntu
  146. TF_VAR_number_of_k8s_masters: "1"
  147. TF_VAR_number_of_k8s_masters_no_floating_ip: "0"
  148. TF_VAR_number_of_k8s_masters_no_floating_ip_no_etcd: "0"
  149. TF_VAR_number_of_etcd: "0"
  150. TF_VAR_number_of_k8s_nodes: "1"
  151. TF_VAR_number_of_k8s_nodes_no_floating_ip: "0"
  152. TF_VAR_number_of_gfs_nodes_no_floating_ip: "0"
  153. TF_VAR_number_of_bastions: "0"
  154. TF_VAR_number_of_k8s_masters_no_etcd: "0"
  155. TF_VAR_floatingip_pool: "elx-public1"
  156. TF_VAR_dns_nameservers: '["1.1.1.1", "8.8.8.8", "8.8.4.4"]'
  157. TF_VAR_use_access_ip: "0"
  158. TF_VAR_external_net: "600b8501-78cb-4155-9c9f-23dfcba88828"
  159. TF_VAR_network_name: "ci-$CI_JOB_ID"
  160. TF_VAR_az_list: '["sto1"]'
  161. TF_VAR_az_list_node: '["sto1"]'
  162. TF_VAR_flavor_k8s_master: 3f73fc93-ec61-4808-88df-2580d94c1a9b # v1-standard-2
  163. TF_VAR_flavor_k8s_node: 3f73fc93-ec61-4808-88df-2580d94c1a9b # v1-standard-2
  164. TF_VAR_image: ubuntu-18.04-server-latest
  165. TF_VAR_k8s_allowed_remote_ips: '["0.0.0.0/0"]'
  166. tf-ovh_cleanup:
  167. stage: unit-tests
  168. tags: [light]
  169. image: python
  170. environment: ovh
  171. variables:
  172. <<: *ovh_variables
  173. before_script:
  174. - pip install -r scripts/openstack-cleanup/requirements.txt
  175. script:
  176. - ./scripts/openstack-cleanup/main.py
  177. tf-ovh_ubuntu18-calico:
  178. extends: .terraform_apply
  179. when: on_success
  180. environment: ovh
  181. variables:
  182. <<: *ovh_variables
  183. TF_VERSION: 0.12.24
  184. PROVIDER: openstack
  185. CLUSTER: $CI_COMMIT_REF_NAME
  186. ANSIBLE_TIMEOUT: "60"
  187. SSH_USER: ubuntu
  188. TF_VAR_number_of_k8s_masters: "0"
  189. TF_VAR_number_of_k8s_masters_no_floating_ip: "1"
  190. TF_VAR_number_of_k8s_masters_no_floating_ip_no_etcd: "0"
  191. TF_VAR_number_of_etcd: "0"
  192. TF_VAR_number_of_k8s_nodes: "0"
  193. TF_VAR_number_of_k8s_nodes_no_floating_ip: "1"
  194. TF_VAR_number_of_gfs_nodes_no_floating_ip: "0"
  195. TF_VAR_number_of_bastions: "0"
  196. TF_VAR_number_of_k8s_masters_no_etcd: "0"
  197. TF_VAR_use_neutron: "0"
  198. TF_VAR_floatingip_pool: "Ext-Net"
  199. TF_VAR_external_net: "6011fbc9-4cbf-46a4-8452-6890a340b60b"
  200. TF_VAR_network_name: "Ext-Net"
  201. TF_VAR_flavor_k8s_master: "defa64c3-bd46-43b4-858a-d93bbae0a229" # s1-8
  202. TF_VAR_flavor_k8s_node: "defa64c3-bd46-43b4-858a-d93bbae0a229" # s1-8
  203. TF_VAR_image: "Ubuntu 18.04"
  204. TF_VAR_k8s_allowed_remote_ips: '["0.0.0.0/0"]'