Ingress NginX TCP UDP

It’s quite difficult to set & no precise document to follow. However here it is

1. install ingress-nginx

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.2.0/deploy/static/provider/cloud/deploy.yaml
 
 

2. patch controller deployment & service

kubectl patch -n ingress-nginx deploy ingress-nginx-controller -p '{"spec":{"template": { "spec": { "containers": [ { "name": "controller", "args": [ "/nginx-ingress-controller", "--publish-service=$(POD_NAMESPACE)/ingress-nginx-controller", "--election-id=ingress-controller-leader", "--controller-class=k8s.io/ingress-nginx", "--ingress-class=nginx", "--configmap=$(POD_NAMESPACE)/ingress-nginx-controller", "--validating-webhook=:8443", "--validating-webhook-certificate=/usr/local/certificates/cert", "--validating-webhook-key=/usr/local/certificates/key", "--tcp-services-configmap=ingress-nginx/tcp-services" ] } ] } }}}' kubectl patch -n ingress-nginx svc ingress-nginx-controller -p '{"spec":{"ports":[{ "name": "redis-port", "port": 6379, "targetPort": 6379, "protocol": "TCP" } ]}}'
 
 
 

3. register TCP configmap

apiVersion: v1 kind: ConfigMap metadata: name: tcp-services namespace: ingress-nginx data: 6379: 'hdgen/redis:6379'
 
 
  1. create your deployment
  1. create your service
  1. check TCP connection (UDP is same with word changing)
 
 
 
 
Exposing TCP and UDP services - NGINX Ingress Controller
Ingress does not support TCP or UDP services. For this reason this Ingress controller uses the flags --tcp-services-configmap and --udp-services-configmap to point to an existing config map where the key is the external port to use and the value indicates the service to expose using the format: : :[PROXY]:[PROXY] It is also possible to use a number or the name of the port.
 
 
 

Recommendations