Skip to content
Run main.go in Kubernetes with one command
Branch: master
Clone or download
Latest commit 2ff5e38 Jun 17, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
example make the project go get-able May 30, 2018
.gitignore configure goreleaser Jun 17, 2019
.goreleaser.yml update goreleaser Jun 17, 2019
LICENSE Initial commit Apr 26, 2018 Update Dec 5, 2018
go.mod specify pod resource limits Jun 17, 2019
go.sum go mod tidy Jun 17, 2019
kurun Sleep tight Apr 27, 2018
kurun.go fix limits Jun 17, 2019


Just like go run main.go but executed inside Kubernetes with one command.


A Kubernetes cluster, where you have access to the image storage of the cluster itself, for example:

  • Docker for Mac Edge with Kubernetes enabled
  • Minikube with the Registry addon enabled


Bash version

curl > /usr/local/bin/kurun && chmod +x /usr/local/bin/kurun

Go version

go get


kurun test.go arg1 arg2 arg3

kurun is like go run

The go run command is a really convenient CLI subcommand for executing Golang code during the development phase. A lot of our applications are making calls to the Kubernetes API and we needed a quick utility to execute the Go code inside Kubernetes very quickly. That's why we have written kurun, a dirty little bash utility, to execute Go code inside Kubernetes with a oneliner:

kurun main.go

It's that easy.

To see how you can leverage kurun let’s try checking it out with a small example which lists all nodes in your Kubernetes cluster:

package main

import (

	metav1 ""

func main() {

	config, err := rest.InClusterConfig()
	if err != nil {

	client, err := kubernetes.NewForConfig(config)
	if err != nil {

	nodes, err := client.CoreV1().Nodes().List(metav1.ListOptions{})
	if err != nil {

	fmt.Println("List of Kubernetes nodes:")
	for _, node := range nodes.Items {
		fmt.Printf("- %s - %s\n", node.Name, node.Labels)

Execute the following commands in the CLI, make sure your kubectl points to the cluster you would like to use:

git clone
cd kurun
# Download the dependencies, this is just a one-time step to get the k8s libraries
go get ./...
./kurun example/test.go
Sending build context to Docker daemon  31.05MB
Step 1/2 : FROM alpine
 ---> 3fd9065eaf02
Step 2/2 : ADD main /
 ---> 0f4ee24ec5ea
Successfully built 0f4ee24ec5ea
Successfully tagged kurun:latest
List of Kubernetes nodes:
- docker-for-desktop - map[]

For some more details and examples please read this post.

You can’t perform that action at this time.