updatecontext

module
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2021 License: Apache-2.0

README

kubectl updatecontext

GitHub Release Go Report Card

Kubectl plugin that manages kubernetes contexts. It will create context in <namespace/<cluster> format. Contexts for non-existent namespaces will be deleted (e.g., after you delete namespace with created context).

To switch contexts you can use kubectx or fzf (see instructions below). Once you have contexts created you will no longer need to use kubectx with kubens when accessing namespace in different cluster.

Installation and usage

Info: This plugin is not in krew-index but for convenience I added krew manifest as installlation option..

  1. Install plugin

    • using krew manifest in this repository
      $ kubectl krew install --manifest=deploy/krew/plugin.yaml
      

    or

    • using Makefile
      $ make bin
      
  2. Use plugin

    $ kubectl updatecontext
    

Use fzf to switch contexts

Add these lines into your .bashrc or .zshrc

#fzf inline alias
alias _inline_fzf="fzf --multi --ansi -i -1 --height=50% --reverse -0 --header-lines=1 --inline-info --border"

#kubernetes contexts switcher
kcs() {
    local context="$(kubectl config get-contexts | _inline_fzf | awk '{print $1}')"
    eval kubectl config set current-context "${context}"
}

Now use kcs within your terminal.

$ kcs

Directories

Path Synopsis
cmd
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL