グループクラスタAPI(証明書ベース)(非推奨)
この機能はGitLab 14.5で非推奨となりました。
プロジェクトレベルや インスタンスレベルのKubernetesクラスタと同様に、グループレベルのKubernetesクラスタでは、Kubernetesクラスタをグループに接続することができ、複数のプロジェクトで同じクラスタを使用することができます。
ユーザーがこれらのエンドポイントを使用するには、少なくともグループのメンテナーのロールが必要です。
グループ・クラスターの一覧
グループ・クラスターのリストを返します。
GET /groups/:id/clusters
パラメータを指定します:
属性 | 種類 | 必須 | 説明 |
---|---|---|---|
id | 整数/文字列 | yes | グループのIDまたはURLエンコードされたパス |
リクエストの例
curl --header "Private-Token: <your_access_token>" "https://gitlab.example.com/api/v4/groups/26/clusters"
応答例
[
{
"id":18,
"name":"cluster-1",
"domain":"example.com",
"created_at":"2019-01-02T20:18:12.563Z",
"managed": true,
"enabled": true,
"provider_type":"user",
"platform_type":"kubernetes",
"environment_scope":"*",
"cluster_type":"group_type",
"user":
{
"id":1,
"name":"Administrator",
"username":"root",
"state":"active",
"avatar_url":"https://www.gravatar.com/avatar/4249f4df72b..",
"web_url":"https://gitlab.example.com/root"
},
"platform_kubernetes":
{
"api_url":"https://104.197.68.152",
"authorization_type":"rbac",
"ca_cert":"-----BEGIN CERTIFICATE-----\r\nhFiK1L61owwDQYJKoZIhvcNAQELBQAw\r\nLzEtMCsGA1UEAxMkZDA1YzQ1YjctNzdiMS00NDY0LThjNmEtMTQ0ZDJkZjM4ZDBj\r\nMB4XDTE4MTIyNzIwMDM1MVoXDTIzMTIyNjIxMDM1MVowLzEtMCsGA1UEAxMkZDA1\r\nYzQ1YjctNzdiMS00NDY0LThjNmEtMTQ0ZDJkZjM.......-----END CERTIFICATE-----"
},
"management_project":
{
"id":2,
"description":null,
"name":"project2",
"name_with_namespace":"John Doe8 / project2",
"path":"project2",
"path_with_namespace":"namespace2/project2",
"created_at":"2019-10-11T02:55:54.138Z"
}
},
{
"id":19,
"name":"cluster-2",
...
}
]
単一のグループ クラスターの取得
単一のグループ・クラスターを取得します。
GET /groups/:id/clusters/:cluster_id
パラメータを指定します:
属性 | 種類 | 必須 | 説明 |
---|---|---|---|
id | 整数/文字列 | yes | グループのIDまたはURLエンコードされたパス |
cluster_id | 整数。 | yes | クラスターのID |
リクエストの例
curl --header "Private-Token: <your_access_token>" "https://gitlab.example.com/api/v4/groups/26/clusters/18"
応答例
{
"id":18,
"name":"cluster-1",
"domain":"example.com",
"created_at":"2019-01-02T20:18:12.563Z",
"managed": true,
"enabled": true,
"provider_type":"user",
"platform_type":"kubernetes",
"environment_scope":"*",
"cluster_type":"group_type",
"user":
{
"id":1,
"name":"Administrator",
"username":"root",
"state":"active",
"avatar_url":"https://www.gravatar.com/avatar/4249f4df72b..",
"web_url":"https://gitlab.example.com/root"
},
"platform_kubernetes":
{
"api_url":"https://104.197.68.152",
"authorization_type":"rbac",
"ca_cert":"-----BEGIN CERTIFICATE-----\r\nhFiK1L61owwDQYJKoZIhvcNAQELBQAw\r\nLzEtMCsGA1UEAxMkZDA1YzQ1YjctNzdiMS00NDY0LThjNmEtMTQ0ZDJkZjM4ZDBj\r\nMB4XDTE4MTIyNzIwMDM1MVoXDTIzMTIyNjIxMDM1MVowLzEtMCsGA1UEAxMkZDA1\r\nYzQ1YjctNzdiMS00NDY0LThjNmEtMTQ0ZDJkZjM.......-----END CERTIFICATE-----"
},
"management_project":
{
"id":2,
"description":null,
"name":"project2",
"name_with_namespace":"John Doe8 / project2",
"path":"project2",
"path_with_namespace":"namespace2/project2",
"created_at":"2019-10-11T02:55:54.138Z"
},
"group":
{
"id":26,
"name":"group-with-clusters-api",
"web_url":"https://gitlab.example.com/group-with-clusters-api"
}
}
既存のクラスターをグループに追加します。
既存のKubernetesクラスターをグループに追加します。
POST /groups/:id/clusters/user
パラメータを指定します:
属性 | 種類 | 必須 | 説明 |
---|---|---|---|
id | 整数/文字列 | yes | グループのIDまたはURLエンコードされたパス |
name | 文字列です。 | yes | クラスターの名前 |
domain | 文字列です。 | いいえ | クラスターのベースドメイン |
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[authorization_type] | 文字列です。 | いいえ | クラスター作成者タイプ:rbac abac またはunknown_authorization 。デフォルトはrbac です。 |
environment_scope | 文字列です。 | いいえ | クラスターに関連付けられた環境。デフォルトは* です。
|
リクエストの例
curl --header "Private-Token: <your_access_token>" "https://gitlab.example.com/api/v4/groups/26/clusters/user" \
-H "Accept: application/json" \
-H "Content-Type:application/json" \
--request POST --data '{"name":"cluster-5", "platform_kubernetes_attributes":{"api_url":"https://35.111.51.20","token":"12345","ca_cert":"-----BEGIN CERTIFICATE-----\r\nhFiK1L61owwDQYJKoZIhvcNAQELBQAw\r\nLzEtMCsGA1UEAxMkZDA1YzQ1YjctNzdiMS00NDY0LThjNmEtMTQ0ZDJkZjM4ZDBj\r\nMB4XDTE4MTIyNzIwMDM1MVoXDTIzMTIyNjIxMDM1MVowLzEtMCsGA1UEAxMkZDA1\r\nYzQ1YjctNzdiMS00NDY0LThjNmEtMTQ0ZDJkZjM.......-----END CERTIFICATE-----"}}'
応答例
{
"id":24,
"name":"cluster-5",
"created_at":"2019-01-03T21:53:40.610Z",
"managed": true,
"enabled": true,
"provider_type":"user",
"platform_type":"kubernetes",
"environment_scope":"*",
"cluster_type":"group_type",
"user":
{
"id":1,
"name":"Administrator",
"username":"root",
"state":"active",
"avatar_url":"https://www.gravatar.com/avatar/4249f4df72b..",
"web_url":"https://gitlab.example.com/root"
},
"platform_kubernetes":
{
"api_url":"https://35.111.51.20",
"authorization_type":"rbac",
"ca_cert":"-----BEGIN CERTIFICATE-----\r\nhFiK1L61owwDQYJKoZIhvcNAQELBQAw\r\nLzEtMCsGA1UEAxMkZDA1YzQ1YjctNzdiMS00NDY0LThjNmEtMTQ0ZDJkZjM4ZDBj\r\nMB4XDTE4MTIyNzIwMDM1MVoXDTIzMTIyNjIxMDM1MVowLzEtMCsGA1UEAxMkZDA1\r\nYzQ1YjctNzdiMS00NDY0LThjNmEtMTQ0ZDJkZjM.......-----END CERTIFICATE-----"
},
"management_project":null,
"group":
{
"id":26,
"name":"group-with-clusters-api",
"web_url":"https://gitlab.example.com/root/group-with-clusters-api"
}
}
グループクラスターの編集
既存のグループ・クラスターを更新します。
PUT /groups/:id/clusters/:cluster_id
パラメータを指定します:
属性 | 種類 | 必須 | 説明 |
---|---|---|---|
id | 整数/文字列 | yes | グループのIDまたはURLエンコードされたパス |
cluster_id | 整数。 | yes | クラスターのID |
name | 文字列です。 | いいえ | クラスターの名前 |
domain | 文字列です。 | いいえ | クラスターのベースドメイン |
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証明書を使用している場合は必要です。 |
environment_scope | 文字列です。 | いいえ | クラスターに関連する環境 |
name
,api_url
,ca_cert
およびtoken
は、「Add existing Kubernetes cluster」オプションまたは「Add existing cluster to group」エンドポイントを通じてクラスターが追加された場合にのみ更新できます。リクエストの例
curl --header "Private-Token: <your_access_token>" "https://gitlab.example.com/api/v4/groups/26/clusters/24" \
-H "Content-Type:application/json" \
--request PUT --data '{"name":"new-cluster-name","domain":"new-domain.com","platform_kubernetes_attributes":{"api_url":"https://10.10.101.1:6433"}}'
応答例
{
"id":24,
"name":"new-cluster-name",
"domain":"new-domain.com",
"created_at":"2019-01-03T21:53:40.610Z",
"managed": true,
"enabled": true,
"provider_type":"user",
"platform_type":"kubernetes",
"environment_scope":"*",
"cluster_type":"group_type",
"user":
{
"id":1,
"name":"Administrator",
"username":"root",
"state":"active",
"avatar_url":"https://www.gravatar.com/avatar/4249f4df72b..",
"web_url":"https://gitlab.example.com/root"
},
"platform_kubernetes":
{
"api_url":"https://new-api-url.com",
"authorization_type":"rbac",
"ca_cert":null
},
"management_project":
{
"id":2,
"description":null,
"name":"project2",
"name_with_namespace":"John Doe8 / project2",
"path":"project2",
"path_with_namespace":"namespace2/project2",
"created_at":"2019-10-11T02:55:54.138Z"
},
"group":
{
"id":26,
"name":"group-with-clusters-api",
"web_url":"https://gitlab.example.com/group-with-clusters-api"
}
}
グループクラスターの削除
既存のグループクラスターを削除します。接続されているKubernetesクラスター内の既存のリソースは削除しません。
DELETE /groups/:id/clusters/:cluster_id
パラメータを指定します:
属性 | 種類 | 必須 | 説明 |
---|---|---|---|
id | 整数/文字列 | yes | グループのIDまたはURLエンコードされたパス |
cluster_id | 整数。 | yes | クラスターのID |
リクエストの例
curl --request DELETE --header "Private-Token: <your_access_token>" "https://gitlab.example.com/api/v4/groups/26/clusters/23"