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.

206 lines
6.1 KiB

  1. # CI Setup
  2. ## Pipeline
  3. 1. build: build a docker image to be used in the pipeline
  4. 2. unit-tests: fast jobs for fast feedback (linting, etc...)
  5. 3. deploy-part1: small number of jobs to test if the PR works with default settings
  6. 4. deploy-part2: slow jobs testing different platforms, OS, settings, CNI, etc...
  7. 5. deploy-part3: very slow jobs (upgrades, etc...)
  8. ## Runners
  9. Kubespray has 3 types of GitLab runners:
  10. - packet runners: used for E2E jobs (usually long), running on Equinix Metal (ex-packet), on kubevirt managed VMs
  11. - light runners: used for short lived jobs, running on Equinix Metal (ex-packet), as managed pods
  12. - auto scaling runners (managed via docker-machine on Equinix Metal): used for on-demand resources, see [GitLab docs](https://docs.gitlab.com/runner/configuration/autoscale.html) for more info
  13. ## Vagrant
  14. Vagrant jobs are using the [quay.io/kubespray/vagrant](/test-infra/vagrant-docker/Dockerfile) docker image with `/var/run/libvirt/libvirt-sock` exposed from the host, allowing the container to boot VMs on the host.
  15. ## CI Variables
  16. In CI we have a set of overrides we use to ensure greater success of our CI jobs and avoid throttling by various APIs we depend on. See:
  17. - [Docker mirrors](/tests/common/_docker_hub_registry_mirror.yml)
  18. - [Test settings](/tests/common/_kubespray_test_settings.yml)
  19. ## CI Environment
  20. The CI packet and light runners are deployed on a kubernetes cluster on Equinix Metal. The cluster is deployed with kubespray itself and maintained by the kubespray maintainers.
  21. The following files are used for that inventory:
  22. ### cluster.tfvars
  23. ```ini
  24. # your Kubernetes cluster name here
  25. cluster_name = "ci"
  26. # Your Equinix Metal project ID. See https://metal.equinix.com/developers/docs/accounts/
  27. equinix_metal_project_id = "_redacted_"
  28. # The public SSH key to be uploaded into authorized_keys in bare metal Equinix Metal nodes provisioned
  29. # leave this value blank if the public key is already setup in the Equinix Metal project
  30. # Terraform will complain if the public key is setup in Equinix Metal
  31. public_key_path = "~/.ssh/id_rsa.pub"
  32. # cluster location
  33. metro = "da"
  34. # standalone etcds
  35. number_of_etcd = 0
  36. plan_etcd = "t1.small.x86"
  37. # masters
  38. number_of_k8s_masters = 1
  39. number_of_k8s_masters_no_etcd = 0
  40. plan_k8s_masters = "c3.small.x86"
  41. plan_k8s_masters_no_etcd = "t1.small.x86"
  42. # nodes
  43. number_of_k8s_nodes = 1
  44. plan_k8s_nodes = "c3.medium.x86"
  45. ```
  46. ### group_vars/all/mirrors.yml
  47. ```yaml
  48. ---
  49. docker_registry_mirrors:
  50. - "https://mirror.gcr.io"
  51. containerd_grpc_max_recv_message_size: 16777216
  52. containerd_grpc_max_send_message_size: 16777216
  53. containerd_registries:
  54. "docker.io":
  55. - "https://mirror.gcr.io"
  56. - "https://registry-1.docker.io"
  57. containerd_max_container_log_line_size: -1
  58. crio_registries_mirrors:
  59. - prefix: docker.io
  60. insecure: false
  61. blocked: false
  62. location: registry-1.docker.io
  63. mirrors:
  64. - location: mirror.gcr.io
  65. insecure: false
  66. netcheck_agent_image_repo: "{{ quay_image_repo }}/kubespray/k8s-netchecker-agent"
  67. netcheck_server_image_repo: "{{ quay_image_repo }}/kubespray/k8s-netchecker-server"
  68. nginx_image_repo: "{{ quay_image_repo }}/kubespray/nginx"
  69. ```
  70. ### group_vars/all/settings.yml
  71. ```yaml
  72. ---
  73. # Networking setting
  74. kube_service_addresses: 172.30.0.0/18
  75. kube_pods_subnet: 172.30.64.0/18
  76. kube_network_plugin: calico
  77. # avoid overlap with CI jobs deploying nodelocaldns
  78. nodelocaldns_ip: 169.254.255.100
  79. # ipip: False
  80. calico_ipip_mode: "Never"
  81. calico_vxlan_mode: "Never"
  82. calico_network_backend: "bird"
  83. calico_wireguard_enabled: True
  84. # Cluster settings
  85. upgrade_cluster_setup: True
  86. force_certificate_regeneration: True
  87. # Etcd settings
  88. etcd_deployment_type: "host"
  89. # Kubernetes settings
  90. kube_controller_terminated_pod_gc_threshold: 100
  91. kubelet_enforce_node_allocatable: pods
  92. kubelet_preferred_address_types: 'InternalIP,ExternalIP,Hostname'
  93. kubelet_custom_flags:
  94. - "--serialize-image-pulls=true"
  95. - "--eviction-hard=memory.available<1Gi"
  96. - "--eviction-soft-grace-period=memory.available=30s"
  97. - "--eviction-soft=memory.available<2Gi"
  98. - "--system-reserved cpu=100m,memory=4Gi"
  99. - "--eviction-minimum-reclaim=memory.available=2Gi"
  100. # DNS settings
  101. resolvconf_mode: none
  102. dns_min_replicas: 1
  103. upstream_dns_servers:
  104. - 1.1.1.1
  105. - 1.0.0.1
  106. # Extensions
  107. ingress_nginx_enabled: True
  108. helm_enabled: True
  109. cert_manager_enabled: True
  110. metrics_server_enabled: True
  111. # Enable ZSWAP
  112. kubelet_fail_swap_on: False
  113. kube_feature_gates:
  114. - "NodeSwap=True"
  115. ```
  116. ## Aditional files
  117. This section documents additional files used to complete a deployment of the kubespray CI, these files sit on the control-plane node and assume a working kubernetes cluster.
  118. ### /root/nscleanup.sh
  119. ```bash
  120. #!/bin/bash
  121. kubectl=/usr/local/bin/kubectl
  122. $kubectl get ns | grep -P "(\d.+-\d.+)" | awk 'match($3,/[0-9]+d/) {print $1}' | xargs -r $kubectl delete ns
  123. $kubectl get ns | grep -P "(\d.+-\d.+)" | awk 'match($3,/[3-9]+h/) {print $1}' | xargs -r $kubectl delete ns
  124. $kubectl get ns | grep Terminating | awk '{print $1}' | xargs -i $kubectl delete vmi/instance-1 vmi/instance-0 vmi/instance-2 -n {} --force --grace-period=0 &
  125. ```
  126. ### /root/path-calico.sh
  127. ```bash
  128. #!/bin/bash
  129. calicoctl patch felixconfig default -p '{"spec":{"allowIPIPPacketsFromWorkloads":true, "allowVXLANPacketsFromWorkloads": true}}'
  130. ```
  131. ### /root/kubevirt/kubevirt.sh
  132. ```bash
  133. #!/bin/bash
  134. export VERSION=$(curl -s https://api.github.com/repos/kubevirt/kubevirt/releases | grep tag_name | grep -v -- '-rc' | sort -r | head -1 | awk -F': ' '{print $2}' | sed 's/,//' | xargs)
  135. echo $VERSION
  136. kubectl apply -f https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/kubevirt-operator.yaml
  137. kubectl apply -f https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/kubevirt-cr.yaml
  138. ```
  139. ### /root/kubevirt/virtctl.sh
  140. ```bash
  141. #!/bin/bash
  142. VERSION=$(kubectl get kubevirt.kubevirt.io/kubevirt -n kubevirt -o=jsonpath="{.status.observedKubeVirtVersion}")
  143. ARCH=$(uname -s | tr A-Z a-z)-$(uname -m | sed 's/x86_64/amd64/') || windows-amd64.exe
  144. echo ${ARCH}
  145. curl -L -o virtctl https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/virtctl-${VERSION}-${ARCH}
  146. chmod +x virtctl
  147. sudo install virtctl /usr/local/bin
  148. ```