2020-05-11 23:09:31 -04:00
---
stage: Configure
group: Configure
2020-11-26 01:09:20 -05:00
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
2020-05-11 23:09:31 -04:00
---
2020-11-18 19:09:41 -05:00
# Cluster management project
2019-10-14 08:06:14 -04:00
2020-12-04 16:09:29 -05:00
WARNING:
2019-10-14 08:06:14 -04:00
This is an _alpha_ feature, and it is subject to change at any time without
prior notice.
2020-05-21 23:08:28 -04:00
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/32810) in GitLab 12.5
2019-10-14 08:06:14 -04:00
A project can be designated as the management project for a cluster.
A management project can be used to run deployment jobs with
Kubernetes
[`cluster-admin` ](https://kubernetes.io/docs/reference/access-authn-authz/rbac/#user-facing-roles )
privileges.
This can be useful for:
2020-12-10 19:09:41 -05:00
- Creating pipelines to install cluster-wide applications into your cluster, see [Install using GitLab CI/CD (alpha) ](applications.md#install-using-gitlab-cicd ) for details.
2019-10-14 08:06:14 -04:00
- Any jobs that require `cluster-admin` privileges.
## Permissions
2020-11-18 19:09:41 -05:00
Only the management project receives `cluster-admin` privileges. All
other projects continue to receive [namespace scoped `edit` level privileges ](../project/clusters/add_remove_clusters.md#rbac-cluster-resources ).
2019-10-14 08:06:14 -04:00
2019-10-24 08:06:03 -04:00
Management projects are restricted to the following:
2020-02-06 22:08:59 -05:00
- For project-level clusters, the management project must be in the same
2019-10-24 08:06:03 -04:00
namespace (or descendants) as the cluster's project.
2020-02-06 22:08:59 -05:00
- For group-level clusters, the management project must be in the same
2020-04-08 02:09:54 -04:00
group (or descendants) as the cluster's group.
2019-10-24 08:06:03 -04:00
- For instance-level clusters, there are no such restrictions.
2019-10-14 08:06:14 -04:00
## Usage
2019-11-13 22:06:25 -05:00
To use a cluster management project for a cluster:
1. Select the project.
1. Configure your pipelines.
1. Set an environment scope.
2019-10-14 08:06:14 -04:00
### Selecting a cluster management project
2019-11-13 22:06:25 -05:00
To select a cluster management project to use:
1. Navigate to the appropriate configuration page. For a:
- [Project-level cluster ](../project/clusters/index.md ), navigate to your project's
**Operations > Kubernetes** page.
- [Group-level cluster ](../group/clusters/index.md ), navigate to your group's **Kubernetes**
page.
2020-03-18 02:09:38 -04:00
- [Instance-level cluster ](../instance/clusters/index.md ), navigate to Admin Area's **Kubernetes**
page.
2019-11-13 22:06:25 -05:00
1. Select the project using **Cluster management project field** in the **Advanced settings**
section.
2019-11-12 01:06:32 -05:00
![Selecting a cluster management project under Advanced settings ](img/advanced-settings-cluster-management-project-v12_5.png )
2019-10-14 08:06:14 -04:00
### Configuring your pipeline
After designating a project as the management project for the cluster,
2019-11-21 19:06:08 -05:00
write a [`.gitlab-ci.yml` ](../../ci/yaml/README.md ) in that project. For example:
2019-10-14 08:06:14 -04:00
```yaml
configure cluster:
stage: deploy
script: kubectl get namespaces
environment:
name: production
```
2020-08-12 20:10:06 -04:00
### Setting the environment scope
2019-10-14 08:06:14 -04:00
[Environment
2020-08-12 20:10:06 -04:00
scopes](../project/clusters/index.md#setting-the-environment-scope)
2019-10-14 08:06:14 -04:00
are usable when associating multiple clusters to the same management
project.
Each scope can only be used by a single cluster for a management project.
For example, let's say the following Kubernetes clusters are associated
to a management project:
| Cluster | Environment scope |
| ----------- | ----------------- |
| Development | `*` |
| Staging | `staging` |
| Production | `production` |
2019-11-18 01:06:20 -05:00
The following environments set in
2020-11-18 19:09:41 -05:00
[`.gitlab-ci.yml` ](../../ci/yaml/README.md ) deploy to the
2019-10-14 08:06:14 -04:00
Development, Staging, and Production cluster respectively.
```yaml
stages:
2020-07-03 05:08:53 -04:00
- deploy
2019-10-14 08:06:14 -04:00
configure development cluster:
stage: deploy
script: kubectl get namespaces
environment:
name: development
configure staging cluster:
stage: deploy
script: kubectl get namespaces
environment:
name: staging
configure production cluster:
stage: deploy
script: kubectl get namespaces
environment:
name: production
```