mirror of
https://github.com/rancher/rancher-docs.git
synced 2026-09-24 20:18:18 +00:00
editing Dan's CLI documentation
This commit is contained in:
@@ -3,27 +3,51 @@ title: Rancher CLI Configuration
|
||||
weight: 1
|
||||
---
|
||||
|
||||
The CLI needs an API token and the URL of your server in order to start using it. Instructions for creating the API token and getting your server URL can be found at TODOMARK: Add a link to the docs on how to create an API key for the user to use in the CLI login
|
||||
Rancher CLI (Command Line Interface) is a unified tool that you can use to manage Rancher Server. With this tool, you can operate Rancher using command line rather than GUI.
|
||||
|
||||
Begin using the CLI by running
|
||||
### Download Rancher CLI
|
||||
|
||||
You can download Rancher CLI from [GitHub](https://github.com/rancher/cli/releases). Download the version of Rancher CLI that corresponds with your version of Rancher Server.
|
||||
|
||||
>**Note:** Rancher CLI only works with its corresponding Rancher Server release. Rancher Server and Rancher CLI installations that don't share the same version are incompatible.
|
||||
|
||||
### Configuration Requirements
|
||||
|
||||
After you download Rancher CLI, you need to make a few configurations. Rancher CLI requires:
|
||||
|
||||
- Your [Rancher Server URL]({{< baseurl >}}/rancher/v2.x/en/tasks/global-configuration/server-url), which is used to connect to Rancher Server.
|
||||
- An [API token]({{< baseurl >}}/rancher/v2.x/en/tasks/user-settings/api-keys), which is used to authenticate with Rancher.
|
||||
|
||||
### Common Usage
|
||||
|
||||
Begin using Rancher CLI by logging into your Rancher Server. Log in using the following command (replace `<BEARER_TOKEN>` and `<SERVER_URL>` with your information):
|
||||
|
||||
```bash
|
||||
$ rancher login -t <token> <server_URL>
|
||||
$ ./rancher login https://<SERVER_URL> -t <BEARER_TOKEN>
|
||||
```
|
||||
|
||||
If the rancher server is using a self signed cert the CLI will ask for confirmation to continue connecting to the server.
|
||||
If Rancher Server uses a self-signed certificate, Rancher CLI prompts you to continue with the connection.
|
||||
|
||||
Once logged in run `rancher --help` for a list of commands
|
||||
Rancher CLI uses a _context_ to determine what resources to fetch when running commands. Context is another name for the cluster/project that's currently in focus.
|
||||
|
||||
All commands accept the `--help` flag to further describe the usage
|
||||
The `./rancher context switch` command displays a list of contexts available and allows the user to change contexts.
|
||||
|
||||
The CLI uses a context to determine what resources to fetch when running commands. A context is a cluster/project currently focused on.
|
||||
**Other Common Commands:**
|
||||
|
||||
`rancher context switch` displays a list of available contexts and allows user selection to change to context
|
||||
* `rancher ps`
|
||||
|
||||
Lists workloads in the current context.
|
||||
|
||||
Common Commands:
|
||||
* `rancher clusters`
|
||||
|
||||
Lists all clusters in the current context.
|
||||
|
||||
* `rancher ps` to show workloads in the current Context
|
||||
* `rancher clusters` to view all clusters
|
||||
* `rancher kubectl` runs kubectl commands against the cluster
|
||||
(requires kubectl to be installed but CLI will pull the kubeconfig)
|
||||
* `rancher kubectl`
|
||||
|
||||
Runs `kubectl` commands against the cluster. This command requires `kubectl` to be installed. However Rancher, CLI will pull the kubeconfig.
|
||||
|
||||
### Rancher CLI Help
|
||||
|
||||
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.
|
||||
Reference in New Issue
Block a user