Skip to content

Instantly share code, notes, and snippets.

@MdSahil-oss
Last active December 22, 2023 14:54
Show Gist options
  • Save MdSahil-oss/8887d02c1ea80d140cd413909f50217c to your computer and use it in GitHub Desktop.
Save MdSahil-oss/8887d02c1ea80d140cd413909f50217c to your computer and use it in GitHub Desktop.
A DevOps project

Scalable Deployments in Kubernetes and more

In this project I deployed my personal web application on AWS EKS, which Kubernetes automatically horizontally scale up and scale down, Means the number of pods of my application in a node gets scaled up and scaled donw by an Autoscaler on the basis of resources load on each pod.

Used Technologies:

  • AWS
  • Kubernetes
  • Docker
  • ArgoCD
  • Bash

Implementation details

  • Created an ECR registry on AWS to store application container images.

  • Created an AWS Pipeline that is triggered when an update happens to the repository personal-web and an container image is built by the AWS PipeLine and pushed to the created ECR registry.

  • Then created a deployment of my web application inside k8s cluster with a ClusterIP service.

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: personal-web-deployment
      labels:
        app: personal-web
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: personal-web
      template:
        metadata:
          labels:
            app: personal-web
        spec:
          imagePullSecrets:
            - name: docker-registry-secret
          containers:
            - name: personal-web
              image: mdsahiloss/personal-web:latest
              ports:
                - containerPort: 3000
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: personal-web-svc
      labels:
        app: personal-web
    spec:
      type: ClusterIP
      ports:
        - name: http
          protocol: TCP
          port: 80
          targetPort: 3000
      selector:
        app: personal-web
    
  • Then created an Autoscaler inside Kubernetes configuired by AWS EKS that scale up and scale down number of pods of my application deployment on the basis of load on my each pod.

    $ kubectl autoscale deployment personal-web-deployment --cpu-percent=80 --min=1 --max=10
  • Then configured an Ingress inside Kubernetes cluster (that Nginx ingress controller handles) that allows users to access the running web application inside Kubernetes cluster from outside of cluster.

    apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
     name: personal-web-ingress
    spec:
     ingressClassName: nginx
     rules:
       - host: mdsahil-oss.me
         http:
           paths:
             - path: /
               pathType: Prefix
               backend:
                 service:
                   name: personal-web-svc
                   port:
                     number: 80
    
  • Then, I Obtained a load balancer service domain to access the web site, which was very ugly. So, I linked that load-balancer domain name with my own domain name mdsahil-oss.me using [namecheap](https://www.namecheap.com/) web tool to access the website using domain mdsahil-oss.me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment