[英]Kubernetes on Spinnaker - Interservice communication
I have a sample application running on a Kubernetes cluster. 我有一个在Kubernetes集群上运行的示例应用程序。 Two microservices, one is a mongodb container and the other is a java springboot container.
两个微服务,一个是mongodb容器,另一个是java springboot容器。
The springboot container interacts with the mongodb container thro a service and stores data into the mongodb container. springboot容器通过服务与mongodb容器进行交互,并将数据存储到mongodb容器中。
The specs are provided below. 规格在下面提供。
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: empappdepl
labels:
name: empapp
spec:
replicas: 1
template:
metadata:
labels:
name: empapp
spec:
containers:
-
resources:
limits:
cpu: 0.5
image: 11.168.xx.xx:5000/employee:latest
imagePullPolicy: IfNotPresent
name: wsemp
ports:
- containerPort: 8080
name: wsemp
command: ["java","-Dspring.data.mongodb.uri=mongodb://mongoservice/microservices", "-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
imagePullSecrets:
- name: myregistrykey
---
apiVersion: v1
kind: Service
metadata:
labels:
name: empwhatever
name: empservice
spec:
ports:
- port: 8080
nodePort: 30062
type: NodePort
selector:
name: empapp
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: mongodbdepl
labels:
name: mongodb
spec:
replicas: 1
template:
metadata:
labels:
name: mongodb
spec:
containers:
- resources:
limits:
cpu: 1
image: mongo
imagePullPolicy: IfNotPresent
name: mongodb
ports:
- containerPort: 27017
---
apiVersion: v1
kind: Service
metadata:
labels:
name: mongowhatever
name: mongoservice
spec:
ports:
- port: 27017
targetPort: 27017
protocol: TCP
type: NodePort
selector:
name: mongodb
I would like to know how this communication can be accomplished in spinnaker since it creates its own labels and selectors. 我想知道在三角帆中如何实现这种通信,因为它创建了自己的标签和选择器。
Thanks, 谢谢,
This is how it needs to be done. 这就是需要做的事情。
Each loadbalancer created for the application is the service. 为应用程序创建的每个负载均衡器都是服务。 So for mongodb application, after a loadbalancer is created with the nodeport settings, get the name of the service eg: mongodb-dev.
因此,对于mongodb应用程序,在使用nodeport设置创建负载均衡器之后,获取服务的名称,例如:mongodb-dev。 The server group for mongodb also needs to be created.
还需要创建mongodb的服务器组。
Then when creating the employee server group, you need to specify the commands one by one in a separate line for that container as mentioned here 然后,在创建员工服务器组时,您需要在该容器的单独一行中一一指定命令,如此处所述
https://github.com/spinnaker/spinnaker/issues/2021#issuecomment-334885467 https://github.com/spinnaker/spinnaker/issues/2021#issuecomment-334885467
"java","-Dspring.data.mongodb.uri=mongodb://name-of-mongodb-service/microservices", "-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"
Now when the employee and mongodb pod starts, it is able to get its mapping and able to communicate properly. 现在,当员工和mongodb Pod启动时,便可以获取其映射并能够正确通信。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.