I am defining
1: a Deployment for a pod running the official rabbitmq
image
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: a Service as a wrapper, so that the pod(s) are discoverable
apiVersion: v1
kind: Service
metadata:
name: rabbit
spec:
ports:
- name: rabbit-port
port: 5672
targetPort: 5672
selector:
els-pod: rabbit
I am logged in a container(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
However:
nc rabbit 5672 &> /dev/null; echo $?
1
The port is NOT open/accessible!
Is sth wrong with my manifests?
The service selector is incorrect. The pod has this metadata:
metadata:
labels:
els-pod: rabbitmq
But the service is looking for pods with this metadata
selector:
els-pod: rabbit
Change the selector to this
selector:
els-pod: rabbitmq
And it should work