# create amazon-cloudwatch namespace apiVersion: v1 kind: Namespace metadata: name: amazon-cloudwatch labels: name: amazon-cloudwatch --- # Deployment apiVersion: apps/v1 kind: Deployment metadata: name: cloudwatch-agent-service namespace: amazon-cloudwatch spec: replicas: 1 selector: matchLabels: name: cloudwatch-agent-service template: metadata: labels: name: cloudwatch-agent-service spec: containers: - name: cloudwatch-agent image: public.ecr.aws/cloudwatch-agent/cloudwatch-agent:latest imagePullPolicy: Always resources: limits: cpu: 200m memory: 100Mi requests: cpu: 200m memory: 100Mi # Pleaes don't change the mountPath volumeMounts: - name: cwagentconfig mountPath: /etc/cwagentconfig volumes: - name: cwagentconfig configMap: name: cwagentconfig-service terminationGracePeriodSeconds: 60 --- # Service kind: Service apiVersion: v1 metadata: name: cloudwatch-agent-service namespace: amazon-cloudwatch spec: selector: name: cloudwatch-agent-service ports: - protocol: UDP port: 8125 # target port should be consistent with the listen port defined in configmap targetPort: 8125 --- # Configmap apiVersion: v1 data: # Configuration is in Json format. No matter what configure change you make, # please keep the Json blob valid. cwagentconfig.json: | { "agent": { "omit_hostname": true }, "metrics": { "metrics_collected": { "statsd": { "service_address":":8125" } } } } kind: ConfigMap metadata: name: cwagentconfig-service namespace: amazon-cloudwatch