Kubernetes External Connection

7/16/2018

I am trying to setup a simple knock-knock server in my cluster and currently it works internally but I cannot get it to connect from a remote connection. For reference this is the server I am trying to use just for testing purposes. https://docs.oracle.com/javase/tutorial/networking/sockets/clientServer.html

Currently I am using NGINX Ingress Controller.

NAME              TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
knock-server      ClusterIP      10.104.42.238    <none>        9000/TCP         25m


testing@host:~$ java KnockKnockClient 10.104.42.238 9000
Server: Knock! Knock!

I have other Ingress's that work perfectly but those are for website related deployments and not for an internal server like this. I have tried 2 different Ingress's but neither work.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: knockknock-ingress
spec:
  rules:
  - host: domain.com
    http:
      paths:
      - backend:
          serviceName: knock-server
          servicePort: 9000

And

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: knock-ingress
spec:
   backend:
    serviceName: knock-server
    servicePort: 9000

I am not sure what I am doing wrong on this one, and any and all help is appreciated.

-- Erwin
kubernetes
kubernetes-ingress

1 Answer

7/17/2018

You can use ingress controller to expose tcp service.

  1. change the ingress controller to include the following parameter:
--tcp-services-configmap tcp-configmap-example

Name of the ConfigMap containing the definition of the TCP services to expose. The key in the map indicates the external port to be used. The value is a reference to a Service in the form "namespace/name:port", where "port" can either be a port number or name. TCP ports 80 and 443 are reserved by the controller for servicing HTTP traffic.

  1. Create the configmap for tcp service:
apiVersion: v1
kind: ConfigMap
metadata:
  name: tcp-configmap-example
data:
  9000: "default/knock-server:9000"
-- Kun Li
Source: StackOverflow