正式なドキュメントは英語版であり、この日本語訳はAI支援翻訳により作成された参考用のものです。日本語訳の一部の内容は人間によるレビューがまだ行われていないため、翻訳のタイミングにより英語版との間に差異が生じることがあります。最新かつ正確な情報については、英語版をご参照ください。

インスタンスクラスターAPI(証明書ベース)(非推奨)

  • プラン: Free、Premium、Ultimate
  • 提供形態: GitLab Self-Managed

この機能はGitLab 14.5で非推奨になりました。

インスタンスレベルのKubernetesクラスターを使用すると、KubernetesクラスターをGitLabインスタンスに接続し、そのインスタンス内のすべてのプロジェクトで同じクラスターを使用できます。

ユーザーには、これらのエンドポイントを使用するための管理者アクセスが必要です。

インスタンスクラスターを一覧表示

すべてのインスタンスクラスターを一覧表示します。

GET /admin/clusters

リクエスト例:

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "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整数はいクラスターのID
GET /admin/clusters/:cluster_id

リクエスト例:

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "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文字列はいクラスターの名前
domain文字列いいえクラスターのベースドメイン
environment_scope文字列いいえクラスターに関連付けられた環境。デフォルトは*です。
management_project_id整数いいえクラスターの管理プロジェクトのID
enabledブール値いいえクラスターがアクティブであるかどうかを決定し、trueにデフォルト設定されます。
managedブール値いいえGitLabがこのクラスターのネームスペースとサービスアカウントを管理するかどうかを決定します。デフォルトはtrueです。
platform_kubernetes_attributes[api_url]文字列はいKubernetesAPIにアクセスするためのURL
platform_kubernetes_attributes[token]文字列はいKubernetesに対して認証するためのトークン
platform_kubernetes_attributes[ca_cert]文字列いいえTLS証明書。APIが自己署名TLS証明書を使用している場合は必須です。
platform_kubernetes_attributes[namespace]文字列いいえプロジェクトに関連する一意のネームスペース
platform_kubernetes_attributes[authorization_type]文字列いいえクラスターの認可タイプ: rbacabac、またはunknown_authorizationrbacがデフォルトです。

リクエスト例:

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

レスポンス例:

{
  "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整数はいクラスターのID
name文字列いいえクラスターの名前
domain文字列いいえクラスターのベースドメイン
environment_scope文字列いいえクラスターに関連付けられた環境
management_project_id整数いいえクラスターの管理プロジェクトのID
enabledブール値いいえクラスターがアクティブであるかどうかを決定します
managedブール値いいえGitLabがこのクラスターのネームスペースとサービスアカウントを管理するかどうかを決定します
platform_kubernetes_attributes[api_url]文字列いいえKubernetesAPIにアクセスするためのURL
platform_kubernetes_attributes[token]文字列いいえKubernetesに対して認証するためのトークン
platform_kubernetes_attributes[ca_cert]文字列いいえTLS証明書。APIが自己署名TLS証明書を使用している場合は必須です。
platform_kubernetes_attributes[namespace]文字列いいえプロジェクトに関連する一意のネームスペース

nameapi_urlca_cert、およびtokenは、クラスターが既存のKubernetesクラスターを追加オプションまたはインスタンスクラスターを作成エンドポイントを介して追加された場合にのみ更新できます。

リクエスト例:

curl --request PUT \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --header "Content-Type: application/json" \
  --data '{"name":"update-cluster-name", "platform_kubernetes_attributes":{"api_url":"https://new-example.com","token":"new-token"}}' \
  --url "http://gitlab.example.com/api/v4/admin/clusters/9"

レスポンス例:

{
  "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整数はいクラスターのID

リクエスト例:

curl --request DELETE \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/admin/clusters/11"