This feature series will focus on the Cloud 66 Toolbelt and is organized into three parts: for beginners, intermediate and advanced level users. This is part three.
In the preceding post of this series, I included a set of command lines that will help you get more confident with using Toolbelt commands in your terminal. I also pointed readers to the Toolbelt visualization page, which mimics how our Toolbelt commands work to give you a better understanding of what happens behind the scenes. This post will focus on advanced command lines to help you move from 'karate kid' to becoming 'Mr. Miyagi'.
#1 Login to the Cloud 66 UI from your terminal
For security reasons, the Cloud 66 Toolbelt uses OAuth 2 to authenticate and authorize access to your Cloud 66 account from your terminal window. With access granted, you can use all our
cx command lines like create, delete, scale and deploy your stacks and more.
Once Cloud 66 Toolbelt is authorized on your computer, use a
$ cx login command line to open up a browser and login to your account. You will be able to login without entering your password or 2fa.
NOTE: for Team Accounts
In a scenario where there is more than one user assigned to one account, the account owner can control who on the team can use the Toolbelt to login to the account. You can configure the permissions on the Teams page.
Check out our help page for more details.
#2 (Slave) Database management
There are two simple command lines that allow you to configure the slave database server, that you've replicated.
- Promote Slave to standalone master
Pre using this command the slave server must have been replicated and configured via Cloud 66 UI. Once that is done you can promote your slave database server to become a master.
$ cx databases promote-slave -s "My Awesome App" my_slave_server_name
- Slave re-synchronizes with master
There are many reasons why your master and slave database server will get out of sync, such as Database size, frequency of change, networking between servers to name a few. In these cases the
resyn-slave command is helpful.
$ cx databases resync-slave -s My_Awesome_App my_slave_server_name
For more information on database management, parameters, and downtime details visit our help page.
#3 Lease ports
This command line is very useful when you need to open a port on your server firewall to allow temporary access from a specific IP address.
You can achieve that from your terminal via our toolbelt, for example:
$ cx lease -s "My Awesome App" -f 22.214.171.124 -t 30 -e production
Check out our help page on Stack network settings for more info on fine-grained access control.
#4 Service management with toolbelt
Toolbelt allows you to easily manage your services from the comfort of your terminal window, with just a few simple command lines.
- Starting from listing your services.
$ cx services list command line, you'll be able to list all the services on the given stack, including the number of running containers in case of the Docker stack.
$ cx services list -s My_Awesome_App --server my_selected_server
You can also choose to create a list of services running on the particular server.
- Scalling services
You can scale up or down the services on the given server by specifying the number of container services you'd like to run on the server.
For example, if you're already running 2 servers and would like to scale up another 3 servers, you'd specify
$ cx services scale -s mystack my_web_service 5
Alternatively, you could specify +3 servers/containers to achieve the same results (5 services/containers running)
$ cx services scale -s mystack my_web_service +3
It works the same way if you want to scale the services down.
In the scenario when you have 5 servers running and need only 2 to be active, you can use the following command lines:
$ cx services scale -s mystack my_web_service 2
$ cx services scale -s mystack my_web_service -3
By specifying the +/- in front of the number, you'll add or remove the exact number of services. And when you specify a number without +/- it will act as an absolute value of services.
- Stopping and Restarting services
You can use
$ cx service stop and
$ cx service restart command lines to stop and restart your backend or web services. To do this, you'll have to include your stack and the service name in the command line and optionally a server name.
$ cx services stop -s mystack a_backend_service
$ cx services restart -s mystack a_backend_service
Read more about service management commands and required parameters on our help page
#5 Gateway management
With the Toolbelt command line, you're able to manage gateways on your account.
Start with the
gateways list command to pull up the list with all gateways belonging to your account. To receive detailed information about your gateways add
verbose to the command.
$ cx --org My_Awesome_org gateways list --verbose
Next, if needed you can add the gateway to your account.
$ cx --org My_Awesome_org gateways add --name aws_bastion --address 126.96.36.199 --username ec2-user --private-ip 188.8.131.52
Once that's done, you can open the gateway and make it available to use with Cloud 66 for (
ttl - time to leave) amount of time.
$ cx --org My_Awesome_org gateways open --name aws_bastion --key /tmp/gateway.pem --ttl 45m
After you've done all the necessary changes you can close the gateway. All gateway keys will be invalidated, which means they won't be available for Cloud 66 usage.
$ cx --org My_Awesome_org gateways close --name aws_bastion
Lastly, you can remove the gateway with the following command:
$ cx --org My_Awesome_org gateways remove --name aws_bastion
Read more about 'Automatic Deployment through a Bastion (gateway) Serve' on our blog post. Also check the help page for more details on gateway management.
Now, you can call yourself 'Mr. Miyagi' and comfortably use our cx commands in the comfort of your terminal window. If you're a Docker user, next week I'll be writing a short follow up with some of the specific advanced commands that are useful when using containers.