Install CLI tools
- Summary
- This tutorial will show you the tools that are useful when using CSC cloud services from the command line.
- Internet
- https://pypi.org/project/python-openstackclient/ (openstack Python client)
https://mirror.openshift.com/pub/openshift-v4/clients/ocp/ (openshift oc command ver 4)
https://github.com/CSCfi/allas-cli-utils#installing-allas-cli-utils (allas-cli-utils)
flowchart LR
A(Open the terminal) --> OS
subgraph OS
B(Update the OS) --> C(Install the system wide software)
end
OS --> D(Create and activate Python virtual environment)
D --> venv
subgraph venv
E(Install Pouta and Pukki openstack tools) --> F(Download and install Rahti openshift tools)
F --> G(Install the rest of Allas tools)
end
venv --> H(Create and store the script for later use)
Prerequisites
- Reasonably modern version of Ubuntu and Python 3.
- RPM and DEB compatible script available here: CLI tools script
- Windows users: How to install Linux on Windows with WSL
- Administrative access (sudo) to the environment
Procedure
Info
These examples use a virtual machine created from cPouta's Ubuntu 22.04 image.
Open the terminal.
The first thing we need to do is make sure that the system is up-to-date.
Try out the following command and have a look at the print result:
By default the SSH client is installed.
Tip
If nothing is printed, run the following command: sudo apt-get install openssh-client -y
and then run the which ssh
command again.
Achievement unlocked! You can now access the Puhti environment from the command line.
Then install some tools that you will need later in the tutorial.
Let's create a virtual Python environment where we will install all the CSC cloud-related tools.
Each time you re-enter the virtual machine, you will need to activate the virtual Python environment with the source
command to use the cloud tools again.
$ python3 -m venv ~/csc-cloud-tools
$ source ~/csc-cloud-tools/bin/activate
(csc-cloud-tools) $ _
From now on, installed tools are isolated from the rest of the operating system in the csc-cloud-tools
virtual environment.
First, we update the pip package manager tool and then we install the OpenStack command line tool.
(csc-cloud-tools) $ pip3 install --upgrade pip
(csc-cloud-tools) $ pip3 install python-openstackclient
(csc-cloud-tools) $ _
Achievement unlocked! You can now command the cPouta environment from the command line.
Then we continue to add more tools to our system.
Achievement unlocked! You can now command the Pukki environment from the command line.
The next step is to download the oc
command. The current version of Rahti supports client version 4.15.
(csc-cloud-tools) $ wget https://mirror.openshift.com/pub/openshift-v4/clients/ocp/4.15.9/openshift-client-linux-4.15.9.tar.gz
(csc-cloud-tools) $ tar xf openshift-client-linux-4.15.9.tar.gz
(csc-cloud-tools) $ mv oc kubectl ~/csc-cloud-tools/bin/
(csc-cloud-tools) $ rm README.md openshift-client-linux-4.15.9.tar.gz
(csc-cloud-tools) $ _
Achievement unlocked! You can now command the Rahti environment from the command line.
Last but not least, we have to install the Allas tools.
(csc-cloud-tools) $ pip3 install crypt4gh
(csc-cloud-tools) $ pip3 install s3cmd
(csc-cloud-tools) $ sudo apt-get install python3-swiftclient rclone -y
(csc-cloud-tools) $ git clone https://github.com/CSCfi/allas-cli-utils
(csc-cloud-tools) $ mv allas-cli-utils/* ~/csc-cloud-tools/bin/
(csc-cloud-tools) $ rm -fr allas-cli-utils
(csc-cloud-tools) $ _
~/.config/rclone/rclone.conf
.
Achievement unlocked! You can now command the Allas environment from the command line.
That's it!
Now you can control CSC's cloud environments from the command line.
Of course, all commands can be executed in sequence. The script available here: CLI tools script will automatically perform the tasks listed above.
Tip
You can download the script to your local machine with curl
or wget
command.
Further Learning
Here are some suggestions for what to read next: