Effortless Machine Learning Infrastructure: Creating users and namespaces in Kubeflow - Part 1

Author: Philip Godfrey

Pre-requisite – Installing Kubeflow

If you haven’t installed Kubeflow in Oracle Cloud Infrastructure, you’ll be pleased to know I’ve created a blog on this exact topic. You can find it here

 

Accessing the Cluster

In order to administrate Kubeflow, we first need to access the machine. For us to do this, we must move from our local machine onto the Cluster, which is sitting in the cloud. To access, we need to SSH (secure shell) onto the Cluster.

SSH provides us with a simple and secure way to enable two computers to communicate with one another and is accessed through the terminal.

When provisioning Kubeflow, you will have created a Private Key for OCI, you will need to specify this when connecting to the cluster.

In the terminal, change directory to the folder your Private Key for OCI is saved and use the below code to create the SSH tunnel:

                                                Ssh -i {ssh-private-key.key} opc@{public IP}

Note -
{ssh-private-key.key}
= the Private Key for OCI
{public IP} = the Public IP of the Bastion Host in Oracle Cloud

Now we have managed to connect to the Cluster, we need to change directory to jump up two levels until we reach the opt folder. This is where Kubeflow has been provisioned and where we will start coding to create our new users and namespaces.

 

Creating a New User

Before we begin creating a new user, we need to navigate to the appropriate area:

Cd opt/Kubeflow/manifests/common/user-namespace/base/

 

In the directory, you will notice all of the files have a ‘.yaml’ extension. YAML stands for Yet Another Markup Language and is a digestible data serialization language, often used to create configuration files with any programming language.

There is a file named profile-instance.yaml if we take a look inside this file we will

----------------------------------------

apiVersion: kubeflow.org/v1beta1

kind: Profile

metadata:

name: $(profile-name)

spec:

owner:

kind: User

name: $(user)

------------------------------------------

We will use this as a basis to create our new user.

Create a new yaml file named ‘test-profile.yaml’, we can do this using the code below, which will create a blank file with the name ‘test-profile.yaml’

Sudo touch test-profile.yaml

 

Within this file we need to add the below code, which will be used to create our new user account. A profile owns a Kubernetes namespace, as well as a collection of Kubernetes resources. Users have view and modify access to their primary profiles


----------------------------------

apiVersion: kubeflow.org/v1beta1

kind: Profile

metadata:

  name: kubeflow-test

spec:

  owner:

    kind: User

    name: test@emaildomain.com

---------------------------------

Change the ‘name’ meta-data to what you want the namespace to be called. In the example this will be ‘kubeflow-test’

Change the ‘name’ within the owner tag to be the created user. In the example it’s ‘test@emaildomain.com’

 

Update ‘test-profile.yaml’ file

In order to make the changes in the previous step, we must update the file ‘test-profile.yaml’ we have just created. We need to use vi to do this.

Vi (or Visual Editor) is the default text editor that comes with most Linux systems. It is a Terminal-based text editor which we need to use to update files within Kubeflow. 

sudo vi test-profile.yaml

 

NOTE:

·         Press i to change to INSERT mode

·         Paste in the contents of the previous code (using right-click)

·         Press ESC to exit INSERT mode.

·         To save and quit the file, you need to use     :wq!

This will save the file and bring you back to the terminal.

As the file has been updated, we now need to apply those changes we’ve made. We can do so using the below code:

kubectl apply -f test-profile.yaml

 

kubectl apply is used to create or modify Kubernetes resources defined in a manifest file. This is called a declarative usage. The state of the resource is declared in the manifest file, then kubectl apply is used to implement that state

The output from the terminal should confirm that the profile has been created.

Profile.kubeflow.org/Kubeflow-test created

Comments