Use-case - To expose the service within virtual network as Internal LoadBalancer
By default, when we create service type LoadBalancer without customized annotations in AKS(Azure Kubernetes Service), then AKS will create Load Balancer with Public IP attached to it, through which application can be accessible to internet world.
However, it is possible that we may need to create service to be exposed within virtual network only, however with service type Load Balancer.
For this, we need to add service.beta.kubernetes.io/azure-load-balancer-internal: "true"
in annotations
in kubernetes service manifest file.
Create an Internal LoadBalancer
apiVersion: v1
kind: Service
metadata:
name: nameOfService
annotations:
service.beta.kubernetes.io/azure-load-balancer-internal: "true"
spec:
type: LoadBalancer
ports:
- port: 8080
targetPort: 8080
selector:
app: nameOfApplication
Define particular private ip address
For this, we need to add loadBalancerIP
in spec
with required IP address from the same subnet of AKS.
Ex.
apiVersion: v1
kind: Service
metadata:
name: nameOfService
annotations:
service.beta.kubernetes.io/azure-load-balancer-internal: "true"
spec:
type: LoadBalancer
loadBalancerIP: 10.10.10.10
ports:
- port: 8080
targetPort: 8080
selector:
app: nameOfApplication
Define particular subnet
For this, we need to add service.beta.kubernetes.io/azure-load-balancer-internal-subnet: "subnetName"
in annotations
Ex.
apiVersion: v1
kind: Service
metadata:
name: nameOfService
annotations:
service.beta.kubernetes.io/azure-load-balancer-internal: "true"
service.beta.kubernetes.io/azure-load-balancer-internal-subnet: "subnetName"
spec:
type: LoadBalancer
loadBalancerIP: 10.10.10.10
ports:
- port: 8080
targetPort: 8080
selector:
app: nameOfApplication
Comments
Post a Comment