Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nevercase/k8s-exec-pod
This is a simple and easy way for you to execute commands inside a k8s pod, watch logs through the websocket proxy and even download current or previous logs with a specific container name.
https://github.com/nevercase/k8s-exec-pod
k8s-client-go k8s-exec-pod k8s-logs-pod pod-log-download terminal websocket-proxy
Last synced: about 1 month ago
JSON representation
This is a simple and easy way for you to execute commands inside a k8s pod, watch logs through the websocket proxy and even download current or previous logs with a specific container name.
- Host: GitHub
- URL: https://github.com/nevercase/k8s-exec-pod
- Owner: neverCase
- Created: 2020-09-09T10:03:02.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-05-05T02:28:54.000Z (over 1 year ago)
- Last Synced: 2024-06-19T05:41:10.939Z (7 months ago)
- Topics: k8s-client-go, k8s-exec-pod, k8s-logs-pod, pod-log-download, terminal, websocket-proxy
- Language: Go
- Homepage:
- Size: 135 KB
- Stars: 14
- Watchers: 2
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# k8s-exec-pod
This is a simple and easy way for you to execute commands inside a k8s pod, watch logs through the websocket proxy and even download current or previous logs with specific container name.## Notice
- A terminal is not just an input field.
- It's a complex system that provides advanced formatting and interactivity with the user, over a plain character stream.
- Here is a classic case: if you transmit the command `clear` to the ssh pty, then the response you received would be "clear: command not found"
- So we should listen and compare `each character` instead of inputting a full command with the `\n` (e.g. `"pwd\n"`)## build server
```sh
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o exec-bin example/main.go
...
./exec-bin -kubeconfig=$HOME/.kube/config --proxyservice=0.0.0.0:9090
```
- if you run the exec binary file inside a k8s pod, just use the command below:
```
./exec-bin --proxyservice=0.0.0.0:9090
```## run websocket_client for testing
### log mode
```sh
go run websocket_client.go --addr=host:port --mode=log -alsologtostderr=true -v=4
```### ssh mode
```sh
go run websocket_client.go --addr=host:port --mode=ssh -alsologtostderr=true -v=4
```