【问题标题】:GKE Metadata Server is unavailable when Horizental Pod Auto Scaler start to work当 Horizo​​ntal Pod Autoscaler 开始工作时,GKE 元数据服务器不可用
【发布时间】:2021-04-06 14:23:03
【问题描述】:

使用 WorkloadIdentity 运行 Pod 会在自动扩展启动时产生 Google 凭据错误。

我的应用程序配置了 WorkloadIdentity 以使用 Google Pub/Sub,还设置了 Horizo​​ntalPodAutoscaler 以将 Pod 扩展到最多 5 个副本。

当自动缩放器创建 pod 的副本时,会出现问题,GKE 的元数据服务器在几秒钟内无法工作,然后在 5 到 10 秒后没有产生错误。

这是自动缩放器创建 pod 后的错误日志。

WARNING:google.auth.compute_engine._metadata:Compute Engine Metadata server unavailable onattempt 1 of 3. Reason: timed out
WARNING:google.auth.compute_engine._metadata:Compute Engine Metadata server unavailable onattempt 2 of 3. Reason: timed out    
WARNING:google.auth.compute_engine._metadata:Compute Engine Metadata server unavailable onattempt 3 of 3. Reason: timed out
WARNING:google.auth._default:Authentication failed using Compute Engine authentication due to unavailable metadata server
Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or explicitly create credentials and re-run the application. For more information, please see https://cloud.google.com/docs/authentication/getting-started

这到底是什么问题?

当我从这里阅读文档时workload identity docs

"The GKE metadata server takes a few seconds to start to run on a newly created Pod"

我认为问题与这个问题有关,但是这种情况有解决方案吗?

谢谢

【问题讨论】:

    标签: kubernetes google-kubernetes-engine gcloud


    【解决方案1】:

    除了确保您的应用程序能够应对此问题外,没有特定的解决方案。 Kubernetes 使用 DaemonSets 来启动每个节点的应用程序,例如元数据拦截服务器,但正如文档清楚地告诉您的那样,这需要几秒钟(注意新节点、调度 pod、拉取图像、启动容器)。

    您可以使用 initContainer 来阻止您的应用程序在某些脚本返回之前启动,这可以尝试访问 GCP API 直到它工作为止。但这可能比仅仅在发生这些错误时重试代码更有效。

    【讨论】:

    • 感谢您的回答。我最好在尝试连接到 GCP API 时破例。
    猜你喜欢
    • 2021-06-01
    • 1970-01-01
    • 2023-03-26
    • 1970-01-01
    • 2019-08-22
    • 2018-10-09
    • 2018-10-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多