HowTo:CS Launch Terminal

From Computer Science Wiki
Revision as of 15:49, 13 November 2023 by Carnold (talk | contribs)
Jump to navigation Jump to search

Introduction

This is a companion guide to HowTo:CS Launch. This guide goes through the same steps as the web interface version, but is done through a command line. All operations except project creation and namespace creation can be done using a command line -- reference HowTo:CS Launch for creating a project and namespace. This guide will walk you through the steps via a command line on rlogin.cs.vt.edu and applies to any other workstation you have access to. You will need to use a text editor to create configuration files. For rlogin.cs.vt.edu can use vi, nano, or VS Code to create text files.

  • This guide uses the namespace my-test-namespace You will need to substitute your own namespace name wherever this is used.

Create a Project and Namespace

Install command line tools

There are two commands used to interact with kubernetes cluster: kubectl and helm. Both use the same configuration file to access to the cluster.

  • Install kubectl locally using instructions at https://kubernetes.io/docs/tasks/tools/ Generally it just involves downloading a binary release and copying the binary somewhere convenient to run.
    • Example: Install into your account on rlogin.cs.vt.edu
    • SSH into rlogin.cs.vt.edu
    • Run the following commands:
cd ~/bin
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
    • kubectl is used to view, edit, and create kubernetes resources
  • Install helm locally using instructions at https://helm.sh/docs/intro/install/ Generally it just involves downloading a binary release and copying the binary somewhere convenient to run.
    • Example: Install into your account on rlogin.cs.vt.edu
    • SSH into rlogin.cs.vt.edu
    • Run the following commands:
cd ~/bin
curl -L https://get.helm.sh/helm-v3.13.1-linux-amd64.tar.gz | tar zx --strip-components 1 linux-amd64/helm

Create Kubernetes Configuration File

The Kubernetes command line tools both use the same configuration file that tells them how to connect to the kubernetes cluster. The CS Launch system makes this easy by giving you a link on the website with the contents of the configuration file.

  • Navigate to your Cluster Dashboard
  • Click on the Copy KubeConfig to Clipboard button in the top right corner. It looks like two squares.
  • Use a text editor to create a file named config
    • The config file needs to be located in your home directory.
    • For Linux or Mac the full path to the file should be ~/.kube/config
    • For Windows the path is %USERPROFILE%\.kube\config
  • Paste the contents into the config file.
  • Example using rlogin.cs.vt.edu:
    • SSH into rlogin.cs.vt.edu
    • Run command: mkdir -p ~/.kube
    • Run command: vi ~/.kube/config
    • Hit the i key to enter insert mode
    • Paste contents of the KubeConfig file
    • Hit the ESC key to exit insert mode
    • Type the following to save the file: :wq<enter>
    • Run command: chmod 600 ~/.kube/config
  • Once you have the configuration file created and in the right place you should be able to run kubectl and access the cluster.
  • Test your cluster access by running the command kubectl get nodes

Launching a Database Using Helm

Kubernetes supports Helm charts to automate deployment of software. There are existing Helm charts for many popular software projects, such as databases. Using a Helm chart can make setting up and updating complex software much easier. This guide will walk you through deploying MariaDB using a Helm chart using a command line terminal. Helm uses repositories to store the charts that you can install. You will need to install a helm repository before you can install a chart.

  • Log into your kubectl enabled terminal.
  • Install the CS Launch Partners repo by running the following commands:
helm repo add partners https://raw.githubusercontent.com/rancher/partner-charts/main-source
helm repo update
helm search repo
  • Make a directory to store your database deployment files
mkdir mariadb-deployment
cd mariadb-deployment
  • Download the deployment Yaml configuration file
helm show values partners/mariadb > values.yaml
  • Use a text editor to edit the values.yaml file
    • Make the following changes to the file:
auth:
  database: test-db
  username: test
  password: Insecure
primary:
  persistence:
    size: 1Gi