GithubHelp home page GithubHelp logo

Comments (4)

DavadDi avatar DavadDi commented on August 10, 2024
kubectl-debug pod_name -- /bin/sh -c "sleep 2 && ls -hl"

It works.
Because sleep 2 extends the lifecycle of the container, giving the chance to the attach cmd catch the container output when it runs a very short task.

from kubectl-debug.

aylei avatar aylei commented on August 10, 2024

@DavadDi Nice catch! I will investigate how to guarantee the output stream being flushed before the debug container get terminated.

Also, the log without verbosity control concerns me, which adds complexity for automation process to parse the output of executed command. I will file another issue for this.

from kubectl-debug.

Fly-Luck avatar Fly-Luck commented on August 10, 2024

A good approach with sleep, but if you execute kubectl debug via code(e.g. exec.Command in golang), you cannot get the one-time command's output according to my experience.

One approach I came up with is:

  1. modify the netshoot image with an additional volume.
  2. sleep 2 && cmd > file in that volume.

Any better idea? @aylei

from kubectl-debug.

yangxikun avatar yangxikun commented on August 10, 2024

A little ideat: use sleep infinity command to create debug container, then send user cmd(ls -hl) to stdin after attach, otherwise send the default cmd sh to stdin.

from kubectl-debug.

Related Issues (20)

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.