Skip to content

Use group clusters when deploying (DeploymentPlatform)

Thong Kuah requested to merge 34758-deployment-cluster into master

What does this MR do?

  • Creates KubenernetesNamespace for each project in group cluster

  • Updates DeploymentPlatform to use group level clusters. EE Merge Request

  • If for any reason the project does not have a KubernetesNamespace for the group cluster, then we will not return any KUBE_TOKEN

DeploymentPlatform algorithm

  1. Project-level cluster trumps group-level cluster, that is, if there's an env scope match, project level always wins.

  2. Sub-groups will determine which cluster to use by looking at closest ancestor with a matching env scope pattern.

Notes

NOTE: This MR also introduces a hierarchy_order option to Gitlab::GroupHierarchy which enables us to now explicitly order the query.

NOTE: This MR also enables group_clusters FF by default

There is a subsequent MR which depends on this MR

What are the relevant issue numbers?

#34758 (closed), #53592 (closed)

Tasks

  • Combine deploy_group_clusters and group_clusters flags
  • Add feature flag
  • Create kubernetes namespace for projects in group on cluster creation
  • Create kubernetes namespace on project creation - Projects::CreateService (Projects::ForkService calls out to CreateService)
  • Create kubernetes namespace + (make delete for old kubernetes namespace) on project transfer / removal from group - Projects::TransferService
  • clusters_kubernetes_namespaces already nullifies project on project delete
  • Send KUBE_TOKEN from clusters_kubernetes_namespaces for group cluster
  • Refresh service part 1 - add missing namespaces
  • [-] Refresh service part 2 - Clean up old kubernetes namespace - Follow up in https://gitlab.com/gitlab-org/gitlab-ce/issues/53591
  • KUBE_TOKEN - only return KUBE_TOKEN for the kubernetes namespace for the project (and not other projects!)
  • create or update k8s resources in create_service_account_service.rb

Testing / Screenshots

  • Make a group cluster
    • Add a group CI variable for AUTO_DEVOPS_DOMAIN
    • Run auto devops pipeline on a project in the group - Expect deploy to group cluster

Screen_Shot_2018-12-03_at_3.22.51_PM

  • make a project cluster, set AUTO_DEVOPS_DOMAIN variable at project level
    • Enable group cluster
    • Run auto devops pipeline - Expect deploy to project cluster

Screen_Shot_2018-12-03_at_3.31.40_PM

  • Disable group cluster and project cluster (Toggle OFF)
    • Run auto devops pipeline again - Expect no production job

Screen_Shot_2018-12-03_at_3.46.25_PM

Does this MR meet the acceptance criteria?

Edited by 🤖 GitLab Bot 🤖

Merge request reports