In this section, we will deploy a web based application called Komiser and configure an associated Service leveraging the Network Load Balancer to expose the application externally.
apiVersion: v1
kind: Service
metadata:
name: komiser-with-nlb
labels:
name: komiser-with-nlb
annotations:
service.beta.kubernetes.io/aws-load-balancer-type: nlb
spec:
selector:
app: komiser-with-nlb
ports:
- name: http
protocol: TCP
port: 80
targetPort: 3000
type: LoadBalancer
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: komiser-with-nlb
labels:
name: komiser-with-nlb
spec:
replicas:
template:
metadata:
labels:
app: komiser-with-nlb
spec:
containers:
- name: komiser-with-nlb
image: mlabouardy/komiser:2.1.0
imagePullPolicy: Always
ports:
- containerPort: 3000
Analyze the difference between this manifest and the Classic Load Balancer manifest. We are essentially adding an annotation to the Service metadata telling Kubernetes that we will leverage a Network Load Balancer for the Service
Deploy your application by using kubectl
kubectl create -f komiser-with-nlb.yml
kubectl describe services
Locate the newly created Service by looking for a Service named “komiser-with-elb” with similar content to the below
Name: komiser-with-nlb
Namespace: default
Labels: name=komiser-with-nlb
Annotations: service.beta.kubernetes.io/aws-load-balancer-type: nlb
Selector: app=komiser-with-nlb
Type: LoadBalancer
IP: 10.100.113.207
LoadBalancer Ingress: a3e243baf7c9811e9b386025ea934319-b301d850bba326d9.elb.eu-west-1.amazonaws.com
Port: http 80/TCP
TargetPort: 3000/TCP
NodePort: http 32436/TCP
Endpoints: 192.168.69.236:3000
Session Affinity: None
External Traffic Policy: Cluster
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal EnsuringLoadBalancer 13m service-controller Ensuring load balancer
Normal EnsuredLoadBalancer 13m service-controller Ensured load balancer
LoadBalancer Ingress: a3e243baf7c9811e9b386025ea934319-b301d850bba326d9.elb.eu-west-1.amazonaws.com