I am running pod in host networking mode i.e., every socket port allocated 
is taken from the host and not within the container network namespace. (the 
reason is to avoid network overlay and bridging performance penalties). So 
I want to build a tool that discover available high ports on the host and 
pass it to k8s.

I wrote a simple python app that initiates socket server that listens on 
port 0. That means that docker will pick random high port from host and 
allocate the socket server on that port.

My python script is app.py
$ cat app.py 
#!/usr/bin/python

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Flask Dockerized'

if __name__ == '__main__':
    app.run(debug=True,host='0.0.0.0',port=0)


When I run it you can see it allocated port 53956. Also, you can see it was 
accessible. 
$ ./app.py 
 * Running on http://0.0.0.0:53956/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger pin code: 603-678-023
127.0.0.1 - - [18/Feb/2017 10:32:46] "GET / HTTP/1.1" 200 -

I want to be able to pass the value 53956 to k8s and run different 
app(apache) that will kill the initial socket server on port 53956 and 
start the new app, the apache on port 53956. 

e.g., my pods spec will look like:

ports:

        - containerPort: 53956

        livenessProbe:

          httpGet:

            path: /index.html

            port: 53956

          initialDelaySeconds: 3

          periodSeconds: 3

Any idea how one can do that?



-- 
You received this message because you are subscribed to the Google Groups 
"Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to kubernetes-users+unsubscr...@googlegroups.com.
To post to this group, send email to kubernetes-users@googlegroups.com.
Visit this group at https://groups.google.com/group/kubernetes-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to