100 Days of AWS — Day 14 — Monitor performance of EKS Cluster using CloudWatch Container Insights
To view the complete course, please enroll it using the below link(it’s free)
https://www.101daysofdevops.com/courses/100-days-of-aws/
Welcome to Day 14 of 100 Days of AWS. The topic for today is Monitor performance of EKS Cluster using CloudWatch Container Insights.
Elastic Kubernetes Service(EKS) is the defacto standard for managing the Kubernetes cluster. Using EKS, AWS will take care of most tasks like patching and provisioning your cluster, performing upgrades, etc.
Using CloudWatch container insight, you can collect, summarize, and aggregate metrics and logs for your containerized application and microservices. It currently supports services like:
- Amazon Elastic Container Service(ECS)
- Amazon Elastic Kubernetes Service(EKS)
- Kubernetes platforms on Amazon EC2
These metrics include CPU, Memory, Disk, and network utilization. It also helps us provide diagnostic information like container restart failure to help you quickly isolate and resolve problems.
To launch your Kubernetes Cluster, you can use tools like eksctl. For more info check the following link.
- To deploy CloudWatch Container Insights run the following command
curl https://raw.githubusercontent.com/aws-samples/amazon-cloudwatch-container-insights/latest/k8s-deployment-manifest-templates/deployment-mode/daemonset/container-insights-monitoring/quickstart/cwagent-fluentd-quickstart.yaml | sed "s/{{cluster_name}}/dev/;s/{{region_name}}/us-west-1/" | kubectl apply -f -
- Where dev is the name of the EKS cluser
- us-west-1 is the region where cluster is deployed
When you execute the above command, it will create the amazon-cloudwatch namespace, set up the CloudWatch and Fluentd agent, create cloudwatch-agent service accounts, and create configmap for cloudwatch agent deploy cloudwatch agent as daemonsets.
serviceaccount/cloudwatch-agent createdclusterrole.rbac.authorization.k8s.io/cloudwatch-agent-role createdclusterrolebinding.rbac.authorization.k8s.io/cloudwatch-agent-role-binding createdconfigmap/cwagentconfig createddaemonset.apps/cloudwatch-agent createdconfigmap/cluster-info createdserviceaccount/fluentd createdclusterrole.rbac.authorization.k8s.io/fluentd-role createdclusterrolebinding.rbac.authorization.k8s.io/fluentd-role-binding createdconfigmap/fluentd-config createddaemonset.apps/fluentd-cloudwatch created
- You can verify the status of CloudWatch and Fluentd pod using below commands
kubectl get pods -n amazon-cloudwatchNAME READY STATUS RESTARTS AGEcloudwatch-agent-7rmlk 1/1 Running 0 4m29scloudwatch-agent-b9cth 1/1 Running 0 4m29scloudwatch-agent-vrgnl 1/1 Running 0 4m29sfluentd-cloudwatch-29vxd 1/1 Running 0 4m28sfluentd-cloudwatch-5rvqg 1/1 Running 0 4m28sfluentd-cloudwatch-h52q4 1/1 Running 0 4m28s
- Now go to the CloudWatch dashboard https://us-west-1.console.aws.amazon.com/cloudwatch , Under Insights, click on Container Insights
- From the drop down select Performance monitoring and under Select clusters, select your EKS cluster.You will see the dashboard like this which display metrics like CPU, memory utilization and various Network statistics across EKS cluster.
- From the drop down you can even select the metrics at the pod level
- OR even at EKS node level