This is an old revision of the document!
Table of Contents
SoCS Kubernetes Cluster
Location: https://kubefarm.socs.uoguelph.ca
Who Has Access: Faculty or students with faculty, on request
The School of Computer Science has a Kubernetes cluster. It is running the RKE2 Kubernetes distribution, and has Rancher on top as a management layer and web based graphic interface.
Important Note: Due to the design of Kubernetes, it is unaware of Rancher running above it. This means that some things MUST be done through Rancher, while others can be done directly using the Kubernetes command kubectl. This guide will note when something must be done directly via Rancher.
How To Interact With Kubernetes
You can interact with Kubernetes in the following ways:
Directly Through the Web Interface
Interacting with Rancher is as simple as logging into Kubefarm and using the interface. To run kubectl commands, from cluster manager click on the Launch Kubectl button to bring up a Kubernetes shell.
Install Rancher Command Line Interface
Follow the guide from the official Rancher documentation. This is the simplest method to connect to Rancher via a command line. To run kubectl commands, preface the command with rancher, ie
rancher kubectl get pod
Install Kubectl on Your Machine
If you prefer to interact with Kubernetes directly, the kubectl command can be installed directly on your local machine.
Follow the instructions for your Operating system from the official Kubernetes documentation.
From the Cluster Manager Menu , choose Kubeconfig file in the top right of the screen to download this file. You can then copy it to your .kube folder which was created in the installation process.
To access from off campus, ensure you are running the campus VPN and choose Full Tunnel mode.
Gitlab Agent Integration
Integrate your Gitlab project with the Kubernetes cluster to automatically deploy and update your project. This Guide assumes you already have a project located in the SoCS Gitlab server, and that you have built the project into a Docker container.
1. You will need to host your Docker container. If the container can be publicly accessible, this can be hosted in Docker Hub. If it must be private, the SoCS Gitlab installation has it's own Docker Container Registry. To access the SoCS Registry, use docker login registry.uoguelph.ca
and enter your central login/Gitlab credentials. Directions to tag and push can be found in your Gitlab project under Packages & Registries > Container Registry.
NB: In the future building a Docker container and pushing to the SoCS registry could be done through the CI/CD pipeline, but this is not yet available.
2. Create .gitlab/agent/agent-name/config.yaml in your Gitlab project, replacing agent-name with whatever you want to name your agent.
gitops: manifest_projects: - id: "Your Project ID" paths: - glob: '/manifests/*.{yaml,yml,json}'
Replace “Your Project ID” with the ID number of your project. This is listed under the project name in the main project screen.
3. From the Infrastructure > Kubernetes Clusters Menu, choose Add Agent and select the agent named in the previous step. Make sure you save the token that is created.
4. In Kubernetes, create two namespaces One for your project, and the other for the gitlab agent. From the https://kubefarm.socs.uoguelph.ca/c/local/projects-namespaces Projects and Namespaces Menu choose Add Namespace. Enter a name, leaving the other settings at their defaults and choose Create. This step MUST be done through Rancher, otherwise you will not have permissions to access the namespace you create.
5.
kubectl create secret generic -n your-gitlab-agent-namespace gitlab-kubernetes-agent-token --from-literal=token='Your Token Here'
6. Customize the yaml file below with the namespaces you've chosen. You should also ensure the version of the image matches the version gitlab is currently running.
TODO Put Yaml Here
7. Add the newly created yaml file with kubectl add -f filename.yml