Ingress Exposing TCP Services

A guide explains how to expose tcp and udp services running in your cluster, through the ingress controller

Pranav Sharma
Pranav Sharma
June 16, 2021
4 min read

The Email API by developers, for developers

Integrate in minutes with our Email API or SMTP and deliver emails to customer's inbox instantly. Mailazy Email API built for developers that fits into any tech stack.

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: <namespace/service name>:<service port>:[PROXY]:[PROXY].

This guide describes how it can be achieved but doing this through your deployment chart is different.

Following guide assumes you have a fresh cluster with no NGINX Ingress installed.

Install NGINX Ingress using Helm

Follwing commands will install NGINX Ingress using Helm to the default namespace where nginx is being the release name and ingress-nginx/ingress-nginx is the repo.

Install helm 3

curl | bash

Add Ingress repo

helm repo add ingress-nginx

Install NGINX Ingress on default namespace

helm repo update
helm install nginx ingress-nginx/ingress-nginx

Deploy your application

Here we are going to deploy an SMTP application and it's service to 587 port as ClusterIP type and then to expose it later using our ingress. Remember to replace the <IMAGE> value below.


apiVersion: apps/v1
kind: Deployment
  name: smtp-chart
  labels: chart-0.10.0 chart smtp "0.1.0" Helm
    matchLabels: chart smtp
      labels: chart smtp-develop
        - name: registry-secret
        - name: chart
          image: "<IMAGE>"
            - containerPort: 587
              protocol: TCP
              port: 587
              port: 587


apiVersion: v1
kind: Service
  name: smtp-chart
  labels: chart-0.10.0 chart smtp "0.1.0" Helm
  type: ClusterIP
    - port: 587
      targetPort: 587
      protocol: TCP
      name: smtp
  selector: chart smtp

Patch NGINX Ingress

Download the default values.yaml file for ingress-nginx.

change following:

tcp: {}
#  8080: "default/example-tcp-svc:9000"


  587: default/smtp-chart:587

Here default is the namespace of your TCP service or pod, and smtp-chart is the deployment name that we defined in the deployment.yaml The following command will update you nginx controller, create the required config map and update config fields:

helm upgrade --install -n default nginx ingress-nginx/ingress-nginx --values values.yaml --wait

Check NGINX Ingress service

kubectl get svc -n default
NAME                                       TYPE           CLUSTER-IP       EXTERNAL-IP             PORT(S)                                    AGE
nginx-ingress-nginx-controller             LoadBalancer   80:30918/TCP,443:32010/TCP,587:32516/TCP   12m
nginx-ingress-nginx-controller-admission   ClusterIP     <none>                  443/TCP                                    13d

In above output ingress is listening to port 587.

That's it!

You should be able to test it via telnet your ingress load balancer or external IP.

telnet 587

Mailazy Docs

Integrate with Transactional email service in minutes

click here

Most Popular Tags

EngineeringSMTPShort ReadBest PracticesEmailAPIsEmail SecurityCommunicationEmail APIEmail Delivery

What is Mailazy?

Mailazy is a Transactional Email Platform specially built for developers which satisfies the requirement for use cases like Reset Password Emails, OTP Emails, Welcome Emails, and so on. The Mailazy platform helps you to send transactional emails seamlessly and track email deliverability. Mailazy enables your applications to send messages via a simple HTTP REST interface or via easy SMTP integration and abstracts away the complexities of sending transactional emails.

Visit website

Pranav Sharma

Pranav Sharma

Pranav Sharma is a Lead Software Development Engineer at Mailazy. He graduated in Computer Science and considers himself a learner of life. He loves to play cricket, football and computer games.

View Profile