Part2: Deploying a gaming application on an EKS cluster with ingress controller
Deploying the application on EKS cluster
In the previous blog, we created an EKS cluster with the fargate profile required to deploy the application. In this blog, we shall proceed and deploy the gaming application in this cluster via k8s resources.
We had already created a Fargate profile in the last blog in the namespace game-2018. We shall now move on to creating the namespace in the actual EKS cluster through the below manifest.
apiVersion: v1 kind: Namespace metadata: name: game-2048
Create the deployment file with 3 replicasets. The docker image used here is from a public docker hub repository.
apiVersion: apps/v1 kind: Deployment metadata: name: gaming-deployment namespace: game-2048 labels: app: gaming spec: replicas: 3 selector: matchLabels: app: gaming template: metadata: labels: app: gaming spec: containers: - name: gaming2048 image: public.ecr.aws/l6m2t8p7/docker-2048:latest imagePullPolicy: Always ports: - containerPort: 80
Next, create and apply service
apiVersion: v1 kind: Service metadata: name: my-service namespace: game-2048 spec: type: NodePort selector: app: gaming ports: - port: 80 targetPort: 80 nodePort: 30007 protocol: TCP
Create and apply ingress resource
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: ingress-2048 namespace: game-2048 annotations: alb.ingress.kubernetes.io/scheme: internet-facing alb.ingress.kubernetes.io/target-type: ip spec: ingressClassName: alb rules: - http: paths: - path: / pathType: Prefix backend: service: name: my-service port: number: 80
Now, we have created all the required k8s resources for the application to be running. Let us check for the status of this on EKS cluster via the command
kubectl get all -n game-2048
We can see that all the pods are in a running state and this aplication can be accessed through node's IP adress. However, the external IP address is not allocated meaning this application cannnot be accessed by the external world or any end user
Although we have already created an ingress resource, a controller is needed which can look into this ingress resource and create a load balanacer through which our application can be accessed by an end user.
So, in the next blog we will be creating an application load balancer with ingress controller and accessing this application via load balancer's DNS.