0
votes

I would like to create azure container with resource group and cluster of specific Orchestrator Kubernetes cluster.

I know by using CLI its possible but I want to do this using Azure Rest API's for Container service from link given here

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

Registered my app in AAD and gave required permissions.

Got access token and making request to below api as per link

PUT management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/containerServices/{containerServiceName}?api-version=2017-01-31 but I am getting error as

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

I understand we get this error when there is nothing in request body.

So my real question here is if I want to create container service with resource group and cluster using API request.

Request Body

    {
  "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"
          }
        ]
      }
    }
  }
}

Response getting

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

Please help me out on this

2
your put body is invalid4c74356b41
@4c74356b41 I am getting same error for any orchestrator like Swarm, DCOS, or CustomBhushan Gholave
@4c74356b41 what wrong things you see in PUT body. will you please elaborate bit please? or if you have sample PUT body please provide me...Bhushan Gholave

2 Answers

1
votes

Two things are missing from Azure REST API documentation. 1) It requires version of orchestratorRelease with orchestratorType like this. "orchestratorProfile": { "orchestratorType": "Kubernetes", "orchestratorRelease": "1.7" } 2) Next error i got about missing vmSize in Properties.MasterProfile.VMSize. So I have added following updates to json

"masterProfile": { "count": 1, "dnsPrefix": "testabc", "vmSize": "Standard_D2_v2" }

Its very surprising and annoying that documentation is missing these 2 important json parameters.

0
votes

agentPoolProfiles should be an array of json objects. I pulled this example from azure-cli's mock unit tests to help give you a frame of reference.

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