Helm 在 Amazon EKS 上安装 Fluentd-Cloudwatch

Helm to install Fluentd-Cloudwatch on Amazon EKS

尝试在 Amazon EKS 上使用 helm 安装 "incubator/fluentd-cloudwatch" 并将用户设置为 root 时,我收到以下响应。

使用的命令:

helm install --name fluentd incubator/fluentd-cloudwatch --set awsRegion=eu-west-1,rbac.create=true --set extraVars[0]="{ name: FLUENT_UID, value: '0' }"

错误:

Error: YAML parse error on fluentd-cloudwatch/templates/daemonset.yaml: error converting YAML to JSON: yaml: line 38: did not find expected ',' or ']'

如果我们不将用户设置为 root,则默认情况下,fluentd 以 "fluent" 用户运行,其日志显示:

[error]: unexpected error error_class=Errno::EACCES error=#<Errno::
EACCES: Permission denied @ rb_sysopen - /var/log/fluentd-containers.log.pos>`

基于 this 看起来它只是试图将 eu-west-1,rbac.create=true 转换为 JSON 字段作为字段,并且有一个额外的逗号 (,) 导致它失败。

如果您查看 values.yaml,您会看到正确的单独选项是 awsRegionrbac.create,因此 --set awsRegion=eu-west-1 --set rbac.create=true 应该修复第一个错误。

关于 /var/log/... Permission denied 错误,您可以看到 here that its mounted as a hostPath 所以如果您执行以下操作:

# (means read/write user/group/world)
$ sudo chmod 444 /var/log 

和你所有的节点,错误应该消失了。请注意,您需要将它添加到所有节点,因为您的 pod 可以降落在集群中的任何位置。

下载并更新 values.yaml 如下。更改在 awsRegion、rbac.create=true 和 extraVars 字段中。

annotations: {}

awsRegion: us-east-1
awsRole:
awsAccessKeyId:
awsSecretAccessKey:
logGroupName: kubernetes

rbac:
## If true, create and use RBAC resources
create: true

## Ignored if rbac.create is true
serviceAccountName: default
# Add extra environment variables if specified (must be specified as a single line 
object and be quoted)
extraVars:
- "{ name: FLUENT_UID, value: '0' }"

然后 运行 下面的命令在 Kubernetes 集群上设置 fluentd 以将日志发送到 CloudWatch Logs。

$ helm install --name fluentd -f .\fluentd-cloudwatch-values.yaml incubator/fluentd-cloudwatch

我这样做了并且对我有用。日志已发送到 CloudWatch Logs。还要确保您的 ec2 节点具有对 CloudWatch Logs 具有适当权限的 IAM 角色。