This repository has been archived by the owner on Aug 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
05 Use Rancher CLI
satrapu edited this page Oct 14, 2017
·
7 revisions
This page details how to use Rancher CLI against a running instance of Rancher server to perform CRUD tasks against its resources (e.g. environments, stacks,etc.).
This tool can be used to automate things, so that they may be invoked by a CI server like Jenkins.
More information can be found here and here.
Make sure you visit the examples too:
- Go to Rancher UI
- Go to menu → API → Keys
- Click the Add Environment button and give the API key a meaningful name
- Click the Create button and save the Access Key and Secret Key in a safe place for future references
- Go to the bottom right link "Download CLI" and click the appropriate Rancher CLI download link
- Unzip the downloaded file (rancher-windows-386-v0.6.3.zip) somewhere on your machine
- Create a new Rancher environment
# Rancher environment is passed via --env <ENVIRONMENT_ID> .\rancher.exe --url http://192.168.99.101:8080 --access-key F830A6D384AF8C497D19 --secret-key NERNbgVkmVhpHEfNyMRtDd9avbQzJePkJx1dLxg7 env create newEnvironment # This command will fail with the following error message: # FATA[0000] Resource type [project] is not creatable # This happens since we're using an environment API key which grants access only to the resources of a specific environment. # In order to create a new environment, we need to use an Account API Key!
- Go to menu, API → Keys and click the Add Account API Key
- Give the key a meaningful name and description and click the Create button
- Click the Create button and save the Access Key and Secret Key in a safe place for future references
- Re-run the command used for creating an environment and the result (the id of the newly created Rancher environment) should be printed inside the current terminal
.\rancher.exe --url http://192.168.99.101:8080 --access-key 80805BE0AC79342F72C6 --secret-key PJygtZyy6RGcaBhKAF3cMmcU6dKMLFYfmYzvKq2S env create newEnvironment # 1a28
- As an exercise, use Rancher CLI commands for creating some of the Rancher objects you have previously created via Rancher UI