Banzai CLI is a command line interface under heavy development for the Banzai Cloud Pipeline platform.

In its current state it is most suitable for making it easier to access and manage existing resources on your Pipeline Platform, and to automate operations. Depending on your goals, environment, preferences, and level of experience, the banzai CLI can be used either instead of, or as a supplement to using the public APIs of the platform directly, with our client library, or the web interface.

Getting started

Installation

Use the following command to quickly install the CLI:

$ curl https://getpipeline.sh/cli | sh

The script automatically chooses the best distribution package for your platform.

Available packages:

You can also select the installation method (one of auto, deb, rpm, brew, tar or go) explicitly:

$ curl https://getpipeline.sh/cli | sh -s -- deb

On macOs, you can directly Homebrew:

$ brew install banzaicloud/tap/banzai-cli

Building from source manually

If you have a golang environment ready, you can also build the tool yourself using the command below. The command will take care of downloading the source of the banzai CLI and its dependencies, and building an executable. For example on a recent Ubuntu you can install a Go environment able to compile banzai CLI with sudo apt install golang git.

$ go get github.com/banzaicloud/banzai-cli/cmd/banzai

You will find the executable file under your $GOPATH/bin directory (~/go/bin by default). To use the command as banzai, you can either add the directory to your PATH, or install it globally with a command like this:

$ sudo install ${GOPATH:-~/go}/bin/banzai /usr/local/bin

Login

To use the command you will have to log in. You can either log in intaractively using a web browser, or provide an API endpoint and a token manually.

For interactive login, just run banzai login, and follow the instructions given.

$ banzai login
? Pipeline endpoint: https://beta.banzaicloud.io/pipeline
? Pipeline token: login with browser
INFO[0004] Opening web browser at http://localhost:5555
INFO[0012] successfully logged in
? Create permanent token? Yes
? Organization: banzaicloud

At the end you will be asked if you want to create a permanent token. This means that the temporary session token obtained by default is replaced with one that does not expire.

You will also be able to select an organization to login into.

Login with Pipeline token

You can obtain a Pipeline access token from the token field of the GET /api/v1/token API endpoint (for example https://beta.banzaicloud.io/pipeline/api/v1/token) in a logged in browser, or by a HTTP request with other means of authentication. See the authentication section for more details. You can use this token with a command like in the following example:

$ banzai login --endpoint=https://beta.banzaicloud.io/pipeline --token=${yourtoken}

Using kubectl on a Kubernetes cluster managed by Pipeline

The banzai CLI's cluster shell command starts a shell, or runs your specified program within the Kubernetes context of your cluster. You can either run the command without arguments to interactively select a cluster, and get an interactive shell, select the cluster with the --cluster-name flag, or specify the command to run.

$ banzai cluster shell
? Cluster: docs-example
INFO[0001] Running sh
[docs-example]$ helm list
NAME            REVISION    UPDATED                     STATUS      CHART                           APP VERSION NAMESPACE
dashboard       1           Wed Jan 16 12:42:15 2019    DEPLOYED    kubernetes-dashboard-0.8.0      1.10.0      pipeline-system
...
[docs-example]$ kubectl get nodes
NAME                                    STATUS   ROLES    AGE   VERSION
gke-docs-example-pool1-7a602b82-62w8    Ready    <none>   1h    v1.10.11-gke.1
gke-docs-example-system-a16f163c-dvwj   Ready    <none>   1h    v1.10.11-gke.1
[docs-example]$ exit
INFO[0026] Command exited successfully
$ banzai cluster shell --cluster-name docs-example kubectl get nodes
INFO[0000] Running kubectl kubectl get nodes
NAME                                    STATUS   ROLES    AGE   VERSION
gke-docs-example-pool1-7a602b82-62w8    Ready    <none>   43m   v1.10.11-gke.1
gke-docs-example-system-a16f163c-dvwj   Ready    <none>   43m   v1.10.11-gke.1
INFO[0001] Command exited successfully

Creating a cluster

If you have a create cluster request ready, you can simply pass it to the standard input of the banzai cluster create command. Alternatively you can answer the basic questions to prepare a query interactively. Please note that you will have to add the cloud provider specific properties manually in the current version.

Example:

$ banzai cluster create <<A
> {
>   "name": "docs-example",
>   "location": "us-central1-a",
>   "cloud": "google",
>   "secretName": "secret-name",
>   "properties": {
>     "gke": {
>       "master": {
>         "version": "1.10"
>       },
>       "nodePools": {
>         "pool1": {
>           "count": 1,
>           "instancetype": "n1-standard-1"
>         }
>       },
>       "nodeversion": "1.10"
>     }
>   }
> }
> A
INFO[0002] cluster is being created
INFO[0002] you can check its status with the command `banzai cluster get "docs-example"`
Id   Name
176  docs-example

See also