In this section, we will deploy a web based application called Komiser and configure an associated Service leveraging the Application Load Balancer to expose the application externally.
The Application Load Balancer integrates with Kubernetes via an Ingress Controller, so it needs to be provisioned in advance.
The Application Load Balancer Ingress Controller runs on the Worker Nodes and in order to create the necessary AWS Resources, permissions are needed. We will be going Rogue here and adding full Power User privileges to your Worker Nodes. Please don’t try this stunt in uncontrolled environments as there be dragons beyond them hills if you do!!!
Access your AWS IAM Console
Go to Roles and search for “eks-node”
Edit the Role associated with the Worker Nodes of the Cluster you are using for the Workshop and Attach the PowerUserAccess policy to it.
wget https://raw.githubusercontent.com/kubernetes-sigs/aws-alb-ingress-controller/v1.1.2/docs/examples/alb-ingress-controller.yaml
# - --cluster-name=devCluster
- --cluster-name=EKS
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/aws-alb-ingress-controller/v1.1.2/docs/examples/rbac-role.yaml
kubectl apply -f alb-ingress-controller.yaml
kubectl logs -n kube-system $(kubectl get po -n kube-system | egrep -o "alb-ingress[a-zA-Z0-9-]+")
-------------------------------------------------------------------------------
AWS ALB Ingress controller
Release: v1.1.2
Build: git-cc1c5971
Repository: https://github.com/kubernetes-sigs/aws-alb-ingress-controller.git
-------------------------------------------------------------------------------
apiVersion: v1
kind: Service
metadata:
name: komiser-with-alb
labels:
name: komiser-with-alb
spec:
selector:
app: komiser-with-alb
ports:
- name: http
port: 3000
type: NodePort
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: "komiser-with-alb"
annotations:
kubernetes.io/ingress.class: alb
alb.ingress.kubernetes.io/scheme: internet-facing
labels:
app: komiser-with-alb
spec:
rules:
- http:
paths:
- path: /*
backend:
serviceName: "komiser-with-alb"
servicePort: 3000
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: komiser-with-alb
labels:
name: komiser-with-alb
spec:
replicas:
template:
metadata:
labels:
app: komiser-with-alb
spec:
containers:
- name: komiser-with-alb
image: mlabouardy/komiser:2.1.0
imagePullPolicy: Always
ports:
- containerPort: 3000
Analyze the difference between this manifest and the Classic Load Balancer manifest and Network Load Balancer.The use of the Application Load Balancer requires that our Services be exposed using the NodePort mechanism and a new section of “Kind” “Ingress” showed up that performs the actual Ingress Controller configuration
Deploy your application by using kubectl
kubectl create -f komiser-with-alb.yml
kubectl describe services
Name: komiser-with-alb
Namespace: default
Labels: name=komiser-with-alb
Annotations: <none>
Selector: app=komiser-with-alb
Type: NodePort
IP: 10.100.65.120
Port: http 3000/TCP
TargetPort: 3000/TCP
NodePort: http 32501/TCP
Endpoints: 192.168.13.235:3000
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
The Service no longer has a “LoadBalancer Ingress” line
Describe the properties of your newly deployed Ingress Controller
kubectl describe ingress
Name: komiser-with-alb
Namespace: default
Address: 68ff00b9-default-komiserwi-a0a0-1779224450.eu-west-1.elb.amazonaws.com
Default backend: default-http-backend:80 (<none>)
Rules:
Host Path Backends
---- ---- --------
*
/* komiser-with-alb:3000 (<none>)
Annotations:
alb.ingress.kubernetes.io/scheme: internet-facing
kubernetes.io/ingress.class: alb
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal CREATE 42m alb-ingress-controller LoadBalancer 68ff00b9-default-komiserwi-a0a0 created, ARN: arn:aws:elasticloadbalancing:eu-west-1:725135641014:loadbalancer/app/68ff00b9-default-komiserwi-a0a0/a533d5a4c64668a5
Normal CREATE 42m alb-ingress-controller rule 1 created with conditions [{ Field: "path-pattern", Values: ["/*"] }]
Address: 68ff00b9-default-komiserwi-a0a0-1779224450.eu-west-1.elb.amazonaws.com