Search code examples
azureazure-active-directoryazure-container-serviceazure-cli2

InvalidDomainNameLabel when creating a Azure CS Cluster in a RG with Underscores


Sorry for the cryptic title, please let me explain.

I'm trying to create a Kubernetes cluster using Azure Container Services inside a Resource Group named like Foo_Bar_BAZ

 az acs create --orchestrator-type=kubernetes --resource-group 
    Foo_Bar_BAZ --name=someCluster --generate-ssh-keys

This fails with:

 At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details. {
  "error": {
    "code": "InvalidDomainNameLabel",
    "message": "Provisioning of resource(s) for container service 'zipkinCluster' in resource group 'Foo_Bar_BAZ' failed.\nMessage: 'The domain name label somecluster-Foo_Bar_BAZ-16b263 is invalid. It must conform to the following regular expression: ^[a-z][a-z0-9-]{1,61}[a-z0-9]$.'.\nDetails: '[]'"
  }
}  Correlation ID: fd8fa3fd-6ab8-4b10-8825-9e8bf28d1cdf

The problem lies here: 'The domain name label somecluster-Foo_Bar_BAZ-16b263 is invalid. Underscores do not conform the regex, but that comes from the Resource Group.

To recap:

  • Underscores are fine for Resource Groups, but when reused to create DomainNames, they don't conform the validating regex.

Another option would be to explicitly assign a DomainName that complies the regex, but I couldn't find a way to do it through the Azure CLI 2.0. Maybe I missed the argument.

This silly error may require to create a new RG without underscores.

Thanks

EDIT: New RG without _ was created as a workaround. It would be awesome to have a solution though.


Solution

  • In Azure, DNS name only numbers, lowercase letters and dashes are allowed, the value must begin with a lowercase letter and cannot end with a slash, and must also be less than 63 characters log.

    When we use CLI 2.0 to create Azure ACS k8s, we can use this argument --dns-prefix to specify the DNS name. Like this:

    az acs create --orchestrator-type=kubernetes --resource-group Foo_Bar_BAZ --name=someCluster --dns-prefix XXXX --generate-ssh-keys