我在定义
1:部署运行官方rabbitmq
映像的pod
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: rabbitmq-deployment
spec:
replicas: 1
template:
metadata:
labels:
els-pod: rabbitmq
spec:
containers:
- image: rabbitmq
name: rabbitmq
ports:
- containerPort: 5672
restartPolicy: Always
2:服务作为包装器,以便可以发现pod
apiVersion: v1
kind: Service
metadata:
name: rabbit
spec:
ports:
- name: rabbit-port
port: 5672
targetPort: 5672
selector:
els-pod: rabbit
我登录了一个容器(pod):
/# nslookup rabbit
Server: 100.64.0.10
Address: 100.64.0.10#53
Name: rabbit.default.svc.cluster.local
Address: 100.71.124.222
然而:
nc rabbit 5672 &> /dev/null; echo $?
1
该港口不开放/无法访问!
我的清单有问题吗?
服务选择器不正确。该pod具有以下元数据:
metadata:
labels:
els-pod: rabbitmq
但该服务正在寻找具有此元数据的pod
selector:
els-pod: rabbit
将选择器更改为此
selector:
els-pod: rabbitmq
它应该工作