Configuring TCP service access
This guide explains how to configure access via the Nginx Ingress Controller.
The Ingress object in Kubernetes supports routing external traffic to services via HTTP(s) by default. To access a service in a Managed Kubernetes cluster via TCP, you need to configure access through an Ingress Controller.
TCP access may be required, for example, when deploying a database, cache server, or other services that operate over the TCP protocol.
Create a ConfigMap
-
Create a YAML file with a manifest for the ConfigMap object:
Manifest example:
apiVersion: v1kind: ConfigMapmetadata:name: tcp-servicesnamespace: ingress-nginxdata:<external_port>: "<namespace>/<service_name>:<service_port>"Specify:
<external_port>— the external port for accessing the service;<namespace>— the namespace where the service is located;<service_name>— the name of the service for which you are configuring TCP access;<service_port>— the service port.
-
Create the ConfigMap:
kubectl apply -f <file_name>Specify
<file_name>— the name of the yaml file with the ConfigMap manifest you created in step 1. For example,configmap.yaml.
Configure the Ingress Controller
Add the Ingress Controller arguments to include the --tcp-services-configmap: flag:
args:
- /nginx-ingress-controller
- --tcp-services-configmap=ingress-nginx/tcp-services