Giter VIP home page Giter VIP logo

k8senv's Introduction

k8senv

Kubernetes client's version manager inspired by tfenv

Kubernetes clients supported at this moments are kubectl, or, helm, or, velero on Linux servers/machines.

Manytimes we need to manage many Kubernetes clusters from same jumpbox or machine or bastion server. Those many cluster may have different versions of Kubernetes. In that case, It becomes difficult to use multiple versions of Kubernetes clients to communicate with those different versions of clusters.

This small tool is to help manage different versions of Kubernetes clients. Kubernetes clients kubectl, helm and velero are supported at this stage.

How to install/setup

  1. Create a directory .k8senv/bin in home directory
mkdir -p ~/.k8senv/bin
  1. Download k8senv tool into .k8senv/bin directory

amd64 Intel or AMD 64-Bit CPU

Download latest k8senv tool:

cd ~/.k8senv/bin
curl -L https://github.com/navilg/k8senv/releases/latest/download/k8senv-linux-amd64 -o k8senv
chmod +x k8senv

Download specific version of k8senv. For e.g. To download version v1.0.2:

cd ~/.k8senv/bin
curl -L https://github.com/navilg/k8senv/releases/download/v1.0.2/k8senv-linux-amd64 -o k8senv
chmod +x k8senv

arm64 Arm-based 64-Bit CPU (i.e. in Raspberry Pi)

Download latest k8senv tool:

cd ~/.k8senv/bin
curl -L https://github.com/navilg/k8senv/releases/latest/download/k8senv-linux-arm64 -o k8senv
chmod +x k8senv

Download specific version of k8senv. For e.g. To download version v1.0.2:

cd ~/.k8senv/bin
curl -L https://github.com/navilg/k8senv/releases/download/v1.0.2/k8senv-linux-arm64 -o k8senv
chmod +x k8senv
  1. Add ~/.k8senv/bin directory to your PATH environment variable
export PATH="$HOME/.k8senv/bin:$PATH"
echo 'export PATH="$HOME/.k8senv/bin:$PATH"' >> ~/.bashrc
hash -r
which k8senv
# OR
type k8senv

Usage

k8senv [VERB] [CLIENT] [VERSION]

# [VERB] can be install, use, list or remove
# [CLIENT] can be kubectl, velero or helm
# [VERSION] can be any client's version in format v*.*.*

examples:
k8senv use kubectl v1.23.2
k8senv install velero v1.8.1

Examples:

Install a kubectl version

Any of below commands can be used to download 1.26.2 version of kubectl

k8senv install kubectl v1.26.2
k8senv install kubectl 1.26.2
k8senv kubectl install v1.26.2
k8senv install kubectl 1.26.2 --overwrite   # Installs even if it already exists
k8senv install kubectl latest               # Installs latest stable version of kubectl
k8s install kubectl v1.19.2 --timeout=300   # Install 1.19.2 with timeout of 300 seconds. Default timeout is 120 seconds.

List all installed version of kubectl

Any of below commandds can be used to list all kubectl client's version installed by k8senv.

k8senv list kubectl
k8senv kubectl list

Switch to a version of kubectl

Any of below commands can be used to switch kubectl version to 1.26.2. If version is not available, It will install it automatically.

k8senv use kubectl v1.26.2
k8senv use kubectl 1.26.2
k8senv kubectl use v1.26.2

If you were using system installed version of kubectl in same shell session, you will need to clear the cached path of the kubectl using below command.

hash -d kubectl

Unuse/Disable k8senv managed kubectl

Any of the below command can be used to unuse or disable k8senv managed kubectl without uninstalling it. This will reset the system to use system installed kubectl, if present.

k8senv unuse kubectl
k8senv kubectl unuse

To clear the cached k8senv path of kubectl, you will need to clear it using below command before you can use system installed version of the tool.

hash -d kubectl

Remove an existing version of kubectl

Any of below commands can be used to remove kubectl version 1.26.2.

k8senv remove kubectl v1.26.2
k8senv remove kubectl 1.26.2
k8senv kubectl remove v1.26.2

Similar command can be used to install, use, list and remove velero and helm clients.

For e.g.

k8senv install helm v3.10.2
k8senv remove velero 1.10.1

Demo

Demo

k8senv's People

Contributors

navilg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

thetechoddbug

k8senv's Issues

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.