# 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: - name: statsd protocol: UDP port: 8125 targetPort: 8125 - name: csm protocol: UDP port: 31000 targetPort: 31000 --- # 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" } } }, "csm": { "service_addresses": ["udp4://0.0.0.0:31000", "udp6://[::]:31000"], "memory_limit_in_mb": 20 } } kind: ConfigMap metadata: name: cwagentconfig-service namespace: amazon-cloudwatch