In database terminology primary key refers to the column in a table that's intended to be the primary way of identifying rows. Each table must have exactly one, and it needs to be unique. This is usually some kind of a unique identifier associated with objects presented by the table, or if such an identifier doesn't exist simply a running ID number (which is incremented automatically).
Using Course Resources in CSC Cloud¶
This page contains necessary information and RULES regarding the user of CSC's computing resources that have been reserved for this course. You need to use these resources in some of the exercises, and they are also one deployment option for your project. Please read the instructions and rules very carefully.
Services Available¶
Here is a brief listing of the services that are available for use.
- My CSC - Overall management of your CSC account.
- cPouta - Infrastructure as a Service (IaaS) platform where you can set up full-fledged virtual machines. Used as an option in exercise 3.
- Rahti - Container cloud for deploying applications in containers. Container orchestration is done with OpenShift (enterprise version of Kubernetes). Used as an option in exercise 3.
- Pukki - DataBase as a Service platform (DBaaS) where we have set up two PostgreSQL instances that you can use for exercise 3 and your projects.
Getting Access¶
We have sent you the invitation link to join the project in CSC. The link has been sent via a Lovelace message. Only one member in each group needs to apply for membership in the CSC project.
Please be aware that we do not get a notification from CSC when someone applies for membership in the project. We will check the membership applications on weekdays, once per day. Once your application has been approved, you will receive notification emails from CSC about services that have been made available to you.
Rules of Use¶
On this course we are using shared resources that are limited, and also ultimately paid from taxpayer money. It is important that we treat these resources with respect, and also make sure everyone in the course has the ability to use them. For this purpose we have laid out some simple rules that everyone must adhere to.
Failure to follow these rules will give your group a warning for the first infraction. The second infraction will get you banned from the project. This means that you may also lose points for exercise 3 as you cannot complete it without using the cloud environment, and your group will have to set up your own platform in order to get full points for project deployment related categories.
- Do not tamper with course infrastructure
- Infrastructure used for some exercises is in the same cloud, you are not allowed to manage these in any way.
- Unlike the other rules, breaking this one will get you instantly banned without warning.
- Make a reservation for one of the floating IPs before doing anything.
- Assigning floating IP to your VM without a reservation is an offense, even if no one else has a reservation at the time.
- If someone re-assigns your floating IP while you are using it, it notify course staff and include the time when it happened.
- Always use minimum amount of resources.
- When creating VMs, use the tiny image flavor.
- In Rahti set reasonable resource limits, and do not create large persistent volume claims, a few MB is sufficient.
- Always use your group name for all of your resource reservations, and always use consistent spelling for it.
- If we spot resources without clear group indication in the name, they will be deleted on sight.
- Do not leave VMs or containers running. When your floating IP reservation ends, make sure to release the resources for other groups.
- In cPouta, either create a snapshot or delete your VM after use.
- In Rahti, scale your replicas to 0 or delete your deployment.
- Do not create new database instances in Pukki
- We have created two instances where you can create databases, there is no reason to create new ones.
- Do not attempt to use other groups' VMs or containers in your exercise task submissions.
Managing VMs in cPouta¶
As the expectation is that you will use Linux and be able to deploy your application on a server, we are providing you with the option to use a virtual machine in the cPouta cloud. These instructions will tell you how to set one up and how to connect to it. The instructions will use command line tools, specifically OpenStack, which you can install in a Python virtual environment. It is recommended that you create a separate virtual env for this purpose. Once you have it created and activated, install the tools with
python -m pip install python-openstackclient python-troveclient
You also need to obtain an openrc file from cPouta in order to log your terminal session. Go to Pouta dashboard and download the file from the top right user menu. Note: the file is tied to a project, so if you have multiple projects, make sure you have the correct one active.
Put the file into a suitable location, like the bin folder in your virtual environment, and then source it similarly to how you activated the venv itself. In this example we renamed the file to
cpouta.sh because Pukki will also need a similar file, if you want to use it, and naming them by the service they log in to makes it easier to operate in the future.source /path/to/your/venv/bin/cpouta.sh
In order to get access to your VM after you create one, you need to generate an SSH key pair and upload it to the cloud. You need to generate this key pair locally on your own computer using ssh-keygen. To make the rest of the guide easier to follow, we'll start with exporting your group name into an
environment variable
. Please shorten it to reasonable length, and make it lowercase + hyphenated.export PWPGROUP=<group name> ssh-keygen -t rsa -f ~/.ssh/$PWPGROUP.key
Please include a passphrase for your key.
First you need to upload your key to the cloud. You will only connect this key to your own VM whenever you create one. Upload your key with:
If you are using new openstack version:
openstack keypair create --public-key ~/.ssh/$PWPGROUP.key.pub $PWPGROUPFor older versions the command is:
openstack keypair create --from-file ~/.ssh/$PWPGROUP.key.pub $PWPGROUP
Creating a VM¶
Next you can create the VM itself. All instructions in the course are written for Ubuntu, so we recommend choosing the latest Ubuntu image. For flavor you should always choose
standard.small because it's the least resource consuming yet sufficient option. The example below uses these:openstack server create --flavor standard.small --image Ubuntu-24.04 --key-name $PWPGROUP $PWPGROUP-vm
You also need to attach the security group that allows you to SSH into your server. Security groups are sets of firewall rules that are used to manage which ports of the server can be connected to, and from where. We have precreated the necessary security groups for this course so you don't need to worry about creating them. The following command will add the ssh security group for your VM. It will allow SSH connections from anywhere, which is fine because your server uses SSH keys for logins.
openstack server add security group $PWPGROUP-vm ssh
At this point you will also most likely need to add the web security group so that HTTP(S) connections to your server can be accepted.
openstack server add security group $PWPGROUP-vm web
Connecting to Your VM¶
Connecting to your VM is done via two steps, first connect to the central server with your group's username. First you need to get the server's IP address, which you can do with command below. The publicly accessible IP is the latter one in the addresses field.
Before you can connect to your VM, it needs to have a public IP address (aka. floating IP). Because IPv4 addresses are limited, we have only been given two floating IP addresses to use for the project. Make a reservation for a floating IP before assigning one. Do not assign an address to your server if you don't have a reservation. Start by checking which floating IP is free:
openstack floating ip list
Addresses where Fixed IP Address is None are currently unassigned. Choose one of them and add it to your VM (where x.x.x.x is the IP address you are assigning).
openstack server add floating ip $PWPGROUP-vm x.x.x.x
From now on you should use this IP (replace x.x.x.x with it) to connect to your VM. Your VM will also have an automatically assigned hostname in the form of
fip-x-x-x-x.kaj.poutavm.fi. To connect to your VM with SSH, you can use either the IP or the address. Add your SSH key to your SSH agent and connect to your VM as the ubuntu user.ssh-add /path/to/your/private/key ssh ubuntu@x.x.x.x
If you want to close the connection with your virtual machine just type the command
logoutShutting Down Your VM¶
Whenever you stop using your VM you need to delete it. For VMs used for the exercise, you should ideally complete the entire exercise in one session and then delete the VM. To delete your VM:
openstack server delete $PWPGROUP-vm