【问题标题】:Can't enable logs for Google Cloud Logging无法为 Google Cloud Logging 启用日志
【发布时间】:2020-12-10 11:12:36
【问题描述】:

我正在使用 Google Container Engine 并尝试添加本指南中的日志 http://kubernetes.io/docs/getting-started-guides/logging/

日志控制台中没有日志, 但是 fluentd pod 日志中有很多这样的消息

-> kubectl logs -f --tail=5 fluentd-cloud-logging-gke-we-production-da3a3de4-node-s285 --namespace=kube-system 2016-06-14 17:51:21 +0000 [警告]:抑制相同的堆栈跟踪 2016-06-14 17:51:28 +0000 [警告]:暂时无法刷新缓冲区。 next_retry=2016-06-14 17:51:58 +0000 error_class="Google::APIClient::ClientError" error="调用者没有权限" plugin_id="object:f9a9ac"

它想要什么权限?请帮帮我,我真的坚持下去了

【问题讨论】:

    标签: kubernetes google-cloud-platform


    【解决方案1】:

    听起来 fluentd pod 无法写入谷歌云日志 API 端点。要写入日志,VM 必须在 VM 的默认服务帐户上具有 https://www.googleapis.com/auth/logging.write 范围。

    【讨论】:

    • 你是对的!在 IAM on Compute 服务帐户中,我添加了 Logger 写入权限。但这很奇怪而且不明显,因为那时我正在创建一个“容器集群”,默认情况下设置了 Logging 写入权限。我认为是所有容器主机的共享
    • 但是现在我看到没有任何容器日志的 kubernetes 日志。可能是你现在为什么会这样?
    • 重启 fluentd pod 后所有日志都出现了。谢谢
    • 很高兴为您解决了问题!
    【解决方案2】:

    我现在遇到了类似的问题。

    来自 Gcloud 命令控制台。

    1. 检查您的 IAM 政策

    $gcloud 项目 get-iam-policy [项目名称] --format json

    1. 为用户登录添加以下权限。

    gcloud 项目 add-iam-policy-binding [PROJECT-NAME] --member=user:[Login-email-ID] --role=roles/viewer

    gcloud projects add-iam-policy-binding [PROJECT-NAME] --member=user:[Login-email-ID] --role=roles/logging.viewer
    
    gcloud projects add-iam-policy-binding [PROJECT-NAME] --member=user:[Login-email-ID] --role=roles/logging.logWriter
    
    gcloud projects add-iam-policy-binding [PROJECT-NAME] --member=user:[Login-email-ID] --role=roles/logging.configWriter
    
    gcloud projects add-iam-policy-binding [PROJECT-NAME] --member=user:[Login-email-ID] --role=roles/logging.bucketWriter
    
    gcloud projects add-iam-policy-binding [PROJECT-NAME] --member=user:[Login-email-ID] --role=roles/logging.viewAccessor
    
    gcloud projects add-iam-policy-binding [PROJECT-NAME] --member=user:[Login-email-ID] --role=roles/logging.admin
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-07
      • 2021-08-06
      • 2020-09-12
      • 2017-08-17
      • 2020-10-18
      • 2019-01-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多