ktx

English 简体中文

ktx is an easy-to-use command line tool for kubernetes multi-cluster context management.

demo

Installation

go install -u github.com/poneding/ktx@latest

For MacOS or Linux:

curl -sSL https://github.com/poneding/ktx/raw/master/install.sh | sh

For Windows:

Download the lastest executable from Releases and add it to the PATH.

Usage

usage

  1. Add cluster context
ktx add -f .kube/kind-cluster-01
ktx add -f .kube/kind-cluster-02
  1. List cluster contexts
ktx list

Alias: ktx ls

  1. Switch cluster context
# Switch contexts
ktx

# Switch to specified cluster context
ktx switch kind-cluster-01

# Interactive switch
ktx switch

Alias: ktx s

  1. Rename cluster context
# Rename specified cluster context
ktx rename kind-cluster-01

# Interactive rename
ktx rename
  1. Remove cluster context
# Remove specified cluster context
ktx remove kind-cluster-01

# Interactive remove
ktx remove

Alias: ktx rm

  1. Export cluster context
ktx export kind-cluster-01 -f .kube/export-01
  1. Generate kubeconfig from ServiceAccount
ktx generate --service-account default -f .kube/my-gen-config

Alias: ktx gen

  1. Set namespace
ktx set-namespace --namespace default
  1. Set Server address
ktx set-server --server https://api.k8s.local:6443