Add existing instance cluster

POST /admin/clusters/add

This feature was introduced in GitLab 13.2. Adds an existing Kubernetes instance cluster.

application/json

Body Required

  • name string Required

    Cluster name

  • enabled boolean

    Determines if cluster is active or not, defaults to true

    Default value is true.

  • environment_scope string

    The associated environment to the cluster

    Default value is *.

  • namespace_per_environment boolean

    Deploy each environment to a separate Kubernetes namespace

    Default value is true.

  • domain string

    Cluster base domain

  • management_project_id integer(int32)

    The ID of the management project

  • managed boolean

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

    Default value is true.

  • platform_kubernetes_attributes[api_url] string Required

    URL to access the Kubernetes API

  • platform_kubernetes_attributes[token] string Required

    Token to authenticate against Kubernetes

  • platform_kubernetes_attributes[ca_cert] string

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

  • platform_kubernetes_attributes[namespace] string

    Unique namespace related to Project

  • platform_kubernetes_attributes[authorization_type] string

    Cluster authorization type, defaults to RBAC

    Values are unknown_authorization, rbac, or abac. Default value is rbac.

Responses

  • 201 application/json

    Add existing instance cluster

    Hide response attributes Show response attributes 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
      Hide user attributes Show user attributes object
      • id integer(int32)
      • username string
      • name string
      • state string
      • avatar_url string
      • avatar_path string
      • custom_attributes array[object]
        Hide custom_attributes attributes Show custom_attributes attributes object
        • key string
        • value string
      • web_url string
      • email string
    • platform_kubernetes object
      Hide platform_kubernetes attributes Show platform_kubernetes attributes object
      • api_url string
      • namespace string
      • authorization_type string
      • ca_cert string
    • provider_gcp object
      Hide provider_gcp attributes Show provider_gcp attributes object
      • cluster_id string
      • status_name string
      • gcp_project_id string
      • zone string
      • machine_type string
      • num_nodes string
      • endpoint string
    • management_project object
      Hide management_project attributes Show management_project attributes object
      • id integer(int32)
      • description string
      • name string
      • name_with_namespace string
      • path string
      • path_with_namespace string
      • created_at string(date-time)
  • 400

    Validation error

  • 403

    Forbidden

  • 404

    Not found

POST /admin/clusters/add
curl \
 --request POST 'https://www.gitlab.com/api/v4/admin/clusters/add' \
 --header "Private-Token: $API_KEY" \
 --header "Content-Type: application/json" \
 --data '{"name":"string","enabled":true,"environment_scope":"*","namespace_per_environment":true,"domain":"string","management_project_id":42,"managed":true,"platform_kubernetes_attributes[api_url]":"string","platform_kubernetes_attributes[token]":"string","platform_kubernetes_attributes[ca_cert]":"string","platform_kubernetes_attributes[namespace]":"string","platform_kubernetes_attributes[authorization_type]":"rbac"}'
Request examples
{
  "name": "string",
  "enabled": true,
  "environment_scope": "*",
  "namespace_per_environment": true,
  "domain": "string",
  "management_project_id": 42,
  "managed": true,
  "platform_kubernetes_attributes[api_url]": "string",
  "platform_kubernetes_attributes[token]": "string",
  "platform_kubernetes_attributes[ca_cert]": "string",
  "platform_kubernetes_attributes[namespace]": "string",
  "platform_kubernetes_attributes[authorization_type]": "rbac"
}
Response examples (201)
{
  "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": {
    "id": 1,
    "username": "admin",
    "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",
    "email": "string"
  },
  "platform_kubernetes": {
    "api_url": "string",
    "namespace": "string",
    "authorization_type": "string",
    "ca_cert": "string"
  },
  "provider_gcp": {
    "cluster_id": "string",
    "status_name": "string",
    "gcp_project_id": "string",
    "zone": "string",
    "machine_type": "string",
    "num_nodes": "string",
    "endpoint": "string"
  },
  "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:17Z"
  }
}