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

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

问题描述

我们有一个docker映像和一个相应的yaml文件,用于使用kubernetes进行部署.我们构建的应用程序在带有akka-http的scala中.我们使用了akka集群.我们在使用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映像部署在容器中的容器中,并且当容器启动时,容器IP已被分配.因此,在容器中开始该过程之前,我们可以通过编程方式或其他方式在代码或配置文件中配置Pod ip吗?

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
}

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

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.

推荐答案

我尝试了一些非常相似的方法.您可以做的是使用状态集 Kubernetes-状态集.有状态集具有命名约定,并且将对Pod进行相应命名-您可以在链接中了解有关状态的更多信息.这样,您就可以对种子节点的值进行硬编码,因为您知道将如何命名吊舱.但是,它们有一个缺点,有状态集尚不支持滚动更新(主要是因为它们是按这种方式设计的.)本文逐步给出了很好的解释:

I have tried something very similar. What you can do is use stateful sets Kubernetes-Stateful sets. Stateful sets have a naming convention and the pods will be named accordingly - you can read more about that in the link. This way, you can hard-code the values for the seed-nodes, since you know how the pods are going to be named. But, they have a drawback, stateful sets don't yet support rolling update(primarily because they are designed that way.) This article has a great explanation step by step : stateful set - akka clustering This article explains everything together - so posting a link instead of copying the steps here. Hope this helps

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

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