Continental Innovates with Rancher and Kubernetes
The Rancher CLI (Command Line Interface) is a unified tool that you can use to interact with Rancher. With this tool, you can operate Rancher using a command line rather than the GUI.
The binary can be downloaded directly from the UI. The link can be found in the right hand side of the footer in the UI. We have binaries for Windows, Mac, and Linux. You can also check the releases page for our CLI for direct downloads of the binary.
After you download the Rancher CLI, you need to make a few configurations. Rancher CLI requires:
Before you can use Rancher CLI to control your Rancher Server, you must authenticate using an API Bearer Token. Log in using the following command (replace <BEARER_TOKEN> and <SERVER_URL> with your information):
$ ./rancher login https://<SERVER_URL> --token <BEARER_TOKEN>
If Rancher Server uses a self-signed certificate, Rancher CLI prompts you to continue with the connection.
Before you can perform any commands, you must select a Rancher project to perform those commands against. To select a project to work on, use the command ./rancher context switch. When you enter this command, a list of available projects displays. Enter a number to choose your project.
./rancher context switch
Example: ./rancher context switch Output
User:rancher-cli-directory user$ ./rancher context switch
NUMBER CLUSTER NAME PROJECT ID PROJECT NAME
1 cluster-2 c-7q96s:p-h4tmb project-2
2 cluster-2 c-7q96s:project-j6z6d Default
3 cluster-1 c-lchzv:p-xbpdt project-1
4 cluster-1 c-lchzv:project-s2mch Default
Select a Project:
After you enter a number, the console displays a message that you’ve changed projects.
INFO Setting new context to project project-1
INFO Saving config to /Users/markbishop/.rancher/cli2.json
The following commands are available for use in Rancher CLI.
inspect [OPTIONS] [RESOURCEID RESOURCENAME]
Once logged into Rancher Server using the CLI, enter ./rancher --help for a list of commands.
All commands accept the --help flag, which documents each command’s usage.