Categorygithub.com/nevercase/k8s-exec-pod
modulepackage
1.0.2
Repository: https://github.com/nevercase/k8s-exec-pod.git
Documentation: pkg.go.dev

# 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

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

go run websocket_client.go --addr=host:port --mode=log -alsologtostderr=true -v=4

ssh mode

go run websocket_client.go --addr=host:port --mode=ssh -alsologtostderr=true -v=4

# Packages

No description provided by the author
No description provided by the author

# Functions

Exec is called by Terminal Executed cmd in the container specified in request and connects it up with the ptyHandler (a Session).
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewSession returns a new Session Interface.
No description provided by the author
Terminal is called from Session as a goroutine Waits for the websocket connection to be opened by the client the session to be bound in Session.HandleProxy.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

ExecOptions passed to ExecWithOptions.
No description provided by the author
No description provided by the author
No description provided by the author
TerminalMessage is the messaging protocol between ShellController and TerminalSession.
TerminalSession implements PtyHandler (using a SockJS connection).
No description provided by the author

# Interfaces

No description provided by the author
PtyHandler is what remotecommand expects from a pty.
Session implements PtyHandler (using a websocket connection).
No description provided by the author

# Type aliases

No description provided by the author