Skip to content

somrajroy/OpenSourceProject-AWS-ElasticKubernetesService-Ingress-NGINX

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 

Repository files navigation

AWS EKS Ingress with NGINX Ingress Controller & eksctl

  • Kubernetes supports a high-level abstraction called Ingress, which allows host- or URL-based routing. An Ingress is a core concept of Kubernetes. It is always implemented by a third party proxy; these implementations are known as ingress controllers. An ingress controller is responsible for reading the ingress resource information and processing that data accordingly. Different ingress controllers have extended the specification in different ways to support additional use cases.
  • Ingress can route traffic to multiple services inside the cluster
    image
    image
  • Clone the repository and navigate to the folder lab-05
  • Open CLI in administrator mode and login
    $ aws configure
  • Create an EKS cluster
    $ eksctl create cluster --name k8sdemo --version 1.23 --region us-west-2 --nodegroup-name k8snodes --node-type t3.medium --nodes 2
  • Switch context
    $ aws eks --region us-west-2 update-kubeconfig --name k8sdemo
  • 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->>
  • Check nodes and pods in the EKS cluster.
    $ kubectl get nodes -o wide
    $ kubectl get pods
  • Install Helm and update the repo. Then install the NGINX inngress controller without customizing the defaults.
    $ helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
    $ helm repo update
    $ helm install nginx-ingress ingress-nginx/ingress-nginx --create-namespace --namespace ingress-basic --set controller.replicaCount=2 --set controller.nodeSelector."kubernetes.io/os"=linux --set defaultBackend.nodeSelector."kubernetes.io/os"=linux
  • Verify NGINX controller installation
    $ kubectl get pods -n ingress-basic -l app.kubernetes.io/name=ingress-nginx --watch
  • Inspect the ingress controller Service & pods
    $ kubectl get svc -n ingress-basic
    image
    $ kubectl get pods -n ingress-basic -l app.kubernetes.io/name=ingress-nginx
    image
  • Deploy the applications (pods and ClusterIP services)
    $ kubectl apply -f cats.yaml
    $ kubectl apply -f dogs.yaml
    $ kubectl apply -f birds.yaml
  • Create the ingress resource
    $ kubectl apply -f ingress.yaml
  • List existing pods & services
    $ kubectl get pods
    $ kubectl get svc
  • List existing ingress
    $ kubectl get ingress
  • Access the application - Get the ingress controller External IP (type LoadBalancer). AWS gives the DNS name and not the IP and it will come under "External IP" column. It can be also found in EC2 console under "Load Balancers".
    $ kubectl get svc -n ingress-basic image
  • Browse to the cats, dogs and birds service
    $ http://<<-DNS name as given under external ip column->>/cats
    $ http://<<-DNS name as given under external ip column->>/dogs
    $ http://<<-DNS name as given under external ip column->>/birds
  • Clean up resources
    $ kubectl get all
    $ kubectl delete all --all
    $ kubectl delete ingress --all
    $ kubectl delete all --all -n ingress-basic
    $ kubectl delete namespace ingress-basic
    $ kubectl delete ingressclass nginx
  • List existing resources
    $ kubectl get all
  • Clean up AWS enviornment
    $ eksctl delete cluster --name k8sdemo

    $ kubectl get -A ValidatingWebhookConfiguration
    $ kubectl delete ValidatingWebhookConfiguration nginx-ingress-ingress-nginx-admission

Further references :