kubernetes-ui / container-terminal Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU Lesser General Public License v2.1
License: GNU Lesser General Public License v2.1
I forgot to do this in my PR adding these features!
this is the websocket between font end and back end:
File configFile = new File("config/kubeconfig");
final String configYAML;
configYAML = String.join("\n",Files.readAllLines(configFile.toPath()));
Config kubernetesConfig = Config.fromKubeconfig(configYAML);
kubernetesConfig.setTrustCerts(true);
String urlStr = "https://127.0.0.1/api/v1/namespaces/namespace1/pods/pod1/exec?container=container1&stdin=true&stdout=true&stderr=true&tty=true&command=sh&pretty=true&follow=true";
URL url = new URL(urlStr);
clientWebSocketListener = initServerWebSocket(url, kubernetesConfig);
clientWebSocketListener.setSession(session);
@OnMessage
public void onMessage(Session session, byte[] messages) throws UnsupportedEncodingException {
if (Objects.isNull(session)) {
return;
}
String sessionId = session.getId();
WebsocketMapping websocketMapping = clients.get(sessionId);
ClientWebSocketListener listener = websocketMapping.getListener();
try {
// 向apiServer发送消息
listener.waitUntilReady(1);
listener.send(message.getBytes(), message.length);
} catch (IOException | InterruptedException ie) {
// 通知发送方
session.getAsyncRemote().sendText("向apiServer发送消息失败!失败消息内容: " + message);
}
}
private static ClientWebSocketListener initServerWebSocket(URL url, Config config) {
OkHttpClient client = HttpClientUtils.createHttpClient(config);
final ClientWebSocketListener serverWebSocketListener = new ClientWebSocketListener();
final Request.Builder request = new Request.Builder().url(url).get();
final OkHttpClient clone = client.newBuilder().readTimeout(0, TimeUnit.MILLISECONDS).build();
clone.newWebSocket(request.build(), serverWebSocketListener);
return serverWebSocketListener;
}
here is the onmessage in websocket between apiserver and back end
@Override
public void onMessage(WebSocket webSocket, ByteString bytes) {
readyLatch.countDown();
this.getSession().getAsyncRemote().sendBinary(ByteBuffer.wrap(bytes.toByteArray()));
}
@Override
public void onMessage(WebSocket webSocket, String text) {
readyLatch.countDown();
this.getSession().getAsyncRemote().sendText(text);
}
the problem is this url open container shell successfully but have no response in the following command like ls, or cd bin/. is there are some format conver I miss or some step I miss?
this question confuse me for a long time
Hi, it's a great project which may help a lot. and I am not good at front end programming, so I got a question.
I noticed that you used angular module method in the base example, and it could be used in a normal HTML file, so could I use it in a vue project?
thanks.
Per the readme: https://github.com/chjj/term.js/
Looks like there is a fork that is being maintained, though. https://github.com/sourcelair/xterm.js
It seems "wss" protocol cannot work for k8s web socket.
I tried url "wss://:8080/api/v1/namespaces/kube-system/pods/kube-dns-v11-6l18b/exec?stdout=1&stdin=1&stderr=1&tty=1&container=etcd&command=%2Fbin%2Fsh&command=-i&access_token=". The error message is "OSStatus error -9847".
If I replace "wss" with "ws",it works fine!
Is there anything need to be configured on k8s to make "wss" connection work?
Seems likely access_token in the query of url is not working with the newer versions of k8s.
Is there any other way to authenticate the request?
Regards.
We need to use normal users instead of root users to enter the container terminal,
so change the value of "command" in line 180 of the file 'container-terminal.js' to ["/bin/sh", "-c","useradd ser > /dev/null 2>&1; su - ser "];However, we found many problems in the use of terminals under ordinary users:
how to set fullsreen for kubernetes-container-terminal?
//row21 to row24
if (typeof(define) === 'function' && define.amd)
define(["base1/angular", "base1/term" ], factory);
else
factory(root.angular, root.Terminal);
When define
is defined, it trys to load base1/angular
and base1/term
,but the problem comes out:
there's no base1/angular
and base1/term
!
ps: I install the module by bower install
It seems something like this would be helpful:
<kubernetes-container-terminal
status="status"></kubernetes-container-terminal>
It would be nice to have at least a connected="true||false
published out, but perhaps a status="some-string-status"
would be more useful?
For 'disconnected', I imagine we can update this in line 197
via the socket.on('close')
, or line 154
in the fatal()
func, or line 207
in the disconnect()
function.
Thinking a bit about the best option, may PR it. The initial goal is to be able to track when the terminal crashes/died unexpectedly & hook into this for other UI.
Hi team. @jwforres @stefwalter
Is this repo active? I wonder if this is working with the new version of k8s?
I am willing to contribute
Regards.
I have a config
file in /home/user/.kube/config
, which has a filed "token", but it cannot work.
When I try to input any chinese charactor in vim editor, it throws Uncaught URIError: URI malformed
exception on console.
I find resize need a buffer[0] = 4, and {Width:xxx, Height:xxxx}, where the docs on kubenetes ?
Quick suggestion since we are using the container terminal in the openshift web console as well now. I see the "subject to change" disclaimer on the README.md file. It is much easier to keep up with these changes if the releases lists feature
, bug
, breaking change
, so wanted to toss that suggestion out there.
Thanks!
hi~excuse me, can this only be done as EXEC? does attach support?
I call kubernetes' exec interface and it works, but the log interface prompts 403
This would allow the user of the directive to detect screen size and adjust the terminal accordingly.
Will submit a PR shortly, with an update something like:
var term = new Terminal({
cols: scope.cols || 80,
rows: scope.rows || 24,
screenKeys: scope.screenKeys || true
});
I'm getting the following error. Hitting the correct IP server and URI. If I load it via GET request I get the following
{
"kind": "Status",
"apiVersion": "v1",
"metadata": {},
"status": "Failure",
"message": "Upgrade request required",
"reason": "BadRequest",
"code": 400
}
I can issue commands just fine from kubectl exec
. I'm not using any auth (that I know of) or ssl. I can access exec remotely from my laptop into a cluster in AWS
./kubectl --server="10.122.0.20:8080" exec api-ext-blue-1swdd --namespace=api-ext date
Sun Oct 11 14:42:56 UTC 2015
Not sure what is going on
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.