HowTo:CS Launch Terminal: Difference between revisions

From Computer Science Wiki
Jump to navigation Jump to search
Carnold (talk | contribs)
Carnold (talk | contribs)
Line 39: Line 39:
** Run command: <code>chmod 600 ~/.kube/config</code>
** Run command: <code>chmod 600 ~/.kube/config</code>
* Once you have the configuration file created and in the right place you should be able to run ''kubectl'' and access the cluster.
* 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 <code>kubectl get nodes</code>

Revision as of 15:59, 9 November 2023

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.

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