<p>I have an Azure Kubernetes Service cluster, running version <code>1.15.7</code>. This cluster recently replaced an older cluster version (<code>1.12.something</code>). In the past, once the various service pods were up and running, we would create a public IP resource in Azure portal and assign it a name, then create a <code>Service</code> resource like this:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: myservice-frontend
  labels:
    app: myservice
spec:
  ports:
  - port: 80
    name: myservice-frontend
    targetPort: 80
  - port: 443
    name: myservice-frontend-ssl
    targetPort: 443
  selector:
    app: myservice-frontend
  type: LoadBalancer
  loadBalancerIP: 1.2.3.4

</code></pre>

<p>Finally, we'd add the public IP to a Traffic Manager instance. </p>

<p>Since upgrading to 1.15, this doesn't seem to work anymore. We can go through all the above steps, but as soon as the Service/Load Balancer is created, the public IP loses its DNS name, which causes it to be evicted from Traffic Manager. We can reset the name, but within 36-48 hours it gets lost again. My suspicion is that AKS is trying to apply a name to the associated IP address, but since I haven't defined one above, it just sets it to null. </p>

<p>How can I tell AKS what name to assign to a public IP? Better yet, can I skip the static public IP and let AKS provision a dynamic address and simply add the DNS name to Traffic Manager?</p>

<p>This is indeed a bug in AKS <code>1.15.7</code></p>

<p><a href="https://github.com/kubernetes/kubernetes/issues/87127" rel="nofollow noreferrer">Azure - PIP dns label will be default deleted</a></p>

<p>The upshot is, this is part of a new feature in 1.15 that allows the DNS label for a LoadBalancer IP to be set in the Service configuration. So, the definition above can become:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: myservice-frontend
  labels:
    app: myservice
  annotations:
    service.beta.kubernetes.io/azure-dns-label-name: myservice-frontend
spec:
  ports:
  - port: 80
    name: myservice-frontend
    targetPort: 80
  - port: 443
    name: myservice-frontend-ssl
    targetPort: 443
  selector:
    app: myservice-frontend
  type: LoadBalancer
</code></pre>

<p>And the service will be automatically assigned a new static IP with the annotated DNS name.</p>
