Commit 577f1260 authored by Marcia Ramos's avatar Marcia Ramos

Merge branch 'docs/k8s-multiple-clusters' into 'master'

Multiple k8s clusters documentation

Closes #4320

See merge request gitlab-org/gitlab-ee!3800
parents ace1660a be466222
...@@ -79,6 +79,8 @@ learn how to leverage its potential even more. ...@@ -79,6 +79,8 @@ learn how to leverage its potential even more.
- [Trigger pipelines through the GitLab API](triggers/README.md) - [Trigger pipelines through the GitLab API](triggers/README.md)
- [Trigger pipelines on a schedule](../user/project/pipelines/schedules.md) - [Trigger pipelines on a schedule](../user/project/pipelines/schedules.md)
- [Deploy Boards](../user/project/deploy_boards.md) - Check the current health - [Deploy Boards](../user/project/deploy_boards.md) - Check the current health
- [Kubernetes clusters](../user/project/clusters/index.md) - Integrate one or
more Kubernetes clusters to your project
## Review Apps ## Review Apps
......
...@@ -30,7 +30,7 @@ In Google's side: ...@@ -30,7 +30,7 @@ In Google's side:
``` ```
https://gitlab.example.com/users/auth/google_oauth2/callback https://gitlab.example.com/users/auth/google_oauth2/callback
https://gitlab.exampl.com/-/google_api/auth/callback https://gitlab.example.com/-/google_api/auth/callback
``` ```
1. You should now be able to see a Client ID and Client secret. Note them down 1. You should now be able to see a Client ID and Client secret. Note them down
......
# Connecting GitLab with a Kubernetes cluster # Connecting GitLab with a Kubernetes cluster
> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/issues/35954) in 10.1. > [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/issues/35954) in GitLab 10.1.
CAUTION: **Warning:** CAUTION: **Warning:**
The Cluster integration is currently in **Beta**. The Cluster integration is currently in **Beta**.
NOTE: **Note:**
The Cluster integration will eventually supersede the
[Kubernetes integration](../integrations/kubernetes.md).
With a cluster associated to your project, you can use Review Apps, deploy your With a cluster associated to your project, you can use Review Apps, deploy your
applications, run your pipelines, and much more, in an easy way. applications, run your pipelines, and much more, in an easy way.
Connect your project to Google Kubernetes Engine (GKE) or your own Kubernetes Connect your project to Google Kubernetes Engine (GKE) or an existing Kubernetes
cluster in a few steps. cluster in a few steps.
NOTE: **Note:**
The Cluster integration will eventually supersede the
[Kubernetes integration](../integrations/kubernetes.md). For the moment,
you can create only one cluster.
## Prerequisites ## Prerequisites
In order to be able to manage your GKE cluster through GitLab, the following In order to be able to manage your Kubernetes cluster through GitLab, the
prerequisites must be met: following prerequisites must be met.
**For a cluster hosted on GKE:**
- The [Google authentication integration](../../../integration/google.md) must - The [Google authentication integration](../../../integration/google.md) must
be enabled in GitLab at the instance level. If that's not the case, ask your be enabled in GitLab at the instance level. If that's not the case, ask your
administrator to enable it. GitLab administrator to enable it.
- Your associated Google account must have the right privileges to manage - Your associated Google account must have the right privileges to manage
clusters on GKE. That would mean that a clusters on GKE. That would mean that a
[billing account](https://cloud.google.com/billing/docs/how-to/manage-billing-account) [billing account](https://cloud.google.com/billing/docs/how-to/manage-billing-account)
must be set up. must be set up.
- You must have Master [permissions] in order to be able to access the **Cluster**
page.
If all of the above requirements are met, you can proceed to add a new GKE **For an existing Kubernetes cluster:**
- Since the cluster is already created, there are no prerequisites.
---
If all of the above requirements are met, you can proceed to add a new Kubernetes
cluster. cluster.
## Adding a cluster ## Adding a Kubernetes cluster
NOTE: **Note:** NOTE: **Note:**
You need Master [permissions] and above to add a cluster. You need Master [permissions] and above to access the Clusters page.
There are two options when adding a new cluster; either use Google Kubernetes There are two options when adding a new cluster to your project; either associate
Engine (GKE) or provide the credentials to your own Kubernetes cluster. your account with Google Kubernetes Engine (GKE) so that you can create new
clusters from within GitLab, or provide the credentials to an existing
Kubernetes cluster.
To add a new cluster: Before proceeding to either method, make sure all [prerequisites](#prerequisites)
are met.
1. Navigate to your project's **CI/CD > Cluster** page **To add a new cluster hosted on GKE to your project:**
1. If you want to let GitLab create a cluster on GKE for you, go through the
following steps, otherwise skip to the next one. 1. Navigate to your project's **CI/CD > Clusters** page.
1. Click on **Create with GKE** 1. Click on **Add cluster**.
1. Connect your Google account if you haven't done already by clicking the 1. Click on **Create with GKE**.
**Sign in with Google** button 1. Connect your Google account if you haven't done already by clicking the
1. Fill in the requested values: **Sign in with Google** button.
1. Fill in the requested values:
- **Cluster name** (required) - The name you wish to give the cluster. - **Cluster name** (required) - The name you wish to give the cluster.
- **GCP project ID** (required) - The ID of the project you created in your GCP - **GCP project ID** (required) - The ID of the project you created in your GCP
console that will host the Kubernetes cluster. This must **not** be confused console that will host the Kubernetes cluster. This must **not** be confused
...@@ -62,10 +71,22 @@ To add a new cluster: ...@@ -62,10 +71,22 @@ To add a new cluster:
of the Virtual Machine instance that the cluster will be based on. of the Virtual Machine instance that the cluster will be based on.
- **Project namespace** - The unique namespace for this project. By default you - **Project namespace** - The unique namespace for this project. By default you
don't have to fill it in; by leaving it blank, GitLab will create one for you. don't have to fill it in; by leaving it blank, GitLab will create one for you.
1. If you want to use your own existing Kubernetes cluster, click on - **Environment scope** - The [associated environment](#setting-the-environment-scope) to this cluster.
**Add an existing cluster** and fill in the details as described in the 1. Finally, click the **Create cluster** button.
[Kubernetes integration](../integrations/kubernetes.md) documentation.
1. Finally, click the **Create cluster** button ---
**To add an existing cluster to your project:**
1. Navigate to your project's **CI/CD > Clusters** page.
1. Click on **Add cluster**.
1. Click on **Add an existing cluster** and fill in the details as described
in the [Kubernetes integration](../integrations/kubernetes.md#configuration)
documentation.
1. Select the [environment scope](#setting-the-environment-scope).
1. Finally, click the **Create cluster** button.
---
After a few moments, your cluster should be created. If something goes wrong, After a few moments, your cluster should be created. If something goes wrong,
you will be notified. you will be notified.
...@@ -110,4 +131,72 @@ To remove the Cluster integration from your project, simply click on the ...@@ -110,4 +131,72 @@ To remove the Cluster integration from your project, simply click on the
**Remove integration** button. You will then be able to follow the procedure **Remove integration** button. You will then be able to follow the procedure
and [add a cluster](#adding-a-cluster) again. and [add a cluster](#adding-a-cluster) again.
## Multiple Kubernetes clusters
> Introduced in [GitLab Enterprise Edition Premium][ee] 10.3.
With GitLab EEP, you can associate more than one Kubernetes clusters to your
project. That way you can have different clusters for different environments,
like dev, staging, production, etc.
To add another cluster, follow the same steps as described in [adding a
Kubernetes cluster](#adding-a-kubernetes-cluster) and make sure to
[set an environment scope](#setting-the-environment-scope) that will
differentiate the new cluster with the rest.
## Setting the environment scope
When adding more than one clusters, you need to differentiate them with an
environment scope. The environment scope associates clusters and
[environments](../../../ci/environments.md) in an 1:1 relationship similar to how the
[environment-specific variables](../../../ci/variables/README.md#limiting-environment-scopes-of-secret-variables)
work.
The default environment scope is `*`, which means all jobs, regardless of their
environment, will use that cluster. Each scope can only be used by a single
cluster in a project, and a validation error will occur if otherwise.
---
For example, let's say the following clusters exist in a project:
| Cluster | Environment scope |
| ---------- | ------------------- |
| Development| `*` |
| Staging | `staging/*` |
| Production | `production/*` |
And the following environments are set in [`.gitlab-ci.yml`](../../../ci/yaml/README.md):
```yaml
stages:
- test
- deploy
test:
stage: test
script: sh test
deploy to staging:
stage: deploy
script: make deploy
environment:
name: staging/$CI_COMMIT_REF_NAME
url: https://staging.example.com/
deploy to production:
stage: deploy
script: make deploy
environment:
name: production/$CI_COMMIT_REF_NAME
url: https://example.com/
```
The result will then be:
- The development cluster will be used for the "test" job.
- The staging cluster will be used for the "deploy to staging" job.
- The production cluster will be used for the "deploy to production" job.
[permissions]: ../../permissions.md [permissions]: ../../permissions.md
[ee]: https://about.gitlab.com/gitlab-ee/
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment