Giter Club home page Giter Club logo

kubectl-karbon's Introduction

kubectl-karbon - Quickly connect to your Karbon cluster!

This kubectl extension allows to quickly connect to an existing karbon cluster without the need to connect to Prism UI. It uses the Karbon API to get kubeconfig file and install it on your local system. The kubectl extension can be used on Linux, MacOS and Windows.

Demo

kubectl-karbon.mp4

Go Report Card Maintainability CI Release

release License Proudly written in Golang Releases


Installation

See the table below for all kubectl-karbon installation methods:

Installation method Operating systems
Kubectl Krew Plugins Linux, MacOS, Windows
Homebrew or Linuxbrew package Linux, MacOS
Manual Linux, MacOS, Windows

After installing, the tools will be available as kubectl karbon.

Kubectl Plugins

You can install and use Krew kubectl plugin manager to get the karbon plugin .

kubectl krew install karbon

Keep up-to-date with kubectl krew upgrade karbon (or kubectl krew upgrade to upgrade everything)

Homebrew Package

You can install with Homebrew for macOS or LinuxBrew for Linux

brew install nutanix/tap/kubectl-karbon

Keep up-to-date with brew upgrade kubectl-karbon (or brew upgrade to upgrade everything)

Manual

  • Download your corresponding release
  • Install the binary somewhere in your PATH (for example /usr/local/bin or Windows equivalent)
  • use it with kubectl karbon

MacOS X notes for security error

Depending of your OS settings when you install you binary manually we must launch the following command: xattr -r -d com.apple.quarantine /usr/local/bin/kubectl-karbon

Usage

  • kubectl karbon help Help about any command
  • kubectl karbon list Get the list of k8s clusters
  • kubectl karbon login Authenticate user with Nutanix Prism Central, create kubeconfig file, get ssh key/cert, ...
  • kubectl karbon logout Remove kubeconfig file, remove ssh key/cert file, clean ssh-agent ...
  • kubectl karbon version Print the version of the plugin

Config file

You can specify a config file to define your seetings. The default is $HOME/.kubectl-karbon.yaml and you can use another one with the --config flag.

server: servername
port: 9440
cluster: karbon_cluster_name
user: admin
insecure: true
verbose: false
force: false
merge: false
kubie: false
keyring: false
#ssh-agent: false
#ssh-file: false
#kubie-path: ~/.kube/.kubie/
#kubeconfig: /path/.kube/config

config file example

All entries are optional, you can define only what you need to enforce.

Env variables

you can also use the following environement variable

KARBON_SERVER
KARBON_PORT
KARBON_CLUSTER
KARBON_USER
KARBON_INSECURE
KARBON_VERBOSE
KARBON_FORCE
KARBON_MERGE
KARBON_PASSWORD
KARBON_KUBIE
KARBON_KUBIE_PATH
KARBON_SSH_AGENT
KARBON_SSH_FILE
KARBON_KEYRING KUBECONFIG

precedence is

FLAGS => ENV => CONFIG FILE => DEFAULT

File overwrite

You can use the --force option to overwrite any existing file(s) like kubeconfig or ssh key/cert.

Password

By default this tools never stored the password.
You can use the KARBON_PASSWORD env variable.
You can also use the --keyring option to save and retrieve your password from the system keyring. It supports OS X, Linux/BSD (dbus) and Windows.
In all other cases password should be provided in an interactive way.

SSH option

During login, allow SSH key and cert retrieval.
The key and cert can be added to the running ssh-agent (--ssh-agent) or saved in file inside the ~/.ssh/ directory (--ssh-file).

Kubie mode

Allows full integration with Kube or Kubie who have support for split configuration files, meaning it can load Kubernetes contexts from multiple files.
When this mode is active (--kubie) each kubeconfig file is stored as an independent file in the kubie-path directoy (default ~/.kube/kubie/cluster_name.yaml)

Merge Feature

The merge feature allows you to add a new context to an existing kubeconfig file instead of overwriting it. This is useful when you have multiple Kubernetes clusters and want to manage them using the same kubeconfig file.

Usage

To use the merge feature, simply pass the --merge flag when running the login command:

kubectl-karbon login --username <username> --password <password> --merge

Building From Source

kubectl-karbon is currently using go v1.16 or above. In order to build kubectl-karbon from source you must:

  1. Clone the repo

  2. Build and run the executable

    make build && make install

kubectl-karbon's People

Contributors

dependabot[bot] avatar fabricekrebs avatar tkelkermans avatar tuxtof avatar yannickstruyf3 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kubectl-karbon's Issues

karbon plugin completely over writes ~/.kube/config by default

As a default overwriting ~/.kube/config is not a safe way to do things.
I lost all my saved config and clusters that I was running out of there.

At the very least warn people and give them a chance to backup the configs before completing the login.

kubectl karbon login
this is destructive and will overwrite your ~/.kube/config

Example of what happens on the default config and installation.

kubectl config get-contexts
CURRENT   NAME                                                   CLUSTER                                                AUTHINFO                                               NAMESPACE
          arn:aws:eks:ClustA                            arn:aws:eks:CLustA                                          arn:aws:eks:ClustA
*         clustB-prod-context                                   clustB-prod                                default-user-clustB-prod                   registry
          clustC-prod                                        clustC-prod                                        kube-admin-clustC-prod
          clustD-prod                                        clustD-prod                                        kube-admin-clustD-prod

kubectl karbon login
Enter [email protected] password:
Logged successfully into clustB-prod cluster

kubectl get nodes
NAME                                                 STATUS   ROLES    AGE   VERSION
karbon-clustB-prod-2d7780-k8s-master-0   Ready    master   8d    v1.20.9
karbon-clustB-prod-2d7780-k8s-master-1   Ready    master   8d    v1.20.9
karbon-clustB-prod-2d7780-k8s-worker-0   Ready    node     8d    v1.20.9
karbon-clustB-prod-2d7780-k8s-worker-1   Ready    node     8d    v1.20.9
karbon-clustB-prod-2d7780-k8s-worker-2   Ready    node     8d    v1.20.9
karbon-clustB-prod-2d7780-k8s-worker-3   Ready    node     8d    v1.20.9
karbon-clustB-prod-2d7780-k8s-worker-4   Ready    node     8d    v1.20.9

kubectl config get-contexts
CURRENT   NAME                              CLUSTER                   AUTHINFO                               NAMESPACE
*         clustB-prod-context   clustB-prod   default-user-clustB-prod

I get you have a Kubie tool integration whatever that means.
You shouldn't overwrite the whole config file to update the user token and cluster details.
Or you should put the config file into a location that is not part of the standard ~/.kube/config that is the default used
by other applications.
kubectl operation and functions should not change because of how you handle the ~/.kube/config file.
Update the cluster-specific details in the kube/config file or leave it alone. never overwrite the whole file.

The defaults in the ~/.kubectl-karbon.yaml file should prevent the ~/.kube/config file being changed in an irreversible way.

 cat ~/.kubectl-karbon.yaml
# karbon config
# https://github.com/nutanix/kubectl-karbon

kubie: true
kubeconfig: ~/.kube/karbon/config
# or
kubeconfig: ~/.kube/kubie/config.karbon.yml

This makes more sense in place of overwriting the defaults

Using context functionality of kubectl

Hi,

Would it be possible to use the context functionality of kubectl with this plugin ?
For example :

  1. Use kubectl Karbon login --server prism-central-address -u
  2. Automatically creates context so that we can switch between the different NKE clusters that have been deployed
    kubectl config use-context nke-01
    kubectl config use-context nke-02

I think it would help instead of overwriting or changing the kubeconfig file every time ?

Thanks

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.