Search code examples
kuberneteskubernetes-ingressbitnaminats.io

How to expose nats(bitnami) using Ingress


I have an Nginx ingress controller in my Kubernetes cluster and I use bitnami/nats.

The services produced are the following:

NAME                TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)             AGE
nats-client         ClusterIP   10.72.13.82   <none>        4222/TCP            36m
nats-cluster        ClusterIP   10.72.8.67    <none>        6222/TCP            36m
nats-headless       ClusterIP   None          <none>        4222/TCP,6222/TCP   36m
nats-monitoring     ClusterIP   10.72.2.102   <none>        8222/TCP            36m

When I kubefwd the port(4222) I can connect to it, but using the below ingress it doesn't work.

Here's my ingress.yaml

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-controller
  annotations:
    kubernetes.io/ingress.class: "nginx"
    kubernetes.io/tls-acme: "true"
    cert-manager.io/cluster-issuer: "letsencrypt-cluster-issuer"
spec:
  tls: 
  - hosts: 
    - NATS_DOMAIN
    secretName: secret
  rules:
  - host: NATS_DOMAIN
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service: 
            name: nats-client
            port:
              number: 4222

Any help would be highly appreciated!


Solution

  • This is a bit late, but NATS is not an http based protocol so this cannot be done with an http based ingress component. Instead it can bee done using load balancers.