Created
January 8, 2016 17:25
-
-
Save kadel/6322bf8a1ba8e7f3bb73 to your computer and use it in GitHub Desktop.
Kubernets: exec using API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://pypi.python.org/pypi/websocket-client/ | |
import websocket | |
import ssl | |
def on_message(ws, message): | |
print message | |
args = {"token": "", | |
"namespace": "testing", | |
"pod": "nonroot-nginx-1-pftqg", | |
"container": "nonroot-nginx", | |
"command": "ls"} | |
url = "wss://console.engint.openshift.com:443/api/v1/namespaces/{namespace}/pods/{pod}/exec?access_token={token}&container={container}&command={command}&stdout=1&stderr=1&stdin=1&tty=1".format(**args) | |
ws = websocket.WebSocketApp(url, on_message=on_message) | |
# sslopt disables ssl/tls verification | |
ws.run_forever(sslopt={"cert_reqs": ssl.CERT_NONE}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment