是的,
namespace
您可以通过主机名从任何容器访问和通信。
这是一个关于 KubernetesService
配置的示例:
---
apiVersion: v1
kind: Service
metadata:
name: master
labels:
name: master
namespace: smart-office
spec:
ports:
- port: 5672
name: master
targetPort: 5672
selector:
name: master
Deployment
配置:
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: master
labels:
name: master
namespace: smart-office
spec:
replicas: 1
template:
metadata:
labels:
name: master
annotations:
prometheus.io/scrape: "false"
spec:
containers:
- name: master
image: rabbitmq:3.6.8-management
ports:
- containerPort: 5672
name: master
nodeSelector:
beta.kubernetes.io/os: linux
以及来自其他服务,例如您的slaver
.env
意愿是:
AMQP_HOST=master <---- The hostname
AMQP_PORT=5672
AMQP_USERNAME=guest
AMQP_PASSWORD=guest
AMQP_HEARTBEAT=60
即使您不发布外部 IP,它也可以在集群内工作。
希望这可以帮到你。