How to send logs to logstash outside the kubernetes cluster

Hi all,

I followed this page to set up a logstash with k8s.

I can send logs to this logstash within the k8s cluster from other pods.
But, I cannot send logs to the logstash outside the cluster.

Here is my settings:

  • minikube: v1.28.0
  • kubectl: client - 1.26.0, server - 1.25.3
  • helm: v3.10.3
  • ubuntu: 20.04

Here is my additional yaml configs:

ingress:
  enabled: true
  hosts:
    - host: logstash-gelf.testing.com
      paths:
        - path: /
          servicePort: 5959
    - host: logstash-tcp.testing.com
      paths:
        - path: /
          servicePort: 5960

service:
  # annotations: {}
  type: ClusterIP
  # loadBalancerIP: ""
  ports:
    - name: gelf-port
      port: 5959
      protocol: UDP
      targetPort: 5959
    - name: tcp-port
      port: 5960
      protocol: TCP
      targetPort: 5960

extraPorts:
  - name: gelf-port
    containerPort: 5959
  - name: tcp-port
    containerPort: 5960

ingress describe

$ kubectl describe ingress logstash-elastic-logstash
Name:             logstash-elastic-logstash
Labels:           app=logstash-elastic-logstash
                  app.kubernetes.io/managed-by=Helm
                  chart=logstash
                  heritage=Helm
                  release=logstash-elastic
Namespace:        default
Address:          
Ingress Class:    nginx
Default backend:  <default>
Rules:
  Host                      Path  Backends
  ----                      ----  --------
  logstash-gelf.testing.com  
                            /   logstash-elastic-logstash:5959 (172.17.0.3:5959)
  logstash-tcp.testing.com   
                            /   logstash-elastic-logstash:5960 (172.17.0.3:5960)
Annotations:                meta.helm.sh/release-name: logstash-elastic
                            meta.helm.sh/release-namespace: default
Events:                     <none>

The command I tried to use for sending logs:

# from host --- failed
$ echo "Test message" | nc -q0 logstash-tcp.testing.com 80
# from other pod within the cluster --- success
$ echo "Test message" | nc -q0 logstash-elastic-logstash 5960

Anyone has related experience on this?

Thanks