Search code examples
kubernetesactivemq-classickubectl

ActiveMQ Broker url on Kubernetes


I have deployed my ActiveMQ on Kubernetes, but how to configure the broker to connect queue using port 61616? If I use the POD IP then it will not be static IP and every time pod recreate will create new IP. Is there anyway to get static IP or using ingress can we setup broker on port 61616?


Solution

  • This is a Community Wiki answer so feel free to edit it and add any additional details you consider important.

    For exposing any of your microservices in kubernetes either externally or internally you have a Service

    As David Maze already stated in his comment:

    There should be a matching Service, which will have a known DNS name; use that. – David Maze yesterday

    You don't need to worry about static IP. Services have also dynamic IPs assigned but they provide a reliable way to access your backend Pods via stable DNS name. Take a look also at this section in the official docks.

    In your case its enough to create a simple ClusterIP Service (which is the default Service type). It may look as follows:

    apiVersion: v1
    kind: Service
    metadata:
      name: my-service
    spec:
      selector:
        app: MyApp
      ports:
        - protocol: TCP
          port: 61616
          targetPort: 61616
    

    provided your app is listening on TCP port 61616 and you want your Service to expose the same port (port) as your Pods (targetPort).