我已经做了一些尽职调查,甚至深入研究了Akka代码,但我不明白为什么我的节点会通过kubernetes-api被发现,一个节点自加入,提升到leader,但另一个节点由于leader无法解析请求者的地址而无法加入集群。我将分别发布应用程序配置和日志。
这是一个包含2个节点(目前)的Akka集群,使用Akka Management和Akka Discovery使用kubernetes-api发现2个pods中的节点。我使用了一个自定义标签选择器“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行,因为当我添加它们时,行为并没有改变。
发布于 2019-10-29 00:33:40
因此,事实证明,第二个节点无法响应加入成功事件的原因(我们在日志中看到了这一点)是由于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
}
}
}希望这能帮助其他人避免一周半的工作效率损失。
https://stackoverflow.com/questions/58550650
复制相似问题