GithubHelp home page GithubHelp logo

nevercase / k8s-exec-pod Goto Github PK

View Code? Open in Web Editor NEW
14.0 2.0 4.0 138 KB

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.

Go 97.23% Makefile 1.50% Dockerfile 1.27%
terminal websocket-proxy k8s-exec-pod k8s-logs-pod pod-log-download k8s-client-go

k8s-exec-pod's Introduction

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

k8s-exec-pod's People

Contributors

dependabot[bot] avatar nevercase avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.