DEV Community

ashutoshbhakare
ashutoshbhakare

Posted on

AWS EKS Ingress - Canary

Dealing with Canary

In this article I will be trying to explain, on how to create a canary deployment using AWS Application LoadBalancer using canary behavior

We need to consider below pre-requisite before we deploy our application, (using AWS Cloud shell to do this demo)

  1. Preinstalled eks cluster ( Ref: https://docs.aws.amazon.com/eks/latest/userguide/create-cluster.html)
  2. Helm Command should works on your AWS Cloud Shell ( Ref: https://docs.aws.amazon.com/eks/latest/userguide/helm.html)
  3. eksctl command is already installed in my case ( Ref: https://docs.aws.amazon.com/eks/latest/userguide/lbc-helm.html)
  4. AWS Load Balancer Controller Should be installed already ( Ref: https://docs.aws.amazon.com/eks/latest/userguide/lbc-helm.html)
  5. I have enabled subnet autodiscovery option by adding tags referred https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.1/deploy/subnet_discovery/ Below is the graphical representation of my example Image description I have deployed two applications for doing this test, one is httpd running on 80 port number and the other one is hello-openshift running on 8080, this can be deployed using below commands


kubectl create deployment mydep1 --image=docker.io/httpd
kubectl expose deployment mydep1 --port=80
kubectl create deployment mydep2 --image=docker.io/openshitf/hello-openshift
kubectl expose deployment mydep2 --port=8080


Enter fullscreen mode Exit fullscreen mode

We are using default service type called clusterIP as our ingress will point to these services, please refer the below screenshots

Image description

Image description
below is the yaml code for our ingress.yaml file



apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: "canary"
  annotations:
    kubernetes.io/ingress.class: alb
    alb.ingress.kubernetes.io/scheme: internet-facing
    alb.ingress.kubernetes.io/target-type: ip
    alb.ingress.kubernetes.io/actions.blue-green: |
      {
        "type":"forward",
        "forwardConfig":{
          "targetGroups":[
            {
              "serviceName":"mydep1",
              "servicePort":"80",
              "weight":50
            },
            {
              "serviceName":"mydep2",
              "servicePort":"8080",
              "weight":50
            }
          ]
        }
      }
  labels:
    app: canary
spec:
  rules:
    - http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: blue-green
                port:
                  name: use-annotation


Enter fullscreen mode Exit fullscreen mode

kubectl apply -f ingress.yaml can se used to deploy this , once deployed we will get output like below

Image description
Now let's try to run the for loop to test the 50-50 percentage canary deployment

Image description

We can clearly conclude the 50-50 load is getting distributed using the canary ingress.

Note: I was facing issues while deploying EKS Load Balancer controller, by using kubectl logs -f -n kube-system -l app.kubernetes.io/instance=aws-load-balancer-controller command was able to conclude the error was coming due to subnet tags was missing.

Happy Learning !!!

Top comments (1)

Collapse
 
srinivish profile image
srinivish

Very nicely explained and easy to follow , thank you Ashutosh.