Amazon CloudWatch
AWS 文档中描述的 AWS 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 AWS 服务入门

更新 CloudWatch 代理容器映像

CloudWatch Container Insights isn't released yet. It's in preview and is subject to change. The preview is open to all AWS accounts. You do not need to request access.


kubectl set image ds/cloudwatch-agent cloudwatch-agent=new-image-container -n amazon-cloudwatch

要实现滚动更新,您必须确保 cwagent-daemonset.yaml 文件中的 .spec.template 部分具有更改。否则,Kubernetes 将 DaemonSet 视为未更改。通常的做法是将 ConfigMap 的哈希值添加到 .spec.template.metadata.annotations.configHash 中,如以下示例中所示。

yq w -i cwagent-daemonset.yaml spec.template.metadata.annotations.configHash $(kubectl get cm/cwagentconfig -n amazon-cloudwatch -o yaml | sha256sum)

这会在 cwagent-daemonset.yaml 文件中添加哈希值,如以下示例中所示。

spec: selector: matchLabels: name: cloudwatch-agent template: metadata: labels: name: cloudwatch-agent annotations: configHash: 88915de4cf9c3551a8dc74c0137a3e83569d28c71044b0359c2578d2e0461825


kubectl apply -f cwagent-daemonset.yaml

有关 yq 的更多信息,请参阅 yq