使用kubernetes api发现Akka群集连接失败

使用kubernetes api发现Akka群集连接失败,akka,akka-cluster,Akka,Akka Cluster,我做了一些尽职调查,甚至深入研究了Akka代码,但不明白为什么我的节点会通过kubernetes api被发现,一个节点自连接,提升到leader,但另一个由于leader无法解析请求者的地址而无法加入集群。我将分别发布应用程序配置和日志 这是一个2节点(目前)Akka集群,使用Akka管理和Akka发现,使用kubernetes api发现2个吊舱中的节点。我正在使用一个自定义标签选择器“application=vcsvc,environment=multibox,akka cluster=v

我做了一些尽职调查,甚至深入研究了Akka代码,但不明白为什么我的节点会通过kubernetes api被发现,一个节点自连接,提升到leader,但另一个由于leader无法解析请求者的地址而无法加入集群。我将分别发布应用程序配置和日志

这是一个2节点(目前)Akka集群,使用Akka管理和Akka发现,使用kubernetes api发现2个吊舱中的节点。我正在使用一个自定义标签选择器“application=vcsvc,environment=multibox,akka cluster=vcsvc”

有人能帮我找出我在哪里错误配置了东西吗

application.conf中的代码段:

akka: {
  management: {
    cluster: {
      bootstrap: {
        # optionally prohibits creating a new cluster, forcing a member to wait until cluster is formed
        new-cluster-enabled: on

        contact-point-discovery: {
          # pick the discovery method you'd like to use:
          discovery-method: "kubernetes-api"

          # the exact number of nodes for the initial startup of the cluster
          required-contact-point-nr: 2
        }
      }

      health-check: {
        # Ready health check returns 200 when cluster membership is in the following states.
        # Intended to be used to indicate this node is ready for user traffic so Up/WeaklyUp
        # Valid values: "Joining", "WeaklyUp", "Up", "Leaving", "Exiting", "Down", "Removed"
        ready-states: ["Up", "WeaklyUp"]

        readiness-path: "health/ready"
        liveness-path: "health/alive"
      }
    }
  }

  discovery: {
    # Set the following in your application.conf if you want to use this discovery mechanism:
    method: kubernetes-api

    kubernetes-api: {
      class = akka.discovery.kubernetes.KubernetesApiServiceDiscovery

      # API server, cert and token information. Currently these are present on K8s versions: 1.6, 1.7, 1.8, and perhaps more
      api-ca-path = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
      api-token-path = "/var/run/secrets/kubernetes.io/serviceaccount/token"
      api-service-host-env-name = "KUBERNETES_SERVICE_HOST"
      api-service-port-env-name = "KUBERNETES_SERVICE_PORT"

      # Namespace to query for pods.
      #
      # Set this value to a specific string to override discovering the namespace using pod-namespace-path.
      pod-namespace = ${com.apptio.vcsvc.namespace}

      # Selector value to query pod API with.
      # `%s` will be replaced with the configured effective name, which defaults to the actor system name
      pod-label-selector: "application="${com.apptio.vcsvc.namespace}",environment="${com.apptio.vcsvc.environment}",akka-cluster="${com.apptio.vcsvc.cluster.name}
    }
  }
}

我会根据要求添加更多内容。我正在询问方法行和api行,因为在我添加它们时,行为没有改变。

因此,第二个节点无法响应加入成功事件(我们在日志中看到了这种情况)的原因是由于
akka.remote
配置存在问题。由于Lightbend/Akka的所有文档和示例代码都指示我们使用
Akka.remote.artery
,因此这一点对我们来说并不明显。出于我尚未确定的原因,这在本地发现环境中有效,但在K8环境中无效。相反,我需要使用
akka.remote.netty.tcp
。为了清楚起见,我将把完整的配置放在下面

失败:

akka: {
  remote: {
    artery: {
      enabled: on
      transport: tcp
      canonical.port: 2552
    }
  }
}
工作:

akka: {
  remote: {
    netty.tcp: {
      hostname:  ${HOSTNAME}
      port: 2552
    }
  }
}

希望有一天这能帮助其他人避免一周半的工作效率损失。

我可以在这里发布日志:您也可以使用arthery设置主机名,如下所示: