インスタンスクラスタAPI(証明書ベース)(非推奨)
この機能はGitLab 14.5で非推奨となりました。
インスタンスレベルのKubernetesクラスターでは、KubernetesクラスターをGitLabインスタンスに接続し、インスタンス内のすべてのプロジェクトで同じクラスターを使用することができます。
ユーザーがこれらのエンドポイントを使用するには管理者権限が必要です。
インスタンス・クラスターの一覧
インスタンス・クラスターのリストを返します。
GET /admin/clusters
リクエストの例
curl --header "Private-Token: <your_access_token>" "https://gitlab.example.com/api/v4/admin/clusters"
応答例
[
  {
    "id": 9,
    "name": "cluster-1",
    "created_at": "2020-07-14T18:36:10.440Z",
    "managed": true,
    "enabled": true,
    "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",
    ...
  }
]
インスタンスクラスタの取得
単一のインスタンスクラスタを返します。
パラメータを指定します:
| 属性 | 種類 | 必須 | 説明 | 
|---|---|---|---|
| cluster_id | 整数。 | yes | クラスターのID | 
GET /admin/clusters/:cluster_id
リクエストの例
curl --header "Private-Token: <your_access_token>" "https://gitlab.example.com/api/v4/admin/clusters/9"
応答例
{
  "id": 9,
  "name": "cluster-1",
  "created_at": "2020-07-14T18:36:10.440Z",
  "managed": true,
  "enabled": true,
  "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インスタンスクラスタを追加します。
POST /admin/clusters/add
パラメータを指定します:
| 属性 | 種類 | 必須 | 説明 | 
|---|---|---|---|
| name | 文字列です。 | yes | クラスターの名前 | 
| domain | 文字列です。 | いいえ | クラスターのベースドメイン | 
| environment_scope | 文字列です。 | いいえ | クラスターに関連付けられた環境。デフォルトは * | 
| management_project_id | 整数。 | いいえ | クラスターの管理プロジェクトのID | 
| enabled | boolean | いいえ | クラスターがアクティブかどうかを決定します。 true | 
| managed | boolean | いいえ | GitLabがこのクラスターの名前空間とサービスアカウントを管理するかどうかを決定します。デフォルトは true | 
| platform_kubernetes_attributes[api_url] | 文字列です。 | yes | Kubernetes APIにアクセスするためのURL。 | 
| platform_kubernetes_attributes[token] | 文字列です。 | yes | Kubernetesに対して認証するためのトークンです。 | 
| platform_kubernetes_attributes[ca_cert] | 文字列です。 | いいえ | TLS証明書。APIが自己署名TLS証明書を使用している場合は必要です。 | 
| platform_kubernetes_attributes[namespace] | 文字列です。 | いいえ | プロジェクトに関連する固有の名前空間 | 
| platform_kubernetes_attributes[authorization_type] | 文字列です。 | いいえ | クラスター作成者タイプ: rbacabacまたはunknown_authorization。デフォルトはrbacです。 | 
リクエストの例
curl --header "Private-Token:<your_access_token>" "http://gitlab.example.com/api/v4/admin/clusters/add" \
-H "Accept:application/json" \
-H "Content-Type:application/json" \
-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-----"}}'
応答例
{
  "id": 11,
  "name": "cluster-3",
  "created_at": "2020-07-14T18:42:50.805Z",
  "managed": true,
  "enabled": true,
  "domain": null,
  "provider_type": "user",
  "platform_type": "kubernetes",
  "environment_scope": "production",
  "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": "http://gitlab.example.com:3000/root"
  },
  "platform_kubernetes": {
    "api_url": "https://example.com",
    "namespace": null,
    "authorization_type": "rbac",
    "ca_cert":"-----BEGIN CERTIFICATE-----qpoeiXXZafCM0ZDJkZjM...-----END CERTIFICATE-----"
  },
  "provider_gcp": null,
  "management_project": null
}
インスタンス・クラスターの編集
既存のインスタンス・クラスターを更新します。
PUT /admin/clusters/:cluster_id
パラメータを指定します:
| 属性 | 種類 | 必須 | 説明 | 
|---|---|---|---|
| cluster_id | 整数。 | yes | クラスターのID | 
| name | 文字列です。 | いいえ | クラスターの名前 | 
| domain | 文字列です。 | いいえ | クラスターのベースドメイン | 
| environment_scope | 文字列です。 | いいえ | クラスターに関連する環境 | 
| management_project_id | 整数。 | いいえ | クラスターの管理プロジェクトのID | 
| enabled | boolean | いいえ | クラスターがアクティビティかどうかを判断します。 | 
| managed | boolean | いいえ | GitLabがこのクラスターの名前空間とサービスアカウントを管理するかどうかを決定します | 
| platform_kubernetes_attributes[api_url] | 文字列です。 | いいえ | Kubernetes APIにアクセスするためのURL。 | 
| platform_kubernetes_attributes[token] | 文字列です。 | いいえ | Kubernetesに対して認証するためのトークンです。 | 
| platform_kubernetes_attributes[ca_cert] | 文字列です。 | いいえ | TLS証明書。APIが自己署名TLS証明書を使用している場合は必要です。 | 
| platform_kubernetes_attributes[namespace] | 文字列です。 | いいえ | プロジェクトに関連する固有の名前空間 | 
name,api_url,ca_cert およびtoken は、クラスターがAdd existing Kubernetes clusterオプションまたはAdd existing instance clusterエンドポイントを通じて追加された場合にのみ更新できます。リクエストの例
curl --header "Private-Token: <your_access_token>" "http://gitlab.example.com/api/v4/admin/clusters/9" \
-H "Content-Type:application/json" \
-X PUT --data '{"name":"update-cluster-name", "platform_kubernetes_attributes":{"api_url":"https://new-example.com","token":"new-token"}}'
応答例
{
  "id": 9,
  "name": "update-cluster-name",
  "created_at": "2020-07-14T18:36:10.440Z",
  "managed": true,
  "enabled": true,
  "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
}
インスタンス・クラスターの削除
既存のインスタンスクラスタを削除します。接続されているKubernetesクラスター内の既存のリソースは削除しません。
DELETE /admin/clusters/:cluster_id
パラメータを指定します:
| 属性 | 種類 | 必須 | 説明 | 
|---|---|---|---|
| cluster_id | 整数。 | yes | クラスターのID | 
リクエストの例
curl --request DELETE --header "Private-Token: <your_access_token>" "https://gitlab.example.com/api/v4/admin/clusters/11"
