Installing the Replicated CLI
Vendors can use the Replicated CLI to manage their applications with Replicated programmatically, rather than using the Replicated vendor portal.
Prerequisites
Complete the following prerequisites before installing the Replicated CLI:
- Create a vendor account. See Creating a Vendor Account.
- To run on Linux or Mac, install curl.
- To run through a Docker container, install docker.
Install and Run
You can install and run the Replicated CLI in the following environments:
- Directly on MacOS
- Directly on Linux
- Through Docker (Useful for Windows, GitHub Actions, or computers without sufficient access)
MacOS
To install and run the latest Replicated CLI on MacOS:
-
Run one of the following commands:
-
With Brew:
brew install replicatedhq/replicated/cli
-
Without Brew:
curl -s https://api.github.com/repos/replicatedhq/replicated/releases/latest \
| grep "browser_download_url.*darwin_all.tar.gz" \
| cut -d : -f 2,3 \
| tr -d \" \
| wget -O replicated.tar.gz -qi -
tar xf replicated.tar.gz replicated && rm replicated.tar.gz
mv replicated /usr/local/bin/replicatednoteIf you do not have root access to the
/usr/local/bin
directory, you can install with sudo by runningsudo mv replicated /usr/local/bin/replicated
instead ofmv replicated /usr/local/bin/replicated
.
-
-
Verify that the installation was successful:
replicated --help
-
Authorize the Replicated CLI:
replicated login
In the browser window that opens, complete the prompts to log in to your vendor account and authorize the CLI.
View a larger version of this image
noteThe
replicated login
command creates a token after you log in to your vendor account in a browser and saves it to a config file. Alteratively, if you do not have access to a browser, you can set theREPLICATED_API_TOKEN
environment variable to authenticate. For more information, see (Optional) Set Environment Variables below. -
(Optional) When you are done using the Replicated CLI, remove any stored credentials created by the
replicated login
command:replicated logout
Linux
To install and run the latest Replicated CLI on Linux:
-
Run the following command:
curl -s https://api.github.com/repos/replicatedhq/replicated/releases/latest \
| grep "browser_download_url.*linux_amd64.tar.gz" \
| cut -d : -f 2,3 \
| tr -d \" \
| wget -O replicated.tar.gz -qi -
tar xf replicated.tar.gz replicated && rm replicated.tar.gz
mv replicated /usr/local/bin/replicatednoteIf you do not have root access to the
/usr/local/bin
directory, you can install with sudo by runningsudo mv replicated /usr/local/bin/replicated
instead ofmv replicated /usr/local/bin/replicated
. -
Verify that the installation was successful:
replicated --help
-
Authorize the Replicated CLI:
replicated login
In the browser window that opens, complete the prompts to log in to your vendor account and authorize the CLI.
View a larger version of this image
noteThe
replicated login
command creates a token after you log in to your vendor account in a browser and saves it to a config file. Alteratively, if you do not have access to a browser, you can set theREPLICATED_API_TOKEN
environment variable to authenticate. For more information, see (Optional) Set Environment Variables below. -
(Optional) When you are done using the Replicated CLI, remove any stored credentials created by the
replicated login
command:replicated logout
Docker / Windows
Installing in Docker environments requires that you set the REPLICATED_API_TOKEN
environment variable to authorize the Replicated CLI with an API token. For more information, see (Optional) Set Environment Variables below.
To install and run the latest Replicated CLI in Docker environments:
-
Generate a service account or user API token in the vendor portal. To create new releases, the token must have
Read/Write
access. See Generating API Tokens. -
Get the latest Replicated CLI installation files from the replicatedhq/replicated repository on GitHub.
Download and install the files. For simplicity, the usage in the next step is represented assuming that the CLI is downloaded and installed to the desktop.
-
Authorize the Replicated CLI:
-
Through a Docker container:
docker run \
-e REPLICATED_API_TOKEN=$TOKEN \
replicated/vendor-cli --helpReplace
TOKEN
with your API token. -
On Windows:
docker.exe run \
-e REPLICATED_API_TOKEN=%TOKEN% \
replicated/vendor-cli --helpReplace
TOKEN
with your API token.
-
For more information about the docker run
command, see docker run in the Docker documentation.
(Optional) Set Environment Variables
The Replicated CLI supports setting the following environment variables:
-
REPLICATED_API_TOKEN
: A service account or user API token generated from a vendor portal team or individual account. TheREPLICATED_API_TOKEN
environment variable has the following use cases:-
To use Replicated CLI commands as part of automation (such as from continuous integration and continuous delivery pipelines), authenticate by providing the
REPLICATED_API_TOKEN
environment variable. -
To authorize the Replicated CLI when installing and running the CLI in Docker containers.
-
Optionally set the
REPLICATED_API_TOKEN
environment variable instead of using thereplicated login
command to authorize the Replicated CLI in MacOS or Linux environments.
-
-
REPLICATED_APP
: The slug of the target application.When using the Replicated CLI to manage applications through your vendor account (including channels, releases, customers, or other objects associated with an application), you can set the
REPLICATED_APP
environment variable to avoid passing the application slug with each command.
REPLICATED_API_TOKEN
To set the REPLICATED_API_TOKEN
environment variable:
-
Generate a service account or user API token in the vendor portal. To create new releases, the token must have
Read/Write
access. See Generating API Tokens. -
Set the environment variable, replacing
TOKEN
with the token you generated in the previous step:-
MacOs or Linux:
export REPLICATED_API_TOKEN=TOKEN
-
Docker:
docker run \
-e REPLICATED_API_TOKEN=$TOKEN \
replicated/vendor-cli --help -
Windows:
docker.exe run \
-e REPLICATED_API_TOKEN=%TOKEN% \
replicated/vendor-cli --help
-
REPLICATED_APP
To set the REPLICATED_APP
environment variable:
-
In the vendor portal, go to the Application Settings page and copy the slug for the target application. For more information, see Get the Application Slug in Managing Application.
-
Set the environment variable, replacing
APP_SLUG
with the slug for the target application that you retreived in the previous step:-
MacOs or Linux:
export REPLICATED_APP=APP_SLUG
-
Docker:
docker run \
-e REPLICATED_APP=$APP_SLUG
replicated/vendor-cli --help -
Windows:
docker.exe run \
-e REPLICATED_APP=%APP_SLUG% \
replicated/vendor-cli --help
-