Instance clusters API

Instance clusters API

在 GitLab 13.2 中引入 .

注意:用户将需要管理员权限才能使用这些端点.

将这些 API 端点与实例集群一起使用,使您可以在多个项目中使用同一集群.

返回实例集群的列表.

请求示例:

响应示例:

  1. [ { "id": 9, "name": "cluster-1", "created_at": "2020-07-14T18:36:10.440Z", "domain": null, "provider_type": "user", "platform_type": "kubernetes", "environment_scope": "*", "cluster_type": "instance_type", "user": { "id": 1, "name": "Administrator", "username": "root", "state": "active", "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", "web_url": "https://gitlab.example.com/root" }, "platform_kubernetes": { "api_url": "https://example.com", "namespace": null, "authorization_type": "rbac", "ca_cert":"-----BEGIN CERTIFICATE-----IxMDM1MV0ZDJkZjM...-----END CERTIFICATE-----" }, "provider_gcp": null, "management_project": null }, { "id": 10, "name": "cluster-2", "created_at": "2020-07-14T18:39:05.383Z", "domain": null, "provider_type": "user", "platform_type": "kubernetes", "environment_scope": "staging", "cluster_type": "instance_type", "user": { "id": 1, "name": "Administrator", "username": "root", "state": "active", "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", "web_url": "https://gitlab.example.com/root" }, "platform_kubernetes": { "api_url": "https://example.com", "namespace": null, "authorization_type": "rbac", "ca_cert":"-----BEGIN CERTIFICATE-----LzEtMCadtaLGxcsGAZjM...-----END CERTIFICATE-----" }, "provider_gcp": null, "management_project": null } { "id": 11, "name": "cluster-3", ... } ]

Parameters:

  1. GET /admin/clusters/:cluster_id

请求示例:

响应示例:

  1. { "id": 9, "name": "cluster-1", "created_at": "2020-07-14T18:36:10.440Z", "domain": null, "provider_type": "user", "platform_type": "kubernetes", "environment_scope": "*", "cluster_type": "instance_type", "user": { "id": 1, "name": "Administrator", "username": "root", "state": "active", "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", "web_url": "https://gitlab.example.com/root" }, "platform_kubernetes": { "api_url": "https://example.com", "namespace": null, "authorization_type": "rbac", "ca_cert":"-----BEGIN CERTIFICATE-----IxMDM1MV0ZDJkZjM...-----END CERTIFICATE-----" }, "provider_gcp": null, "management_project": null }

添加现有的 Kubernetes 实例集群.

  1. POST /admin/clusters/add

Parameters:

请求示例:

  1. curl --header "Private-Token:<your_access_token>" "http://gitlab.example.com/api/v4/admin/clusters/add" \
  2. -H "Content-Type:application/json" \
  3. -X POST --data '{"name":"cluster-3", "environment_scope":"production", "platform_kubernetes_attributes":{"api_url":"https://example.com", "token":"12345", "ca_cert":"-----BEGIN CERTIFICATE-----qpoeiXXZafCM0ZDJkZjM...-----END CERTIFICATE-----"}}'

更新现有的实例集群.

  1. PUT /admin/clusters/:cluster_id

Parameters:

注意:仅通过通过添加现有 Kubernetes 集群选项或通过端点添加集群时,才能更新nameapi_urlca_certtoken .

请求示例:

  1. curl --header "Private-Token: <your_access_token>" "http://gitlab.example.com/api/v4/admin/clusters/9" \
  2. -H "Content-Type:application/json" \
  3. -X PUT --data '{"name":"update-cluster-name", "platform_kubernetes_attributes":{"api_url":"https://new-example.com","token":"new-token"}}'

响应示例:

  1. { "id": 9, "name": "update-cluster-name", "created_at": "2020-07-14T18:36:10.440Z", "domain": null, "provider_type": "user", "platform_type": "kubernetes", "environment_scope": "*", "cluster_type": "instance_type", "user": { "id": 1, "name": "Administrator", "username": "root", "state": "active", "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", "web_url": "https://gitlab.example.com/root" }, "platform_kubernetes": { "api_url": "https://new-example.com", "namespace": null, "authorization_type": "rbac", "ca_cert":"-----BEGIN CERTIFICATE-----IxMDM1MV0ZDJkZjM...-----END CERTIFICATE-----" }, "provider_gcp": null, "management_project": null, "project": null }

删除现有的实例集群.

请求示例:

  1. curl --request DELETE --header "Private-Token: <your_access_token>" "https://gitlab.example.com/api/v4/admin/clusters/11"