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

feat(pkg/console): support interactive console #56

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

giannoul
Copy link

@giannoul giannoul commented Jun 15, 2021

This PR introduces the support for interactive console

requires teamhephy/controller#148

Using a github.com/gorilla/websocket we access the k8s API in order to create an interactive console with a container like so:

deis apps:create testadminapp5 --no-remote
Creating Application... done, created testadminapp5
If you want to add a git remote for this app later, use `deis git:remote -a testadminapp5`
deis config:set PORT=5000 --app=testadminapp5
Creating config... done

=== testadminapp5 Config
PORT      5000
deis builds:create igiannoulas/sample-flask-app:v0.1.2 --procfile="{web: python3 app/app.py}" --app=testadminapp5
Creating build... done
deis ps:list -a testadminapp5
=== testadminapp5 Processes
--- web:
testadminapp5-web-6f5b688cb9-jw2wb up (v3)
deis ps:console testadminapp5-web-6f5b688cb9-jw2wb web testadminapp5 /bin/sh --debug=true
Starting console session with command /bin/sh for pod testadminapp5-web-6f5b688cb9-jw2wb for application testadminapp5
INFO[0000] [Start] Container name: testadminapp5-web
INFO[0000] [RoundTrip] Url: wss://10.0.0.119:8443/api/v1/namespaces/testadminapp5/pods/testadminapp5-web-6f5b688cb9-jw2wb/exec?stdout=true&tty=true&command=/bin/sh&container=testadminapp5-web&stdin=true
INFO[0000] [RoundTrip] Decoded token: eyJhbGciOi ... 4vekvJFY_w
# ls
Dockerfile  bin   etc   lib64  opt               root  srv  usr
Procfile    boot  home  media  proc              run   sys  var
app         dev   lib   mnt    requirements.txt  sbin  tmp
# ps faux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root        28  0.0  0.0   4504   704 pts/0    Ss   14:20   0:00 /bin/sh
root       106  0.0  0.0  34424  2840 pts/0    R+   14:25   0:00  \_ ps faux
root         1  0.0  0.3  76128 25892 ?        Ss   14:18   0:00 python3 app/app
root         8  0.3  0.3 233960 26544 ?        Sl   14:18   0:01 /usr/bin/python

The console package introduced required the token that is obtained via teamhephy/controller#148

The console is not as reliable as e.g. an ssh client as controls are not passed (e.g. CTR+D, arrow keys etc) and it requires to type exit and hit enter to quit, but it provides a way of accessing the containers without the kubectl superpowers.

@Cryptophobia Cryptophobia self-requested a review July 15, 2021 01:25
@Cryptophobia
Copy link
Member

This looks good. See comment in the other PR: teamhephy/controller#148 (comment)

Let me know your thoughts.

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

Successfully merging this pull request may close these issues.

None yet

2 participants