A command-line utility for managing Tango Docker images for Autolab.
Written in Python 3.8 to maintain compatibility with older versions of Ubuntu.
- Build Docker images from a Dockerfile and tag them properly for uploading to Docker Hub
- Deploy images from Docker Hub to all Tango servers in the cluster
- Build, upload, and deploy with one command!
- Clone this repo to the Autolab server or your local machine:
git clone https://github.com/NicholasMy/tangoctl.git
- Cd into the project:
cd tangoctl
- Create a virtual environment:
python3 -m venv venv
- Activate the virtual environment:
source venv/bin/activate
- Install the requirements:
pip install -r requirements.txt
- Optionally, "install" this tool with
sudo bash install.sh
from thetangoctl
directory.- This will allow you to run
tangoctl
from anywhere by dynamically generatingtangoctl_installed.py
using the venv's executable path and creating a symlink in /usr/local/bin.
- This will allow you to run
- Ensure the permissions are correct:
sudo chmod 755 tangoctl.py
. The install script does this automatically.
- Copy the template config file to create your own within the project directory:
cp config.yaml.template config.yaml
docker_hub_org
is the Docker Hub organization to use when building and uploading imagesssh_key_path
is the path to the SSH key to use when deploying imagesssh_username
is the username to use when deploying imagestango_nodes
is a list of Tango nodes to deploy to. Each node must includefqdn
, the fully-qualified domain name, and can optionally includessh_key_path
andssh_username
as per-node overrides.
In general, commands are formatted as:
tangoctl [config_overrides] <command> <options...>
Arguments in [square brackets] are optional. Arguments in <angle brackets> are required.
Run tangoctl [command] -h
to see a list of commands and options.
All of these are optional. If not provided, the values in the configuration file will be used. Due to the way Python's argparse library works, these must be provided before the command.
--org
- Override the configuration's Docker Hub organization--ssh-key-path
- Override the configuration's default SSH key path--ssh-username
- Override the configuration's default SSH username
E.g., tangoctl --org myorg --ssh-username myuser deploy ...
tangoctl [config_overrides] build <dockerfile> <image_name>
Builds a Docker image from a Dockerfile (local or URL) locally, and properly tags it with a datestamp and latest tag.
dockerfile
is the path to a directory containing a Dockerfile OR a URL to a Dockerfileimage_name
is the name of the image to build and deploy, without an org or tag, e.g.cse_116
This is not provided as a standalone command by Tangoctl because it's already provided by Docker.
Use docker push <image_name>
to upload an image to Docker Hub. image_name
should include an org and a tag. You'll
need to be logged in.
If you use the All-in-one (AIO) command, this action will be performed automatically.
tangoctl [config_overrides] deploy <image_name> <tango_node(s)>
Download an image from Docker Hub and deploy it to the specified Tango node(s). This will handle removing the org for cleanliness on Autolab.
image_name
is the name of the image to deploy, including an org and a tag.tango_node(s)
can be one or more Tango nodes, separated by commas, or 'all'. These are configured in the config file.
tangoctl [config_overrides] aio <dockerfile> <image_name>
Build, upload, and deploy an image in one command!
This builds a Docker image locally, uploads the image to Docker Hub, and deploys it to all Tango nodes in the cluster.
Just like build
:
dockerfile
is the path to a directory containing a Dockerfile OR a URL to a Dockerfileimage_name
is the name of the image to build and deploy, without an org or tag, e.g.cse_116
Because this pushes to Docker Hub, it requires being logged in. Use docker login
and docker logout
to manage your
authentication.
tangoctl [config_overrides] images
Display which Docker images are installed on each Tango node.
tangoctl [config_overrides] volumes
Display the contents of the Tango volumes directory on each Tango node.