Skip to main content
Configure access to the service via TCP protocol
Last update:

Configure access to the service via TCP protocol

The Ingress object in Kubernetes by default supports routing external traffic to services via HTTP(s) only. To access a service in a Managed Kubernetes cluster over TCP, you must configure access through the Ingress Controller.

TCP access may be required, for example, when deploying a database, cache server, or other services that run over TCP.

We will look at configuring access through the Nginx Ingress Controller.

  1. Create ConfigMap.
  2. Set up Ingress Controller.

Create ConfigMap

  1. Create a yaml file with a manifest for the ConfigMap object:

    Manifesto example:

    apiVersion: v1
    kind: ConfigMap
    metadata:
    name: tcp-services
    namespace: ingress-nginx
    data:
    <external_port>: "<namespace>/<service_name>:<service_port>"

    Specify:

    • <external_port> — external port to access the service;
    • <namespace> is the namespace in which the service resides;
    • <service_name> is the name of the service for which you are configuring TCP access;
    • <service_port> — service port.
  2. Create ConfigMap:

    kubectl apply -f <configmap.yaml>

    Specify <configmap.yaml> is the name of the yaml file with the manifest for ConfigMap that you created in step 1.

Customize Ingress Controller

In the Ingress Controller arguments, add the --tcp-services-configmap flag:

args: 
- /nginx-ingress-controller
- --tcp-services-configmap=ingress-nginx/tcp-services