Chuyển tới nội dung chính

Create Kubernetes Cluster

POST /v1/clusters

Create a new Kubernetes cluster based on a cluster template. Refer to Creating Kubernetes cluster templates for more information.

info

Request

Request Parameters

NameInTypeDescription
namebodystringName of the resource.
discovery_urlbodystringThe custom discovery URL for node discovery. This is used by the COE to discover the servers that have been created to host the containers. The actual discovery mechanism varies with the COE. In some cases, Magnum fills in the server info in the discovery service. In other cases, if the discovery_url is not specified, Magnum will use the public discovery service at: https://discovery.etcd.io. In this case, Magnum will generate a unique URL here for each bay and store the info for the servers.
master_countbodyintegerThe number of servers that will serve as master for the bay/cluster. The default is 1. Set to more than 1 master to enable High Availability. If the option master-lb-enabled is specified in the baymodel/cluster template, the master servers will be placed in a load balancer pool.
cluster_template_idbodyUUIDThe UUID of the cluster template.
node_countbodyintegerThe number of servers that will serve as node in the bay/cluster. The default is 1.
keypairbodystringThe name of the SSH keypair to configure in the bay/cluster servers for ssh access. Users will need the key to be able to ssh to the servers in the bay/cluster. The login name is specific to the bay/cluster driver, for example with fedora-atomic image, default login name is fedora.
create_timeoutbodyintegerThe timeout for cluster creation in minutes. The value expected is a positive integer and the default is 60 minutes. If the timeout is reached during cluster creation process, the operation will be aborted and the cluster status will be set to CREATE_FAILED.
master_flavor_id (Optional)bodystringThe flavor of the master node for this baymodel/cluster template.
labels (Optional)bodyarrayArbitrary labels in the form of key=value pairs. The accepted keys and valid values are defined in the bay/cluster drivers. They are used as a way to pass additional parameters that are specific to a bay/cluster driver.
flavor_idbodystringThe nova flavor ID or name for booting the node servers. The default is m1.small.
fixed_subnet (Optional)bodystringFixed subnet that are using to allocate network address for nodes in bay/cluster.
fixed_network (Optional)bodystringThe name or network ID of a Neutron network to provide connectivity to the internal network for the bay/cluster.
floating_ip_enabled (Optional)bodybooleanWhether enable or not using the floating IP of cloud provider. Some cloud providers used floating IP, some used public IP, thus Magnum provide this option for specifying the choice of using floating IP. If it's not set, the value of floating_ip_enabled in template will be used.

Sample Request

Using curl

curl -ks -X POST -H 'Content-Type: application/json' -H 'OpenStack-API-Version: container-infra 1.8' -H 'X-Auth-Token: gAAAAA<...>' -d '{
"name": "kubApi_template",
"master_count": 1,
"node_count": 1,
"master_flavor_id": "medium.2c.4g",
"flavor_id": "small.1c.2g",
"keypair": "Docs Writter",
"docker_volume_size": 10,
"cluster_template_id": "389ecf86-46ce-4cdd-b7f3-889b0603b7ed",
"create_timeout": 60,
"labels": {
"boot_volume_type": "nvmer3",
"docker_volume_type": "nvmer3",
"boot_volume_size": "20",
"etcd_lb_disabled": "true",
"heat_container_agent_tag": "5.3.11",
"cloud_provider_tag": "v1.31.1",
"cloud_provider_enabled": "true",
"cinder_csi_plugin_tag": "v1.31.1",
"csi_snapshotter_tag": "v8.0.1",
"csi_attacher_tag": "v4.6.1",
"flannel_tag": "v0.11.0-amd64",
"cinder_csi_enabled": "true",
"availability_zone": "nova",
"use_podman": "true",
"etcd_tag": "v3.5.13",
"cgroup_driver": "systemd",
"octavia_api_lb_flavor": "",
"octavia_default_flavor": "",
"auto_scaling_enabled": "True",
"cluster_upgrade_method": "replace",
"network_driver": "cilium",
"kube_tag": "v1.31.2",
"kube_version": "v1.31.2",
"hyperkube_image": "docker.io/virtuozzo/hci-binary-hyperkube",
"autoscaler_tag": "1.31.0",
"coredns_tag": "1.11.3",
"k8s_keystone_auth_tag": "v1.31.1",
"cilium_tag": "v1.16.3",
"container_runtime": "containerd",
"monitoring_enabled": "False",
"minion_floating_ip_disabled": "True",
"cilium_routing_mode": "native"
}
}' https://api.vietnix.cloud:9513/v1/clusters

Using HTTP request

POST https://api.vietnix.cloud:9513/v1/clusters
Content-Type: application/json
OpenStack-API-Version: container-infra 1.8
X-Auth-Token: gAAAAA<...>

{
"name": "kubApi_template",
"master_count": 1,
"node_count": 1,
"master_flavor_id": "medium.2c.4g",
"flavor_id": "small.1c.2g",
"keypair": "Docs Writter",
"docker_volume_size": 10,
"cluster_template_id": "389ecf86-46ce-4cdd-b7f3-889b0603b7ed",
"create_timeout": 60,
"labels": {
"boot_volume_type": "nvmer3",
"docker_volume_type": "nvmer3",
"boot_volume_size": "20",
"etcd_lb_disabled": "true",
"heat_container_agent_tag": "5.3.11",
"cloud_provider_tag": "v1.31.1",
"cloud_provider_enabled": "true",
"cinder_csi_plugin_tag": "v1.31.1",
"csi_snapshotter_tag": "v8.0.1",
"csi_attacher_tag": "v4.6.1",
"flannel_tag": "v0.11.0-amd64",
"cinder_csi_enabled": "true",
"availability_zone": "nova",
"use_podman": "true",
"etcd_tag": "v3.5.13",
"cgroup_driver": "systemd",
"octavia_api_lb_flavor": "",
"octavia_default_flavor": "",
"auto_scaling_enabled": "True",
"cluster_upgrade_method": "replace",
"network_driver": "cilium",
"kube_tag": "v1.31.2",
"kube_version": "v1.31.2",
"hyperkube_image": "docker.io/virtuozzo/hci-binary-hyperkube",
"autoscaler_tag": "1.31.0",
"coredns_tag": "1.11.3",
"k8s_keystone_auth_tag": "v1.31.1",
"cilium_tag": "v1.16.3",
"container_runtime": "containerd",
"monitoring_enabled": "False",
"minion_floating_ip_disabled": "True",
"cilium_routing_mode": "native"
}
}
warning

To ensure the cluster is created successfully, we recommend using our sample request, specifically the labels parameter.

Response

Response Parameters

NameInTypeDescription
uuidbodyUUIDThe UUID of the cluster.

Sample Response

{
"uuid": "ed495c33-601c-4f5c-86c8-d7c13b5f6b0e"
}

Status Code

Success

Status CodeDescription
202 - AcceptedRequest was accepted for processing, but the processing has not been completed. A 'location' header is included in the response which contains a link to check the progress of the request.

Error

Status CodeDescription
400 - Bad RequestSome content in the request was invalid.
401 - UnauthorizedUser must authenticate before making a request.
403 - ForbiddenPolicy does not allow current user to do this operation.
404 - Not FoundThe requested resource could not be found.