Coder Social home page Coder Social logo

janossarusikis / kube-exec Goto Github PK

View Code? Open in Web Editor NEW

This project forked from radu-matei/kube-exec

0.0 1.0 0.0 532 KB

Lightweight Golang package for executing commands in remote Kubernetes pods

Home Page: https://engineerd.github.io/kube-exec/introduction/

License: MIT License

Makefile 2.63% Go 97.37%

kube-exec's Introduction

kube-exec

CircleCI Go Report Card Documentation

kube-exec is a library similar to os/exec that allows you to run commands in a Kubernetes pod, as if that command was executed locally.

It is inspired from go-dexec by ahmetb, which does the same thing, but for a Docker engine.

The interface of the package is similar to os/exec, and essentially this:

  • creates a new pod in Kubernetes based on a user-specified image
  • waits for the pod to be in Running state
  • attaches to the pod and allows you to stream data to the pod through stdin, and from the pod back to the program through stdout and stderr

How to use it

cfg := kube.Config{
	Kubeconfig: os.Getenv("KUBECONFIG"),
	Image:      "ubuntu",
	Name:       "kube-example",
	Namespace:  "default",
}

cmd := kube.Command(cfg, "/bin/sh", "-c", "sleep 2; echo Running from Kubernetes pod;")
cmd.Stdout = os.Stdout

err := cmd.Run()
if err != nil {
	log.Fatalf("error: %v", err)
}

Here's a list of full examples you can find in this repo:

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.