In this blog, we’re going to implement how we can update the ingress as per EKS’s latest version(1.24), and further, we will deploy the AWS load balancer using a helm chart with a simple node js application.
You can check out the official documentation provided by AWS.
Prerequisites
● EKS Cluster
● Helm
To deploy the ingress, we’ll use the AWS load balancer controller so it’ll create a load balancer for us. We have to use the annotations “kubernetes.io/ingress.class: alb”.
Automate Datadog Monitoring | Mistakes Made By DevOps Practitioner | DevSecOps Services
So I’ve written the deployment YAML for a sample node hello application.
Deployment
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
name: node
spec:
selector:
matchLabels:
app: node
replicas: {{ .Values.replicaCount }}
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 25%
template: # create pods using pod definition in this template
metadata:
labels:
app: node
spec:
containers:
- name: node
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: 3000
Service
Now we need to expose the service as LoadBalancer for this deployment.
apiVersion: v1
kind: Service
metadata:
name: node
namespace: default
labels:
app: node
spec:
externalTrafficPolicy: Local
ports:
- name: node-svc
port: 80
protocol: TCP
targetPort: 3000
selector:
app: node
type: {{ .Values.service.type }}
Cloud Consultant | Successful DevSecOps Process | Azure DevOps | Waterfall Vs. Agile Vs. DevOps
Ingress
As per Kubernete’s latest documentation of ingress I’ve updated its syntax of it.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
namespace: default
name: ingress-node
annotations:
kubernetes.io/ingress.class: alb
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/target-type: ip
spec:
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: node-svc
port:
number: 80
After that, now let’s take a look at the values.yaml of the chart.
replicaCount: 3
service:
type: LoadBalancer
image:
repository: xyzrepo/hello-node
pullPolicy: IfNotPresent
tag: "01"
Update the kube-config of EKS Cluster and now let’s deploy the helm chart.
$ aws eks --region ap-south-1 update-kubeconfig --name cluster_name
$ helm install node-chart.
To list the helm releases
$ helm list
Microservices Architecture | Dockerization | Managed Microsoft Azure | AWS Vs. Google Cloud Vs. Azure
Now let’s take a look at all the deployed k8s resources.
$ kubectl get all
Check the ingress resource.
$ kubectl get ingress
So ingress is getting deployed successfully so now let’s have a look at the external-ip of the deployment service.
The external-ip is the AWS load balancer DNS name and you can verify that a load balancer is getting deployed on your account.
Conclusion
In this blog, we’ve seen how we can use the updated ingress Kubernetes resource with the AWS load balancer controller which creates a load balancer for us. If you find this blog helpful, please show your appreciation by giving thumbs-ups and sharing it with your friends.
Cloud Adoption | Cloud Migration Service | Best DevOps Strategy