All Projects → kylieCat → kx

kylieCat / kx

Licence: Apache-2.0 license
A more stream lined way to move around k8s contexts and namespaces

Programming Languages

go
31211 projects - #10 most used programming language
python
139335 projects - #7 most used programming language
shell
77523 projects
Makefile
30231 projects

Projects that are alternatives of or similar to kx

mllint
`mllint` is a command-line utility to evaluate the technical quality of Python Machine Learning (ML) projects by means of static analysis of the project's repository.
Stars: ✭ 67 (+219.05%)
Mutual labels:  golang-application
whatsapp-jpeg-repair
A handy tool to fix jpeg files downloaded from WhatsApp and prevent errors upon opening these files in Adobe Photoshop.
Stars: ✭ 30 (+42.86%)
Mutual labels:  golang-application
kubectl-secretdata
A kubectl plugin for viewing decoded Secret data with search flags.
Stars: ✭ 37 (+76.19%)
Mutual labels:  kubectl
eventsourcing-go
Event Sourcing + CQRS using Golang Tutorial
Stars: ✭ 75 (+257.14%)
Mutual labels:  golang-application
kubectl-janitor
List Kubernetes objects in a problematic state
Stars: ✭ 48 (+128.57%)
Mutual labels:  kubectl
Golang-Files-Preview
Golang 文件预览支持 office\pdf\cad\achieve\txt\image\video files
Stars: ✭ 53 (+152.38%)
Mutual labels:  golang-application
kubectlsafe
Safe operations in kubectl with plugin kubectlsafe
Stars: ✭ 36 (+71.43%)
Mutual labels:  kubectl
kube-lineage
A CLI tool to display all dependencies or dependents of an object in a Kubernetes cluster.
Stars: ✭ 238 (+1033.33%)
Mutual labels:  kubectl
trustydns
DNS Over HTTPS proxy, server and query programs
Stars: ✭ 22 (+4.76%)
Mutual labels:  golang-application
ecsview
Browse your AWS ECS Clusters in the Terminal
Stars: ✭ 100 (+376.19%)
Mutual labels:  golang-application
insta
Instagram power tool
Stars: ✭ 56 (+166.67%)
Mutual labels:  golang-application
kubeadm-vagrant
Setup Kubernetes Cluster with Kubeadm and Vagrant
Stars: ✭ 49 (+133.33%)
Mutual labels:  kubectl
aksctl
An easy to use CLI for AKS cluster
Stars: ✭ 46 (+119.05%)
Mutual labels:  kubectl
gitops-kubernetes-cluster
A quick way to build a cluster with ArgoCD then deploy via Applications
Stars: ✭ 34 (+61.9%)
Mutual labels:  kubectl
mikrotik-fwban
Use your Mikrotik firewall to do fail2ban like blocking of unwanted IPs. Written in Go
Stars: ✭ 22 (+4.76%)
Mutual labels:  golang-application
kahoy
Simple Kubernetes raw manifests deployment tool
Stars: ✭ 33 (+57.14%)
Mutual labels:  kubectl
kubectl-ssh-plugin-eks
This is plugin to SSH into Worker Nodes running on AWS
Stars: ✭ 18 (-14.29%)
Mutual labels:  kubectl
kubeconfig-loader
A simple bash script for rotating local kubeconfigs
Stars: ✭ 20 (-4.76%)
Mutual labels:  kubectl
n3dr
Nexus3 Disaster Recovery (N3DR) is a tool that is capable of downloading all artifacts from a Nexus3 server and to migrate them to another Nexus3 server. Note that some repository formats are not supported at the moment.
Stars: ✭ 110 (+423.81%)
Mutual labels:  golang-application
kubehelper
KubeHelper - simplifies many daily Kubernetes cluster tasks through a web interface. Search, analysis, run commands, cron jobs, reports, filters, git synchronization and many more.
Stars: ✭ 200 (+852.38%)
Mutual labels:  kubectl

kx

A more convenient method for changing contexts and name spaces for kubectl

Usage:

kx [context [namespace]] [-a|--all] [-s|--set] [--no-color] [-r|--rename NEW_NAME]

To add to prompt:

$ export PROMPT_COMMAND=$(kx prompt)

Examples:

Change context and namespace

$ kx new-context new-namespace

Use a dash as the context name to stay in the same context but change namespace

$ kx - new-namespace

Change context, keep the namespace set in .kube/config

$ kx new-context

Change back to the previous context and namespace

$ kx
first-ctx first-ns
$ kx second-ctx second-ns
$ kx
second-ctx second-ns
$ kx -
$ kx
first-ctx first-ns
$ kx -
$ kx
second-ctx second-ns

Generate tab completion for the contexts in your kubeconfig

$ eval "$(kx complete)"
$ kx <tab><tab>
foo-prd        gke_prd-usc1-1     foo-test
foo-gke-prd    int-usw1a          stg-use1a
foo-gke-stg    minikube           stg-use1b

Rename a context

$ kx -r new-name old-name

Show current context and namespace

$ kx
current-context current-namespace

Set a favorite context/namespace pair

[some-ctx:some-ns]
$ kx fave-ctx fave-ns -f my-fave
...
[some-ctx:some-ns]
$ kx my-fave
[fave-ctx:fave-ns]
$ 

Show all contexts and namespaces. Favorites for each ns are listed as well

$ kx -a
Current Context     Namespace       Favorites
        foo-prd     bar             prod=foo-prd:bar
-->     foo-test    kube-system     pkube=foo-test:kube-system,test=foo-test:bar

Configuration

kx is a cobra app so it is configured the same way as any other similar app.

The default location for this file is $HOME/.kx.yaml. The prompt generated by kx prompt can by configured here. Favorites are also stored here.

Configuring the Prompt

The prompt is completely configurable. The parts of which are defined like so:

prompt:
  separator: string
  leftWrapper: string
  rightWrapper: string
  contextColor: color* 
  namespaceColor: color*
  separatorColor: color*
  colorOff: \033[0m  # special required value, will be depracated 

* see color configuration*

To display a prompt that appears like this:

[the-context:the-namespace]

The following configuration can be used:

prompt:
  separator: ':'
  leftWrapper: '['
  rightWrapper: ']'
  contextColor: Red
  namespaceColor: K8sBlue
  separatorColor: White

How it looks with color:

color prompt

To display a prompt that appears like this:

(the-context➡ the-namespace)

The following configuration can be used:

prompt:
  separator: '➡ '
  leftWrapper: '('
  rightWrapper: ')'
  contextColor: MayaBlue
  namespaceColor: LightPink1
  separatorColor: White

How it looks with color:

color prompt

Colors

Colors are configured using the name of the color. These names can be found in pkg/colors/colors.go.

You can print the available color options with the kxcolors command.

$ kx kxcolors 
Name
Aquamarine1
Aquamarine3
Black
Blue1
Blue3
...

Each name will be displayed in the color it represents. You can add these names to your .kx.yaml manually or use the set command. After using set you will need to re-source the prompt command:

$ kx kxcolors set [-c|--context] <COLOR NAME> [-s|--separator] <COLOR NAME> [-n|--ns] <COLOR NAME>
$ eval "$(kx prompt)"

Note: color names may change slightly in the future to be consistent with Go capitalization.

Favorites

Favorites are also stored in in .kx.yaml. Should be pretty obvious how these work:

favorites:
  pkube:
    context: foo-test
    namespace: kube-system
  prod:
    context: foo-prd
    namespace: bar
  test:
    context: foo-test
    namespace: bar

Todo

  • Work with custom locations of kubeconfig via the KUBECONFIG env var.
  • Support for favorite ctx/namespace pairs.
  • Add context names to bash completion.
  • Ability to rename contexts.
  • Return to previous context/namespace
  • Work with locations of kubeconfig passed via the command line.
  • Command to show color options.
  • Code clean up.
  • Better error messaging.

Thanks

Thanks to the following folks for helping out, you guys rock!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].