Exposing TCP and UDP services in Kubernetes using nginx-ingress
1 min readJan 31, 2020
Nginx-ingress provides us with the capability to manage HTTP/HTTPS traffic for multiple services. But ingress doesn’t support TCP or UDP services. But there is a workaround, using nginx-ingress we can use the args --tcp-services-configmap
and --udp-services-configmap
to map an exposed (external world) port to a corresponding Kubernetes service using a configmap
.
Deploying nginx-ingress using deployment:
In nginx-ingress Deployment manifest, use the argument --tcp-services-configmap
The corresponding configmap:
apiVersion: v1
kind: ConfigMap
metadata:
name: tcp-services
namespace: default
data:
27017: "default/tcp-svc:27017"
Deploying nginx-ingress using helm charts:
apiVersion: flux.weave.works/v1beta1
kind: HelmRelease
metadata:
name: nginx-ingress
namespace: default
spec:
releaseName: nginx-ingress
chart:
repository: https://kubernetes-charts.storage.googleapis.com
name: nginx-ingress
version: 1.6.10
values:
tcp:
27017: "default/tcp-svc:27017"