Clusters¶
Reference¶
- v4 API:
gitlab.v4.objects.ProjectCluster
gitlab.v4.objects.ProjectClusterManager
gitlab.v4.objects.Project.clusters
gitlab.v4.objects.GroupCluster
gitlab.v4.objects.GroupClusterManager
gitlab.v4.objects.Group.clusters
- GitLab API: https://docs.gitlab.com/ee/api/project_clusters.html
- GitLab API: https://docs.gitlab.com/ee/api/group_clusters.html
Examples¶
List clusters for a project:
clusters = project.clusters.list()
Create an cluster for a project:
cluster = project.clusters.create(
{
"name": "cluster1",
"platform_kubernetes_attributes": {
"api_url": "http://url",
"token": "tokenval",
},
})
Retrieve a specific cluster for a project:
cluster = project.clusters.get(cluster_id)
Update an cluster for a project:
cluster.platform_kubernetes_attributes = {"api_url": "http://newurl"}
cluster.save()
Delete an cluster for a project:
cluster = project.clusters.delete(cluster_id)
# or
cluster.delete()
List clusters for a group:
clusters = group.clusters.list()
Create an cluster for a group:
cluster = group.clusters.create(
{
"name": "cluster1",
"platform_kubernetes_attributes": {
"api_url": "http://url",
"token": "tokenval",
},
})
Retrieve a specific cluster for a group:
cluster = group.clusters.get(cluster_id)
Update an cluster for a group:
cluster.platform_kubernetes_attributes = {"api_url": "http://newurl"}
cluster.save()
Delete an cluster for a group:
cluster = group.clusters.delete(cluster_id)
# or
cluster.delete()