Skip to content

Add a cluster to a project

POST
/api/v4/projects/{id}/clusters/user

Adds a cluster to a specified project.

id
required
One of:
string

The ID or URL-encoded path of the project

Media type application/json
object
name
required

Cluster name

string
nullable
enabled

Determines if cluster is active or not, defaults to true

boolean
default: true nullable
domain

Cluster base domain

string
nullable
environment_scope

The associated environment to the cluster

string
default: * nullable
namespace_per_environment

Deploy each environment to a separate Kubernetes namespace

boolean
default: true nullable
management_project_id

The ID of the management project

integer
nullable
managed

Determines if GitLab will manage namespaces and service accounts for this cluster, defaults to true

boolean
default: true nullable
platform_kubernetes_attributes
required

Platform Kubernetes data

object
api_url
required

URL to access the Kubernetes API

string
nullable
token
required

Token to authenticate against Kubernetes

string
nullable
ca_cert

TLS certificate (needed if API is using a self-signed TLS certificate)

string
nullable
namespace

Unique namespace related to Project

string
nullable
authorization_type

Cluster authorization type, defaults to RBAC

string
default: rbac nullable
Allowed values: unknown_authorization rbac abac

Created

Media type application/json
object
id
string
name
string
created_at
string
domain
string
enabled
string
managed
string
provider_type
string
platform_type
string
environment_scope
string
cluster_type
string
namespace_per_environment
string
user
object
id
integer format: int64
username
string
public_email
string
name
string
state
string
locked
boolean
avatar_url
string
avatar_path
string
custom_attributes
Array<object>
object
key
string
value
string
web_url
string
platform_kubernetes
object
api_url
string
namespace
string
authorization_type
string
ca_cert
string
provider_gcp
object
cluster_id
string
status_name
string
gcp_project_id
string
zone
string
machine_type
string
num_nodes
string
endpoint
string
management_project
object
id
integer format: int64
description
string
name
string
name_with_namespace
string
path
string
path_with_namespace
string
created_at
string format: date-time
project
object
id
integer format: int64
description
string
name
string
name_with_namespace
string
path
string
path_with_namespace
string
created_at
string format: date-time
default_branch
string
tag_list
Array<string>
topics
Array<string>
ssh_url_to_repo
string
http_url_to_repo
string
web_url
string
readme_url
string
forks_count
integer
license_url
string
license
object
key
string
name
string
nickname
string
html_url
string
source_url
string
avatar_url
string
star_count
integer
last_activity_at
string format: date-time
visibility
string
namespace
object
id
integer format: int64
name
string
path
string
kind
string
full_path
string
parent_id
integer format: int64
avatar_url
string
web_url
string
custom_attributes
object
key
string
value
string
repository_storage
string
Example
{
"user": {
"id": 1,
"username": "admin",
"public_email": "john@example.com",
"name": "Administrator",
"state": "active",
"avatar_url": "https://gravatar.com/avatar/1",
"avatar_path": "/user/avatar/28/The-Big-Lebowski-400-400.png",
"custom_attributes": [
{
"key": "foo",
"value": "bar"
}
],
"web_url": "https://gitlab.example.com/root"
},
"management_project": {
"id": 1,
"description": "desc",
"name": "project1",
"name_with_namespace": "John Doe / project1",
"path": "project1",
"path_with_namespace": "namespace1/project1",
"created_at": "2020-05-07T04:27:17.016Z"
},
"project": {
"id": 1,
"description": "desc",
"name": "project1",
"name_with_namespace": "John Doe / project1",
"path": "project1",
"path_with_namespace": "namespace1/project1",
"created_at": "2020-05-07T04:27:17.016Z",
"default_branch": "main",
"tag_list": [
"tag"
],
"topics": [
"topic"
],
"ssh_url_to_repo": "git@gitlab.example.com:gitlab/gitlab.git",
"http_url_to_repo": "https://gitlab.example.com/gitlab/gitlab.git",
"web_url": "https://gitlab.example.com/gitlab/gitlab",
"readme_url": "https://gitlab.example.com/gitlab/gitlab/blob/master/README.md",
"forks_count": 1,
"license_url": "https://gitlab.example.com/gitlab/gitlab/blob/master/LICENCE",
"license": {
"key": "gpl-3.0",
"name": "GNU General Public License v3.0",
"nickname": "GNU GPLv3",
"html_url": "http://choosealicense.com/licenses/gpl-3.0"
},
"avatar_url": "http://example.com/uploads/project/avatar/3/uploads/avatar.png",
"star_count": 1,
"last_activity_at": "2013-09-30T13:46:02Z",
"visibility": "public",
"namespace": {
"id": 2,
"name": "project",
"path": "my_project",
"kind": "project",
"full_path": "group/my_project",
"parent_id": 1,
"avatar_url": "https://example.com/avatar/12345",
"web_url": "https://example.com/group/my_project"
},
"custom_attributes": {
"key": "foo",
"value": "bar"
},
"repository_storage": "default"
}
}

Validation error

Forbidden

Not found