Skip to content

⚡ Manage a Rahti project from the CLI

Summary
This tutorial shows you how to create a Rahti project (sometimes called a namespace) from the CLI.
Internet
https://rahti.csc.fi
flowchart LR
    A(Launch terminal) --> B(Paste and execute<br><code>oc</code> command)
    B --> C{Create<br>project}
    C -->|Yes| D(Give name and <code>csc_project:201xxxx</code> as parameters)
    D --> E(List projects)
    C -->|No| E
    E --> F{Project action}
    F --> G(Select active project)
    F --> H(Delete project)
    F --> C

Prerequisites

  1. CLI tools are installed.
  2. Successful login to the Rahti service from the CLI.

🟩 Procedure

If you don't have any projects, the following will be printed when you log in with oc command.

Info

In case you missed it, here's the tutorial for Log in to Rahti from the CLI.

Terminal
$ oc login ...
Logged into "https://api.2.rahti.csc.fi:6443" as "cbrown" using the token provided.

You don't have any projects. You can try to create a new project, by running

    oc new-project <projectname>
$ _

As with creating a Rahti project from the web interface, we need to define a name and the csc_project:2010xxx tag for the new project.

Terminal
$ oc new-project basics-of-containers --description='csc_project:2010xxx'
Now using project "basics-of-containers" on server "https://api.2.rahti.csc.fi:6443".

You can add applications to this project with the 'new-app' command. For example, try:

    oc new-app rails-postgresql-example

to build a new example application in Ruby. Or use kubectl to deploy a simple Kubernetes application:

    kubectl create deployment hello-node --image=registry.k8s.io/e2e-test-images/agnhost:2.43 -- /agnhost serve-hostname
$ _

Note

If you do not address the appropriate name or csc_project:2010xxx tag, one of the following error messages will be displayed.

error: must have exactly one argument

Error from server: admission webhook "project.admission.webhook" denied the request: Unable to extract the ID of CSC computing project from the description, please make sure to add the description of the project as described in this link: https://docs.csc.fi/cloud/rahti2/usage/projects_and_quota/

If you have more than one project, you can list them using the oc projects command.

Terminal
$ oc projects
You have access to the following projects and can switch between them with 'project <projectname>':

  * basics-of-containers
    containers-and-linux

Using project "basics-of-containers" on server "https://api.2.rahti.csc.fi:6443".
$ _

The asterisk indicates the active project.

The project can be changed with the command oc project <projectname>. For example, like this:

Terminal
$ oc project containers-and-linux
Now using project "containers-and-linux" on server "https://api.2.rahti.csc.fi:6443".
$ _

... and a project can be deleted using the following command:

Terminal
$ oc delete project basics-of-containers
project.project.openshift.io "basics-of-containers" deleted
$ oc projects
You have one project on this server: "containers-and-linux".
$ _

That's it!

Now you know how to manage Rahti projects from the CLI.

Further Learning

Here are some suggestions for what to read next: