【问题标题】:Azure Container Service using Rest API使用 Rest API 的 Azure 容器服务
【发布时间】:2018-02-09 01:41:13
【问题描述】:

我想使用特定 Orchestrator Kubernetes 集群的资源组和集群创建 azure 容器。

我知道使用 CLI 是可能的,但我想通过此处给出的链接使用 Azure Rest API 的容器服务来执行此操作

docs.microsoft.com/en-us/rest/api/container-service/containerservices/createorupdate

在 AAD 中注册我的应用并授予所需权限。

获取访问令牌并根据链接向下面的 api 发出请求

PUT management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/containerServices/{containerServiceName}?api-version=2017-01-31 但我收到错误

{
"error":  {
"code": "InvalidResource"
"message": "The resource definition is invalid."
}
}

我知道当请求正文中没有任何内容时我们会收到此错误。

所以我真正的问题是我是否想使用 API 请求创建具有资源组和集群的容器服务。

请求正文

    {
  "id": "myCluster",
  "name": "myCluster",
  "type": "Microsoft.ContainerService/containerServices",
  "location": "southindia",
  "tags": {
    "tag": "test"
  },
  "properties": {
     "orchestratorProfile": {
      "orchestratorType": "Kubernetes"
    },
    "servicePrincipalProfile": {
      "clientId": "<clientid>,
      "secret": "<secret>"
    },
    "masterProfile": {
      "count": 1,
      "dnsPrefix": "testabc"
    },
    "agentPoolProfiles": {
      "name": "agentPool1234",
      "count": 2,
      "vmSize": "Standard_A1",
      "dnsPrefix": "testabcagents"
    },
    "linuxProfile": {
      "adminUsername": "kubeadmin",
      "ssh": {
        "publicKeys": [
          {
            "keyData": "sshkey"
          }
        ]
      }
    }
  }
}

得到响应

{
    "code": "BadRequest",
    "message": "An error has occurred in subscription <subscriptionid>, resourceGroup: tobeDeletedResourceGroup request: OrchestratorType has unknown orchestrator: ."
    }

请帮我解决这个问题

【问题讨论】:

  • 你的put body无效
  • @4c74356b41 对于 Swarm、DCOS 或 Custom 等任何编排器,我都会遇到同样的错误
  • @4c74356b41 你在 PUT 正文中看到了什么错误。请你详细说明一下好吗?或者如果您有样本 PUT 正文,请提供给我...

标签: azure azure-management-api azure-container-service


【解决方案1】:

Azure REST API 文档中缺少两件事。 1) 它需要这样的 orchestratorRelease 版本和 orchestratorType 。 “编排器配置文件”:{ "orchestratorType": "Kubernetes", “orchestratorRelease”:“1.7” } 2) 下一个错误是我在 Properties.MasterProfile.VMSize 中缺少 vmSize。 所以我在 json 中添加了以下更新

"masterProfile": { “计数”:1, "dnsPrefix": "testabc", “vmSize”:“标准_D2_v2” }

文档缺少这两个重要的 json 参数,这非常令人惊讶和烦人。

【讨论】:

    【解决方案2】:

    agentPoolProfiles 应该是一个 json 对象数组。我从azure-cli's mock unit tests 中提取了这个示例,以帮助您提供一个参考框架。

    https://gist.github.com/bacongobbler/470b8d139536144edf91174916ec4036

    【讨论】:

    • 是的,我用“agentPoolProfiles”更新了我的代理池:[{“name”:“agentPool1234”,“count”:2,“vmSize”:“Standard_A1”,“dnsPrefix”:“testabcagents”} ],但仍然出现同样的错误。
    猜你喜欢
    • 2019-02-03
    • 2017-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-24
    • 1970-01-01
    相关资源
    最近更新 更多