Contained in this docker image:
- rancher-cli
- rancher-compose cli (no maintain by RancherLabs)
- A Python CLI tool for Rancher's API rancher.py
- Add rancher cli and rancher-compose cli into this docker images, so you needn't reinvent the wheel.
- Support rancher environments, because duplicate service or stack names are possible across rancher environments
- New commands for health check and blue-green deployment (still working on)
alias rancher-cli="docker run --rm -it -e RANCHER_URL=$RANCHER_URL -e RANCHER_SECRET_KEY=$RANCHER_SECRET_KEY -e RANCHER_ACCESS_KEY=$RANCHER_ACCESS_KEY -e RANCHER_ENVIRONMENT=dev alpine/rancher-cli:1.0"
If you work environment behinds corporate proxy,
alias rancher-cli="docker run --rm -it -e RANCHER_URL=$RANCHER_URL -e RANCHER_SECRET_KEY=$RANCHER_SECRET_KEY -e RANCHER_ACCESS_KEY=$RANCHER_ACCESS_KEY -e RANCHER_ENVIRONMENT=dev -e http_proxy="http://192.168.65.2:3128" -e https_proxy="http://192.168.65.2:3218" alpine/rancher-cli:1.0"
Make sure you have set the alias.
rancher-cli rancher --help
Make sure you have set the alias.
rancher-cli rancher-compose --help
rancher.py
is simply some Python scripts to access the
Rancher's API to perform tasks which
I need to have executed through my deployment workflow.
At this point, it does not contain much but it might grow as I get more requirements.
Contributions are welcome if you want to use it and add to it.
rancher.py
can be run directly on a command line provided you have Python installed
as well as the dependencies listed below.
pip install -r requirements.txt
./rancher.py query
It can also be run as a Docker container:
Make sure you have set the alias.
rancher-cli rancher.py query 1s245
Gaucho needs to know the Rancher host and must be given an access key and access secret to be able to interact with the Rancher's API. This can be done through environment variables:
RANCHER_ACCESS_KEY
RANCHER_SECRET_KEY
RANCHER_URL
RANCHER_ENVIRONMENT
If you want to turn off SSL validation because you are using a self-signed certificate or a private CA-signed certificate, you can pass the environment variable:
- `SSL_VERIFY=false`
You can also mount the SSL certificate chain into the container, and pass the path to the certificate as an environment variable:
-v /path/to/ca_chain.crt:/root/ca.crt
-e SSL_VERIFY=/root/ca.crt
If you run Gaucho in a container on Rancher, rather than set the environment variables manually, use the following labels to have Rancher automatically do it for you.
io.rancher.container.create_agent=true
io.rancher.container.agent.role=environment
See Service Accounts in Rancher for more information on this feature.
Usage: ./services.py query [<service_id>]
Retrieves the service information.
If you don't specify an ID, data for all services will be retrieved.
Options:
--service_id The ID of the service to read (optional)
Retrieves the stack ID of a stack given its name.
$ ./rancher.py stack_id project1
1s97
Retrieves the ID of a service given its name, need stack name with it.
$ ./rancher.py service_id stack_name/cassandra
1s130
Retrieves the ID of a service given its name, need stack name with it
$ ./rancher.py service_health stack_name/cassandra
healthy
Usage: ./rancher.py env_id dev
Retrieves the ID of a environment given its name.
Required Arguments:
environment_name The name of the environment
Usage: ./gaucho start_service <service_id>
Starts the containers of a given service, typically a Start Once service.
Required Arguments:
service_id The ID of the service to start the containers of.
Usage: ./gaucho stop_service <service_id>
Stop the containers of a given service.
Required Arguments:
service_id The ID of the service to stop the containers of.
Usage: ./gaucho restart_service <service_id>
Restart the containers of a given service.
Required Arguments:
service_id The ID of the service to restart the containers of.
Usage: ./services.py upgrade <service_id> [<start_first>] [<complete_previous>] [<imageUuid>] [<auto_complete>] [<batch_size>] [<interval_millis>] [<replace_env_name>] [<replace_env_value>]
Upgrades a service
Performs a service upgrade, keeping the same configuration, but
otherwise pulling new image as needed and starting new containers,
dropping the old ones.
Required Arguments:
service_id The ID of the service to upgrade.
Options:
--start_first Whether or not to start the new instance first before
stopping the old one.
--complete_previous If set and the service was previously upgraded but the
upgrade wasn't completed, it will be first marked as
Finished and then the upgrade will occur.
--imageUuid If set the config will be overwritten to use new
image. Don't forget Rancher Formatting
'docker:<Imagename>:tag'
--auto_complete Set this to automatically 'finish upgrade' once
upgrade is complete
--batch_size
--interval_millis
--replace_env_name The name of an environment variable to be changed in
the launch config (requires replace_env_value).
--replace_env_value The value of the environment variable to be replaced
(requires replace_env_name).
--timeout How many seconds to wait until an upgrade fails
Usage: ./services.py rollback <service_id>
Rolls back service
Performs a service rollback
Required Arguments:
service_id The ID of the service to roll back.
Options:
--timeout How many seconds to wait until an upgrade fails
Usage: ./gaucho execute <service_id> <command>
Runs the given *command* on the first container found for the given *service id*.
Required Arguments:
service_id The ID of the service to perform the command on.
command shell command to execute
Usage: ./gaucho activate <service_id>
Activate the given *service id*.
Required Arguments:
service_id The ID of the service to perform the command on.
Options:
--timeout How many seconds to wait until get back prompt on activation
Usage: ./gaucho deactivate <service_id>
Deactivate the given *service id*.
Required Arguments:
service_id The ID of the service to perform the command on.
Options:
--timeout How many seconds to wait until get back prompt on deactivation
Usage: ./gaucho remove <service_id>
Remove the given *service id*.
Required Arguments:
service_id The ID of the service to perform the command on.
Options:
--timeout How many seconds to wait until get back prompt on remove
Usage: ./gaucho deactivate_env <environment_id>
Deactivate the given *environment id*.
Required Arguments:
environment_id The ID of the environment to perform the command on.
Options:
--timeout How many seconds to wait until get back prompt on deactivation
Usage: ./gaucho remove_env <environment_id>
Remove the given *environment id*.
Required Arguments:
environment_id The ID of the environment to perform the command on.
Options:
--timeout How many seconds to wait until get back prompt on remove
Usage: ./gaucho state <service_id>
Print state of the given *service id*.
Required Arguments:
service_id The ID of the service to check.
- requests==2.18.4
- baker==1.3
- websocket-client==0.44.0