doc-locale/fr-fr/api/instance_clusters.md
{{< details >}}
{{< /details >}}
[!warning] Cette fonctionnalité a été dépréciée dans GitLab 14.5.
Avec les clusters Kubernetes au niveau de l'instance, vous pouvez connecter un cluster Kubernetes à l'instance GitLab et utiliser le même cluster pour tous les projets de votre instance.
Les utilisateurs doivent disposer d'un accès administrateur pour utiliser ces endpoints.
Liste tous les clusters d'instance.
GET /admin/clusters
Exemple de requête :
curl --request GET \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/admin/clusters"
Exemple de réponse :
[
{
"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",
...
}
]
Récupère un seul cluster d'instance.
Paramètres :
| Attribut | Type | Obligatoire | Description |
|---|---|---|---|
cluster_id | integer | oui | L'ID du cluster |
GET /admin/clusters/:cluster_id
Exemple de requête :
curl --request GET \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/admin/clusters/9"
Exemple de réponse :
{
"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
}
Crée un cluster d'instance en ajoutant un cluster Kubernetes existant.
POST /admin/clusters/add
Paramètres :
| Attribut | Type | Obligatoire | Description |
|---|---|---|---|
name | string | oui | Le nom du cluster |
domain | string | non | Le domaine de base du cluster |
environment_scope | string | non | L'environnement associé au cluster. Par défaut : * |
management_project_id | integer | non | L'ID du projet de gestion du cluster |
enabled | boolean | non | Détermine si le cluster est actif ou non, par défaut true |
managed | boolean | non | Détermine si GitLab gère les espaces de nommage et les comptes de service pour ce cluster. Par défaut : true |
platform_kubernetes_attributes[api_url] | string | oui | L'URL d'accès à l'API Kubernetes |
platform_kubernetes_attributes[token] | string | oui | Le token pour s'authentifier auprès de Kubernetes |
platform_kubernetes_attributes[ca_cert] | string | non | Certificat TLS. Requis si l'API utilise un certificat TLS auto-signé. |
platform_kubernetes_attributes[namespace] | string | non | L'espace de nommage unique lié au projet |
platform_kubernetes_attributes[authorization_type] | string | non | Le type d'autorisation du cluster : rbac, abac ou unknown_authorization. Par défaut : rbac. |
Exemple de requête :
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"
Exemple de réponse :
{
"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
}
Met à jour un cluster d'instance existant.
PUT /admin/clusters/:cluster_id
Paramètres :
| Attribut | Type | Obligatoire | Description |
|---|---|---|---|
cluster_id | integer | oui | L'ID du cluster |
name | string | non | Le nom du cluster |
domain | string | non | Le domaine de base du cluster |
environment_scope | string | non | L'environnement associé au cluster |
management_project_id | integer | non | L'ID du projet de gestion du cluster |
enabled | boolean | non | Détermine si le cluster est actif ou non |
managed | boolean | non | Détermine si GitLab gère les espaces de nommage et les comptes de service pour ce cluster |
platform_kubernetes_attributes[api_url] | string | non | L'URL d'accès à l'API Kubernetes |
platform_kubernetes_attributes[token] | string | non | Le token pour s'authentifier auprès de Kubernetes |
platform_kubernetes_attributes[ca_cert] | string | non | Certificat TLS. Requis si l'API utilise un certificat TLS auto-signé. |
platform_kubernetes_attributes[namespace] | string | non | L'espace de nommage unique lié au projet |
[!note]
name,api_url,ca_certettokenne peuvent être mis à jour que si le cluster a été ajouté via l'option Add existing Kubernetes cluster ou via l'endpoint Créer un cluster d'instance.
Exemple de requête :
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"
Exemple de réponse :
{
"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
}
Supprime un cluster d'instance existant. Ne supprime pas les ressources existantes dans le cluster Kubernetes connecté.
DELETE /admin/clusters/:cluster_id
Paramètres :
| Attribut | Type | Obligatoire | Description |
|---|---|---|---|
cluster_id | integer | oui | L'ID du cluster |
Exemple de requête :
curl --request DELETE \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/admin/clusters/11"