Skip to content

somrajroy/OpenSourceProject-AWS-EKS-Load-Balancer-Service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 

Repository files navigation

Creating a Load Balancer Service with AWS EKS

  • Clone the repository and move to folder lab-04
  • Create a cluster with eksctl
    $ eksctl create cluster --name k8sLB --version 1.23 --region us-west-2 --nodegroup-name k8sLBnodes --node-type t3.medium --nodes 2
  • Switch context
    $ aws eks --region us-west-2 update-kubeconfig --name k8sLB
  • Refer below commands for verification of contexts.
    $ kubectl config view
    $ kubectl config current-context (output should be k8sdemo).
    $ kubectl config get contexts
    $ kubectl config use-context <<-context name->>
  • Verify - Check nodes and pods in the EKS cluster.
    $ kubectl get nodes -o wide
    $ kubectl get pods
  • There would not be any pods in system but the output for nodes would be like below. This signifies that the cluster is reachable from CLI
    image
  • Create deployments
    $ kubectl apply -f ./k8s-deployments/
  • Create services
    $ kubectl apply -f ./k8s-services/
  • Check the pods. The worker pod will have a high restarts value because initially there were no connection between the pods (services were not created)
    image
  • Check services. Wait for 5-10 mins for the load balancers to be ready to serve traffic.
  • Get the DNS names of the load balancers. Under column "EXTERNAL-IP"
    image
  • Access the "vote" service and place your vote!
    http://<<-DNS Name from above->>:5000
  • Output of the "vote" service should be like below.
    image
  • Access the "result" service and check the results:
    http://<<-DNS Name from above->>:5001
  • Output of the "result" service would be like below.
    image
  • Delete deployments and services.
    $ kubectl delete -f ./k8s-deployments/
    $ kubectl delete -f ./k8s-services/
    $ kubectl delete all --all
  • Verify from the EC2 console that the load balaner (classic) is deleted.
  • Clean up AWS enviornment
    $ eksctl delete cluster --name k8sLB

    image

References

How do I troubleshoot service load balancers for Amazon EKS?
How do I resolve HTTP 503 (Service unavailable) errors when I access a Kubernetes Service in an Amazon EKS cluster?