1

我们在 Azure AKS Kubernetes 上使用 Linkerd 2.11.1。除其他外,还有一个使用 Alpine Linux 映像的部署,该映像包含提供 API 的 Apache/mod_php/PHP8。HTTPS 由带有 cert-manager 的 Traefik v2 解析,因此传入 API 的流量在端口 80 上。Linkerd 代理容器作为 Sidecar 注入。

最近看到 API 容器在做 Rolling 部署时,会在短时间内返回 504 错误。在 Sidecars 日志中,我发现以下内容:

[ 0.000590s] INFO ThreadId(01) linkerd2_proxy::rt: Using single-threaded proxy runtime
[ 0.001062s] INFO ThreadId(01) linkerd2_proxy: Admin interface on 0.0.0.0:4191
[ 0.001078s] INFO ThreadId(01) linkerd2_proxy: Inbound interface on 0.0.0.0:4143
[ 0.001081s] INFO ThreadId(01) linkerd2_proxy: Outbound interface on 127.0.0.1:4140
[ 0.001083s] INFO ThreadId(01) linkerd2_proxy: Tap interface on 0.0.0.0:4190
[ 0.001085s] INFO ThreadId(01) linkerd2_proxy: Local identity is default.my-api.serviceaccount.identity.linkerd.cluster.local
[ 0.001088s] INFO ThreadId(01) linkerd2_proxy: Identity verified via linkerd-identity-headless.linkerd.svc.cluster.local:8080 (linkerd-identity.linkerd.serviceaccount.identity.linkerd.cluster.local)
[ 0.001090s] INFO ThreadId(01) linkerd2_proxy: Destinations resolved via linkerd-dst-headless.linkerd.svc.cluster.local:8086 (linkerd-destination.linkerd.serviceaccount.identity.linkerd.cluster.local)
[ 0.014676s] INFO ThreadId(02) daemon:identity: linkerd_app: Certified identity: default.my-api.serviceaccount.identity.linkerd.cluster.local
[ 3674.769855s] INFO ThreadId(01) inbound:server{port=80}: linkerd_app_inbound::detect: Handling connection as opaque timeout=linkerd_proxy_http::version::Version protocol detection timed out after 10s

我的猜测是这种检测会以某种方式导致 504 错误。但是,如果我将 linkerd 入站端口注释添加到 pod 模板(terraform 语法):

resource "kubernetes_deployment" "my_api" {
  metadata {
    name = "my-api"
    namespace = "my-api"
    labels = {
      app = "my-api"
    }
  }

  spec {
    replicas = 20
    selector {
      match_labels = {
        app = "my-api"
      }
    }
    template {
      metadata {
        labels = {
          app = "my-api"
        }
        annotations = {
          "config.linkerd.io/inbound-port" = "80"
        }
      }

我得到以下信息:

time="2022-03-01T14:56:44Z" level=info msg="Found pre-existing key: /var/run/linkerd/identity/end-entity/key.p8"
time="2022-03-01T14:56:44Z" level=info msg="Found pre-existing CSR: /var/run/linkerd/identity/end-entity/csr.der"
[ 0.000547s] INFO ThreadId(01) linkerd2_proxy::rt: Using single-threaded proxy runtime
thread 'main' panicked at 'Failed to bind inbound listener: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }', /github/workspace/linkerd/app/src/lib.rs:195:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

有人可以告诉我为什么它无法绑定入站侦听器吗?

任何帮助深表感谢,

谢谢,

帕斯卡

4

1 回答 1

0
        annotations = {
          "config.linkerd.io/inbound-port" = "80"
        }

我不认为你想要这个设置。Linkerd 将透明地代理连接,无需您进行任何设置。

此设置将 Linkerd 的代理配置为尝试侦听端口 80。这可能与您的 Web 服务器的端口配置冲突;但是您遇到的具体错误是 Linkerd 代理没有以 root 身份运行,因此它没有绑定端口 80 的权限。

如果您删除了该注释,我希望这一切都能正常工作:)

于 2022-03-04T01:07:40.010 回答