Author : MD TAREQ HASSAN | Updated : 2021/05/20

Using Static Public IP

Requirements

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

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