• Stars
    star
    203
  • Rank 192,890 (Top 4 %)
  • Language
    Go
  • License
    MIT License
  • Created over 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿงช kubectl alternative with quick context switching, kubectl on steroids

TUBEKIT

All Contributors

tubekit helps you to operate Kubernetes clusters more effectively by reducing time spent on everyday routines.

tubectl

Build Status

Tubectl is a simple yet powerful wrapper around kubectl which adds a bit of magic to your everyday kubectl routines by reducing the complexity of working with contexts, namespaces and intelligent matching resources.

Installation

Arch Linux

The package is always available in AUR: tubekit-git.

Debian/Fedora/CentOS

Packages can be found on releases page.

nix (on Linux or macOS) / nixOS

With flakes support:

$ nix profile install github:reconquest/tubekit

macOS

brew tap reconquest/tubekit https://github.com/reconquest/tubekit.git
brew install tubekit

Binaries

Binaries can be found on releases page.

Standalone

With your GOPATH already set up:

go get github.com/reconquest/tubekit/cmd/...

Usage

asciicast

Quick context

Very often you need to switch between environments and therefore you need to switch your kubectl's context or specify it in kubectl's command line with the flag --context. Well, there is even no short option for that flag. This is where tubectl starts its magic.

You can just specify @ followed by a name of the context, you don't need to specify full name of the context, it will be matched by the existing list of contexts specified in your kubectl configs.

Instead of typing kubectl --context staging or kubectl --context production now you just type tubectl @st or tubectl @prod. It doesn't mean that --context will no longer work because it will. tubectl does not break kubectl as it has full backwards compatibility with the original kubectl.

Quick namespaces

Boring to type -n monitoring, huh? Here is the solution โ€” don't type so much, just type +mon with tubectl. tubectl retrieves a list of namespaces from a cluster and matches given namespace. It's fully back compatible with -n --namespace flags.

Forget about --all-namespaces, just use the ++ flag.

With kubectl you used to do like that:

kubectl --context staging --all-namespaces get pods

Now you can type:

tubectl @st ++ get pods

Instead of kube-system in such command:

kubectl get pods -n kube-system

You can now type like this:

tubectl get pods +sys

Also, you can type ++ and @st at the end of cmdline or in the middle of it, it really doesn't matter โ€” tubectl will figure it out.

Resource matching

That is the real panacea for several problems if you ever had a thought like:

  • tailing logs of multiple containers at the same time
  • executing a command in multiple containers in serial or parallel mode
  • deleting/retrieving/patching all pods/deployments/ingresses matching given regular expression
  • just want to attach to the first container of the pod with several replicas whatever suffix it might have

Meet the matching operator โ€” %.

For example, we have two replicas of nginx running in a cluster:

nginx-59d4c6bbcf-dft5z                  1/1     Running   8          18d
nginx-59d4c6bbcf-dvfd2                  1/1     Running   8          18d

Instead of getting the list of pods and then running kubectl logs against all of them you can do the following:

tubectl logs nginx%

You need to put % at the end of your matching query, tubectl will figure out what resource are you trying to match, will retrieve list of these resources from given cluster with given namespace, will match it and then run your command against these resources with all other arguments you've passed.

When you specify one % at the end of the query tubectl will run the command against all matched resources. If you want to run only against a specific replica, you need to specify its number like %:X, example:

tubectl logs nginx%:1

In this example, tubectl will retrieve all pods matching nginx and then get 1st pod from the list, the same can be applied to the second pod โ€” %:2.

What if you want to run the command against all the pods but in parallel mode?

Similar to ++ for --all-namespaces tubectl introduces an operator %%, let's say you want to tail logs of all nginx pods at the same time, then you just do the following:

tubectl logs nginx%% -f

tubectl will match resources and will run kubectl logs against all pods at the same time.

Other advanced examples

  • Deleting all deployments matching word backend in staging namespace

    tubectl delete deployment +stag backend%
    

    or in parallel (concurrent) mode:

    tubectl delete deployment +stag backend%%
    
  • Describing all statefulsets matching word redis in staging namespace

    tubectl describe sts +stag redis%%
    

    or in parallel (concurrent) mode:

    tubectl describe sts +stag redis%%
    
  • Executing a command in all pods matching word apiserver or scheduler in kube-system namespace

    tubectl exec +sys '(apiserver|scheduler)%' -- id
    

    or in parallel (concurrent) mode:

    tubectl exec +sys '(apiserver|scheduler)%%' -- id
    

Custom flags

Tubectl supports a few own flags, they all have prefix --tube:

  • --tube-version - prints version of the program
  • --tube-debug - enables debug mode, also can be turned on by TUBEKIT_DEBUG
  • --tube-help - prints short help message about the program.

Support

Have a question or problem? Join us in Slack: slack.reconquest.io

Authors

Hire us, we do reduce business costs by optimizing the things.

License

MIT

Contributors

Thanks goes to these wonderful people (emoji key):

Sergey Romanov
Sergey Romanov

๐Ÿ’ป
Dmitry Shaposhnik
Dmitry Shaposhnik

๐Ÿ“ฆ
Harrison Heck
Harrison Heck

๐Ÿ“ฆ

This project follows the all-contributors specification. Contributions of any kind welcome!

More Repositories

1

orgalorg

Parallel SSH commands runner and file synchronization tool
Go
888
star
2

shadowd

Secure login distribution service
Go
361
star
3

shdoc

Documentation generator for shell scripts (bash, sh, zsh). Javadoc for shell scripts.
Awk
263
star
4

barely

Simple and extensible status bar to pretty display of Golang program's progress
Go
257
star
5

hierr-go

Hierarchical errors reporting done right in Golang
Go
73
star
6

vim-autosurround

Automatically insert pairs (brackets, quotes) where they are supposed to be
Python
54
star
7

atlassian-external-hooks

External Hooks plugin for Atlassian Bitbucket
Go
45
star
8

loreley

Simple and extensible colorizer for programs' output
Go
39
star
9

goava

The research project based on the draft design of Go Generics
33
star
10

gunter

Simple configuration system
Go
27
star
11

vim-pythonx

Python libraries for making coding in vim easier
Python
26
star
12

import.bash

Golang-like import statement in bash
Shell
25
star
13

tests.sh

Simple test library for integration and functional testing of daemons, services and command line tools
Shell
21
star
14

coproc.bash

Missing parallel routines (coprocesses) in bash
Shell
16
star
15

karma-go

Everything has a reason.
Go
15
star
16

archiso-zfs

archlinux iso with zfs (archzfs archiso)
Shell
14
star
17

shadowc

Client for the secure login distribution service.
Go
13
star
18

resources-go

Cache that always has a value. Cache that automatically loads values. Refresh caches automatically in background.
Go
11
star
19

rex

Ultimate XKB bindings for insane typing productivity
8
star
20

zeus

zfs backup tool
Go
7
star
21

guntalina

Create and execute command list basing on list of modified/created files and list of rules
Go
7
star
22

opts.bash

Missing very simple option parser for bash
Shell
6
star
23

marvex

Tiling terminal multiplexor
Go
6
star
24

args

Simple CLI parser for bash
Shell
6
star
25

atlassian-pull-request-labels

Pull Request Labels Bitbucket Add-On
Java
5
star
26

taild

Go
5
star
27

executil-go

just do what golang authors can't
Go
5
star
28

bitbucket-external-hook

A cli for enabling/configuring hooks in Atlassian Bitbucket
Go
5
star
29

colorgful

Simple and extensible colorizer for lorg, Go-lang logger
Go
5
star
30

treetrunks

Go
3
star
31

sould

Service for mirroring git repositories
Go
3
star
32

go-test.bash

Collect code coverage while running Go-lang binary
Shell
3
star
33

bmo

The missing tool for parsing structured text, like logs
Go
3
star
34

snippets

marvelous snippets which will change your life
Vim Snippet
3
star
35

health-go

Go
2
star
36

fresh

2
star
37

classes.bash

Classes. In bash.
Shell
2
star
38

ser-go

Go
2
star
39

test-runner.bash

Integrations Test Runner for tests.sh
Shell
2
star
40

snobs

Go
2
star
41

sign-go

Simplest Go signals-per-callback handler.
Go
2
star
42

progress.bash

Shell
2
star
43

cog

Structured key-value logger without breaking order of fields. ๐Ÿ”ง
Go
2
star
44

monk

Based on philosophical papers
Go
2
star
45

workers-go

Go
2
star
46

snake-runner

Snake Runner โ€” The Job Runner for Snake CI
Go
2
star
47

threadpool-go

Go
1
star
48

regexputil-go

Extract subexp names in golang regexp
Go
1
star
49

types.bash

Type checking functions for bash scripts
Shell
1
star
50

charts

Smarty
1
star
51

mrdig

Makefile
1
star
52

when

Go
1
star
53

highlight

easy interface to bash (terminal) escape codes highlighting
Shell
1
star
54

ssh-test.bash

Library for accessing remote nodes by ssh, commonly used in tests
Shell
1
star
55

tmux.bash

Shell
1
star
56

cli

Go
1
star
57

stats-go

Go
1
star
58

vim-colorscheme

Vim Script
1
star
59

xcsyncd

C
1
star
60

pipe

Go
1
star
61

uuid-go

Go
1
star
62

orgalorg-bottlebreaker

Sync tool for orgalorg
Go
1
star
63

bash-get

go get inspired bash get
Shell
1
star
64

zen-go

Go
1
star
65

lexec-go

exec.Command, but with logging
Go
1
star
66

pom

Maven POM parser in Go
Go
1
star