Kubernetes - Akka 集群部署 [英] Kubernetes - Akka clustering Deployment

查看:43
本文介绍了Kubernetes - Akka 集群部署的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个 docker 镜像和一个对应的 yaml 文件,用于使用 kubernetes 进行部署.我们构建的应用程序是在带有 akka-http 的 Scala 中.我们使用了 akka-cluster.我们在使用 pod ip 的应用程序代码中使用的配置文件中有一个特定的变量(在我们的例子中是种子节点 - akka 集群).但是,除非部署完成,否则我们不会获得 pod ip.我们应该如何着手解决这个问题?环境变量会有所帮助吗,如果是的话如何?

We have a docker image and a corresponding yaml file for the deployment using kubernetes. The application we have built is in scala with akka-http. We have used akka-cluster. We have a particular variable(seed-nodes in our case - akka cluster) in the configuration file which is used in our application code that uses the pod ip. But, we will not get the pod ip unless the deployment is done. How should we go about tackling the issue? Will environment variables help, if yes how?

更具体地说,一旦将 docker 镜像部署到容器中的 pod 中,并且当容器启动时,pod ip 已经分配.那么,在进程在容器中启动之前,我们可以以编程方式或以其他方式在我们的代码或配置文件中配置 pod ips 吗?

More specifically, Once the docker images is deployed in the container in a pod, and when the container starts, the pod ip is already assigned. So, can we programmatically or otherwise configure the pod ips in our code or config file before the process starts in the container?

作为参考,这是我们的配置文件:

For reference, this is our configuration file :

akka {
  actor {
    provider = "akka.cluster.ClusterActorRefProvider"
  }    
  remote {
    log-remote-lifecycle-events = off
    netty.tcp {
      hostname = "127.0.0.1"
      port = 0
    }
  }
  cluster {
    seed-nodes = [
      "akka.tcp://our-system@127.0.0.1:3000",
      "akka.tcp://our-system@127.0.0.1:3001",
    ],
    metrics {
      enabled = off
    }
  }    
}
service {
  validateTokenService {
     ml.pubkey.path = "<filePath>"
  }
  ml_repository {
    url = <url address>
  }
  replication.factor = 3
  http.service.interface = "0.0.0.0"
  http.service.port = 8080
}

在上面的文件中,我们需要有 pod-ip,而不是 akka.remote.netty.tcp.hostname 作为127.0.0.1".所以,我们可以在种子节点中使用它:

In the above file, instead of having akka.remote.netty.tcp.hostname as "127.0.0.1", we need to have the pod-ip. So, that we can use it in the seed nodes as :

seed-nodes = [
          "akka.tcp://our-system@hostname:3000",
          "akka.tcp://our-system@hostname:3001",
        ],

我们该怎么做?提前致谢.

How can we do so? Thanks in advance.

推荐答案

截至 2018 年,在 Kubernetes 中初始化 Akka 集群的理想方式是 akka-management.

As of 2018 the ideal way to initialize a Akka Cluster within kubernetes is the akka-management.

它使用 Kubernetes API 获取所有正在运行的 pod 的列表并引导集群.无需配置任何种子节点.

It uses the Kubernetes API to fetch a list of all running pods and bootstrap the cluster. There's no need to configure any seed nodes.

它还提供了等待 Pod 加入集群的就绪检查.还有一张活支票.

It does also provice a readiness check that waits until the pod has joined the cluster. And a alive check.

这篇关于Kubernetes - Akka 集群部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆