Kubernetes - How is ingress-nginx tcp services exposed?

12/8/2020

I'm trying to figure out how port 1234 and 1235 is exposed when I add it to configMap. It works but I don't see a config to read these configMaps and expose the service.

apiVersion: v1
kind: ConfigMap
metadata:
  name: tcp-services
  namespace: ingress-nginx
data:
  1234: "test-web-dev/httpd:1234"
  1235: "test-web-dev/tomcat7:1235"
---
kind: Service
apiVersion: v1
metadata:
  name: ingress-nginx
  namespace: ingress-nginx
  labels:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
spec:
  externalTrafficPolicy: Local
  type: LoadBalancer
  selector:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
  ports:
    - name: http
      port: 80
      protocol: TCP
      targetPort: http
    - name: https
      port: 443
      protocol: TCP
      targetPort: https

---
-- John Doe
kubernetes
kubernetes-ingress
nginx-ingress

1 Answer

12/8/2020

The ConfigMap is consumed by the Nginx Ingress, as can be found here: https://kubernetes.github.io/ingress-nginx/user-guide/exposing-tcp-udp-services/

Usually you would have to define how the ConfigMap data is used by yourself, but the developers of the Nginx Ingress already did that for you, so you just have to provide the ConfigMap.

-- Simon K.
Source: StackOverflow