Author : MD TAREQ HASSAN | Updated : 2021/05/20
Using Static Public IP
- Create a static public IP resource in Azure portal
- Assign DNS label to it
- Assign static IP to the service
Requirements
- Annotation: “
service.beta.kubernetes.io/azure-load-balancer-resource-group: myResourceGroup
” - The AKS cluster managed identity (
[clustername]-agentpool
inMC_x_y_z_
resource group)has Network Contributor role in the resource group where static IP belong
Create service with static IP: my-service-with-state-ip.yaml
apiVersion: v1
kind: Service
metadata:
name: my-service
annotations:
service.beta.kubernetes.io/azure-load-balancer-resource-group: myResourceGroup
spec:
loadBalancerIP: 20.151.113.52
type: LoadBalancer
ports:
- port: 80
selector:
app: my-service-pod
Command: kubectl apply -f my-service-with-state-ip.yaml -n test
Using DNS Label Name
- Annotation: “service.beta.kubernetes.io/azure-dns-label-name: uniquelabel”
- Url will be “uniquelabel.
.cloudapp.azure.com"
Create service with DNS label: my-service-with-dns-label.yaml
apiVersion: v1
kind: Service
metadata:
name: my-service
annotations:
service.beta.kubernetes.io/azure-dns-label-name: hoverapp
spec:
type: LoadBalancer
ports:
- port: 80
selector:
app: my-service-pod
Command: kubectl apply -f my-service-with-dns-label.yaml -n test