Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hello, World: Pass listening port in YAML config #9

Open
aaaaalbert opened this issue Aug 10, 2018 · 12 comments
Open

Hello, World: Pass listening port in YAML config #9

aaaaalbert opened this issue Aug 10, 2018 · 12 comments

Comments

@aaaaalbert
Copy link
Contributor

I try to streamline the Hello, World tutorial and remove as many preparation steps as possible. For example, I want to reuse an existing image off DockerHub instead of having to create my own.

However, the NodeJS code currently has the listening port number hardcoded. I can't thus reuse someone else's image because then I might hit their old deployed instance unknowingly.

A way around having to rebuild the Docker image for every experimenter could be to supply the listening port through the YAML config: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/

This should allow us to start the NodeJS server inside the Docker image with per-experimenter config from the YAML, i.e. a single image will do for everyone taking the tutorial.

@aaaaalbert
Copy link
Contributor Author

A Python2 version of the echo server is available from my fork of this repo, https://github.com/aaaaalbert/edgenet-project.github.io/blob/simpler-hello-world/assets/other/echo_server.py .

It takes the listening port as a command line argument.

@aaaaalbert
Copy link
Contributor Author

Alternatively and perhaps even simpler, the server inside the container can run on and expose via the Dockerfile its default port (8000 in my case), and we use Kubernetes to forward another port to the one that the pod exposes.

I'm testing this in my "mini hello world" right now.

@aaaaalbert
Copy link
Contributor Author

aaaaalbert commented Aug 17, 2018

The expose command of kubectl seems to be a way to do just this.

Example:

kubectl --kubeconfig=sundew.cfg expose pod echo123-pvwgp --port=49134 --container-port=8000

@boldt
Copy link

boldt commented Aug 20, 2018

I suggest creating a new organization called edge-net on https://hub.docker.com/ where you push the hello world example server. Wrt to my docker-express-example, I use the following config:

apiVersion: extensions/v1beta1
kind: ReplicaSet
metadata:
 name: docker-express-example
spec:
 template:
   metadata:
     labels:
       app: docker-express-example
   spec:
     containers:
       - name: docker-express-example
         image: boldt/docker-express-example:0.0.1
         ports:
         - containerPort: 3000
           hostPort: <randomPort>

Cant you just say: "Replace <randomPort> with a random port"?

@aaaaalbert
Copy link
Contributor Author

Thanks for the suggestion! We have https://hub.docker.com/r/edgenetproject/ for this purpose already, but the helloworld there isn't yet up to the task.

@aaaaalbert
Copy link
Contributor Author

Cant you just say: "Replace with a random port"?

I think so, but I got stuck testing last week due to responsiveness issues with nodes. (The nodes were restarted since.)

@boldt
Copy link

boldt commented Aug 22, 2018

You can, just remove hostNetwork: true, since for usual docker application it is not required at all

@boldt
Copy link

boldt commented Aug 22, 2018

The hostNetwork setting applies to the Kubernetes pods. When a pod is configured with hostNetwork: true, the applications running in such a pod can directly see the network interfaces of the host machine where the pod was started.

http://alesnosek.com/blog/2017/02/14/accessing-kubernetes-pods-from-outside-of-the-cluster/

@aaaaalbert
Copy link
Contributor Author

Thank you very much for pointing this out. Tested & working in the upcoming "mini hello world", aaaaalbert@c23ce18e9a9bf2ae0642177b8b3fec8e78066c1f.

@boldt
Copy link

boldt commented Aug 24, 2018

I wonder about the port range 40000-65000. RFC 6335 (IANA) recommends 49152-65535:

the Dynamic Ports, also known as the Private or Ephemeral Ports, from 49152-65535 (never assigned)

https://tools.ietf.org/html/rfc6335

@boldt
Copy link

boldt commented Aug 24, 2018

since we didn't specify where this should be placed it will be placed at a node chosen by Kubernetes.

Is it possible to specify this? I haven't found out yet.

@aaaaalbert
Copy link
Contributor Author

  1. I chose some port range only guaranteed to not lie in the well-known range, before the discussion with @rickmcgeer about firewalls etc. The "mini" hello world isn't canon yet, though :-)

  2. The discussion about node placement is going on here, Needs to be a way for a user to specify which nodes he runs on edgenet-legacy-2024#44. The current idea is to use labels. Feel free to join!

@EdgeNet-project EdgeNet-project deleted a comment from boldt Aug 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants