Reputation: 1
I have deployed Rabbitmq statefulset inside my EKS cluster pod is up and running and also i can able to perform the port forwarding to test the rabbitmq UI page service connection using localhost:port number.
To achieve TCP port expose i have created configmap in default namespace where my Rabbitmq pod is running.
apiVersion: v1
kind: ConfigMap
metadata:
name: tcp-services
data:
5672: "default/rabbitmq-service:5672"
Followed by above configmap i have created Rabbitmq services as a clusterIP services
apiVersion: v1
kind: Service
metadata:
name: rabbitmq
labels:
app: rabbitmq
spec:
selector:
app: rabbitmq
ports:
- name: http
protocol: TCP
port: 15672
targetPort: 15672
- name: amqp
protocol: TCP
port: 5672
targetPort: 5672
- name: amqps
protocol: TCP
port: 5671
targetPort: 5671
Finally nginx ingress yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/backend-protocol: HTTPS
name: rabbit-ingress
spec:
ingressClassName: nginx
rules:
- host:my-host.com
http:
paths:
- backend:
service:
name: rabbitmq
port:
number: 5672
path: /
pathType: Prefix
How to test and validate the TCP connection port connection after all the configuration which applied.
Upvotes: 0
Views: 232
Reputation: 4168
From the official Kubernetes documentation
An Ingress does not expose arbitrary ports or protocols. Exposing services other than HTTP and HTTPS to the internet typically uses a service of type Service.Type=NodePort or Service.Type=LoadBalancer.
As well a service of type ClusterIP
can't be used, because this type of service is only for cluster-local loadbalancing.
In Kubernetes, Services are an abstract way to expose an application running on a set of Pods. Services can have a cluster-scoped virtual IP address (using a Service of type: ClusterIP).
So you could use a service of type LoadBalancer
for example
apiVersion: v1
kind: Service
metadata:
name: rabbitmq
spec:
type: LoadBalancer
ports:
- appProtocol: amqps
name: amqps
port: 5671
protocol: TCP
targetPort: 5671
selector:
app: rabbitmq
Upvotes: 1