Configure access to the service via TCP protocol
Configure access to the service via TCP protocol
The Ingress object in Kubernetes by default supports routing external traffic to services only via HTTP(s). 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.
Create ConfigMap
-
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>
— namespace in which the service is located;<service_name>
— the name of the service for which you are configuring TCP access;<service_port>
— service port.
-
Create ConfigMap:
kubectl apply -f <configmap.yaml>
Specify
<configmap.yaml>
is the name of the yaml file containing the manifest for ConfigMap that you created in step 1.
To configure the Ingress Controller
Add the --tcp-services-configmap
flag to the Ingress Controller arguments:
args:
- /nginx-ingress-controller
- --tcp-services-configmap=ingress-nginx/tcp-services