I'm current trying deploy an application to connect the rabbitmq.
The application and rabbitmq are on different pod on the same cluster node.
And I can not connect to rabbitMQ via servicename or cluster IP.
Do you have any idea about this problem?
The exeception on app
None of the specified endpoints were reachable
Here is rabbitmq_deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: rabbitmq
namespace: test
spec:
selector:
matchLabels:
run: rabbitmq
replicas: 1
template:
metadata:
labels:
run: rabbitmq
spec:
containers:
- name: rabbitmq
image: rabbitmq_delay_v3.7
imagePullPolicy: IfNotPresent
---
apiVersion: v1
kind: Service
metadata:
name: rabbitmq-svc
namespace: test
labels:
run: rabbitmq
spec:
type: NodePort
ports:
- name: rabbit-web
protocol: TCP
port: 15672
targetPort: 15672
nodePort: 30000
- name: rabbit-svc
protocol: TCP
port: 5672
targetPort: 5672
selector:
run: rabbitmq
Here is app_deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: app_test
namespace: test
spec:
selector:
matchLabels:
run: app_test
replicas: 1
template:
metadata:
labels:
run: app_test
spec:
containers:
- name: app1
image: my_app_image
imagePullPolicy: IfNotPresent
env:
- name: "ASPNETCORE_ENVIRONMENT"
value: "Staging"
---
apiVersion: v1
kind: Service
metadata:
name: app-test-svc
namespace: test
labels:
run: app-test
spec:
type: NodePort
ports:
- name: app_test_port
protocol: TCP
port: 80
targetPort: 80
nodePort: 30203
selector:
run: app_test
And here is config to connect rabbitmq on app
"QueueConfig": {
"HostName": "rabbitmq-svc",
"UserName": "guest",
"Pwd": "guest",
"VirtualHost": "/",
"Port": 5672,
}
Here is output of kubectl -n test describe avc rabbitmq-svc
Name: rabbitmq-svc
Namespace: test
Labels: run=rabbitmq
Annotations: Selector: run=rabbitmq
Type: NodePort
IP: 10.103.189.233
Port: rabbit-web 15672/TCP
TargetPort: 15672/TCP
NodePort: rabbit-web 30000/TCP
Endpoints: 10.244.1.174:15672
Port: rabbit-svc 5672/TCP
TargetPort: 5672/TCP
NodePort: rabbit-svc 31425/TCP
Endpoints: 10.244.1.174:5672
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
Here is output of kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
coredns-66bff467f8-j8494 1/1 Running 1 7d9h
coredns-66bff467f8-jtn5w 1/1 Running 1 7d9h
etcd-master-node 1/1 Running 1 7d9h
kube-apiserver-master-node 1/1 Running 1 7d9h
kube-controller-manager-master-node 1/1 Running 1 7d9h
kube-flannel-ds-amd64-8gd7b 1/1 Running 1 7d9h
kube-flannel-ds-amd64-xj2hw 1/1 Running 1 7d8h
kube-proxy-62wsz 1/1 Running 1 7d9h
kube-proxy-77g2d 1/1 Running 0 7d8h
kube-scheduler-master-node 1/1 Running 1 7d9h