Use group clusters when deploying (DeploymentPlatform)
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 anyKUBE_TOKEN
DeploymentPlatform algorithm
-
Project-level cluster trumps group-level cluster, that is, if there's an env scope match, project level always wins.
-
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
andgroup_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 toCreateService
) -
Create kubernetes namespace + (make delete for old kubernetes namespace) on project transfer / removal from group - Projects::TransferService
-
clusters_kubernetes_namespaces
alreadynullifies
project on project delete -
Send KUBE_TOKEN
fromclusters_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
-
-
make a project cluster, set AUTO_DEVOPS_DOMAIN
variable at project level-
Enable group cluster -
Run auto devops pipeline - Expect deploy to project cluster
-
-
Disable group cluster and project cluster (Toggle OFF) -
Run auto devops pipeline again - Expect no production
job
-
Does this MR meet the acceptance criteria?
-
Changelog entry added, if necessary -
Documentation created/updated - https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/22804 -
Tests added for this feature/bug -
Conforms to the code review guidelines -
Conforms to the merge request performance guidelines - [-] Conforms to the style guides
-
Conforms to the database guides