|
| 1 | +# Monitoring EKS using CloudWatch Container Insigths |
| 2 | + |
| 3 | +## Step-01: Deploy our Sample to generate Load |
| 4 | +``` |
| 5 | +# Deploy |
| 6 | +kubectl apply -f kube-manifests |
| 7 | +
|
| 8 | +# Access Application |
| 9 | +http://<Network-Load-Balancer-URL>/app1/index.html |
| 10 | +``` |
| 11 | + |
| 12 | +## Step-02: Associate CloudWatch Policy to our EKS Worker Nodes Role |
| 13 | +- Go to Services -> EC2 -> Worker Node EC2 Instance -> IAM Role -> Click on that role |
| 14 | +``` |
| 15 | +# Sample Role ARN |
| 16 | +arn:aws:iam::180789647333:role/eksctl-eksdemo1-nodegroup-eksdemo-NodeInstanceRole-1FVWZ2H3TMQ2M |
| 17 | +
|
| 18 | +# Policy to be associated |
| 19 | +Associate Policy: CloudWatchAgentServerPolicy |
| 20 | +``` |
| 21 | + |
| 22 | +## Step-03: Install Container Insights |
| 23 | + |
| 24 | +### Deploy CloudWatch Agent and Fluentd as DaemonSets |
| 25 | +- This command will |
| 26 | + - Create the Namespace amazon-cloudwatch. |
| 27 | + - Create all the necessary security objects for both DaemonSet: |
| 28 | + - SecurityAccount. |
| 29 | + - ClusterRole. |
| 30 | + - ClusterRoleBinding. |
| 31 | + - Deploy Cloudwatch-Agent (responsible for sending the metrics to CloudWatch) as a DaemonSet. |
| 32 | + - Deploy fluentd (responsible for sending the logs to Cloudwatch) as a DaemonSet. |
| 33 | + - Deploy ConfigMap configurations for both DaemonSets. |
| 34 | +``` |
| 35 | +# Template |
| 36 | +curl -s 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}}/<REPLACE_CLUSTER_NAME>/;s/{{region_name}}/<REPLACE-AWS_REGION>/" | kubectl apply -f - |
| 37 | +
|
| 38 | +# Replaced Cluster Name and Region |
| 39 | +curl -s 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}}/eksdemo1/;s/{{region_name}}/us-east-1/" | kubectl apply -f - |
| 40 | +``` |
| 41 | + |
| 42 | +## Verify |
| 43 | +``` |
| 44 | +kubectl -n amazon-cloudwatch get daemonsets |
| 45 | +``` |
| 46 | + |
| 47 | + |
| 48 | +## Step-04: Access CloudWatch Dashboard & Generate Traffic using Postman Runner |
| 49 | +- Access CloudWatch Container Insigths Dashboard |
| 50 | +- Generate some traffic using Postman Runner |
| 51 | + |
| 52 | +## Step-05: CloudWatch Log Insights |
| 53 | +- View Container logs |
| 54 | + |
| 55 | + |
| 56 | +## Step-06: CloudWatch Alarms from metrics |
| 57 | +- Create Alarms |
| 58 | + |
| 59 | + |
| 60 | +## Step-07: Clean-Up Container Insights |
| 61 | +``` |
| 62 | +# Template |
| 63 | +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}}/cluster-name/;s/{{region_name}}/cluster-region/" | kubectl delete -f - |
| 64 | +
|
| 65 | +# Replace Cluster Name & Region Name |
| 66 | +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}}/eksdemo1/;s/{{region_name}}/us-east-1/" | kubectl delete -f - |
| 67 | +``` |
| 68 | + |
| 69 | +## References |
| 70 | +- https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/deploy-container-insights-EKS.html |
0 commit comments