万能集群创建

Magnum cluster creation

根据https://developer.openstack.org/api-ref/container-infrastructure-management/#create-new-cluster,我创建集群所需要做的就是传递如下参数:

 curl --header "X-Auth-Token: blah" \
 -X POST https://myopenstack:9511/v1/clusters -d name="Swarm-cluster-ansible" -d cluster_template_id="7402f9d3-4881-440f-8496-08d420935f58" -d node_count=2 -d keypair="k8s-gitlab-ci"

它给了我:

{"errors": [{"status": 400, "code": "client", "links": [], "title": "Unknown argument: \"cluster_template_id, node_count, keypair, name\"", "detail": "Unknown argument: \"cluster_template_id, node_count, keypair, name\"", "request_id": ""}]}

如果我这样尝试:

curl --header "X-Auth-Token: blah" \
 -X POST https://myopenstack:9511/v1/clusters -d cluster='{
   "name":"swarm",
   "master_count":1,
   "discovery_url":null,
   "cluster_template_id":"7402f9d3-4881-440f-8496-08d420935f58",
   "node_count":1,
   "keypair":"k8s-gitlab-ci",
   "master_flavor_id":null,
   "labels":{
   },
   "flavor_id":null
}'


{"errors": [{"status": 400, "code": "client", "links": [], "title": "Invalid input for field/attribute cluster", "detail": "Invalid input for field/attribute cluster. Value: '{\n   \"name\":\"swarm\",\n   \"master_count\":1,\n   \"discovery_url\":null,\n   \"cluster_template_id\":\"7402f9d3-4881-440f-8496-08d420935f58\",\n   \"node_count\":1,\n   \"keypair\":\"k8s-gitlab-ci\",\n   \"master_flavor_id\":null,\n   \"labels\":{\n   },\n   \"flavor_id\":null\n}'. unable to convert to Cluster. Error: __init__() takes exactly 1 argument (2 given)", "request_id": ""}]}

有什么想法吗?

编辑:我能够执行 GET 并检索现有集群的列表。

-H "Content-Type: application/json" 在这种情况下就足够了,所以正文被解释为 JSON.