项目作者: cjimti

项目描述 :
TCP echo server.
高级语言: Go
项目地址: git://github.com/cjimti/go-echo.git
创建时间: 2018-03-29T16:16:26Z
项目社区:https://github.com/cjimti/go-echo

开源协议:MIT License

下载


Docker Container Image Size
Docker Container Layers
Docker Container Pulls

GO (TCP) Echo

A Simple go TCP echo server. Written to learn and test Kubernetes TCP networking.

Test with Docker

Run the container from a terminal:

  1. docker run --rm -it -e TCP_PORT=2701 -e NODE_NAME="EchoNode" -p 2701:2701 cjimti/go-echo

In another terminal run:

  1. telnet localhost 2701

Test with Kubernetes

  1. cd k8s
  2. kubectl create -f .

You should now have two TCP echo containers running:

  1. kubectl get pods --selector=app=tcp-echo
  1. NAME READY STATUS RESTARTS AGE
  2. tcp-echo-deployment-777d856787-5fhb4 1/1 Running 0 27s
  3. tcp-echo-deployment-777d856787-rh9tp 1/1 Running 0 27s

You should also have a service that connection port 32701 to the pods:

  1. kubectl get service --selector=app=tcp-echo-service
  1. NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
  2. tcp-echo-service NodePort 10.102.207.113 <none> 2701:32701/TCP 35m

Echo some data, replace ANY_NODE_IP with a location of a node:

  1. telnet ANY_NODE_IP 32701

After connecting, type the word hello and hit return:

  1. Trying x.x.x.x...
  2. Connected to node1.example.com.
  3. Escape character is '^]'.
  4. Welcome, you are connected to node node1.example.com.
  5. Running on Pod tcp-echo-deployment-777d856787-rh9tp.
  6. In namespace default.
  7. With IP address 192.168.33.39.
  8. Service default.
  9. hello
  10. hello

Resources