Site Tools


techsupport:kube3760

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
techsupport:kube3760 [2022/11/30 21:52] – [Integrating Gitlab and Kubernetes with Gitlab Agent] kjohns23techsupport:kube3760 [2023/03/15 17:20] (current) kjohns23
Line 1: Line 1:
-===== Gitlab and Kubernetes in CIS*3760 F23 =====+==== Gitlab and Kubernetes in CIS*3760 F23 ====
  
 This is a guide to assist students in CIS*3760 with the process of deploying an application developed on the SoCS Gitlab Server to our Kubernetes cluster. Each project group will be provided with their own server running RKE2 Kubernetes, on which to deploy. The server will be located at cis3760-XX.socs.uoguelph.ca where XX is your group number. This is a guide to assist students in CIS*3760 with the process of deploying an application developed on the SoCS Gitlab Server to our Kubernetes cluster. Each project group will be provided with their own server running RKE2 Kubernetes, on which to deploy. The server will be located at cis3760-XX.socs.uoguelph.ca where XX is your group number.
Line 15: Line 15:
 If you prefer to interact with Kubernetes directly from your own machine, the kubectl command can be installed directly on your local machine.  If you prefer to interact with Kubernetes directly from your own machine, the kubectl command can be installed directly on your local machine. 
  
-Follow the instructions for your Operating system from the [[ https://kubernetes.io/docs/tasks/tools/ | official Kubernetes documentation]].+Follow the instructions for your Operating system from the [[ https://kubernetes.io/docs/tasks/tools/|official Kubernetes documentation]].
  
-From the [[ https://kubefarm.socs.uoguelph.ca/ | web interface ]], open the hamburger menu at the top left, and select your cluster listed under Explore Cluster. Select Download KubeConfig from the top right menu on this page. The icon looks like a sheet of paper. You can then copy it to your .kube folder which was created in the installation process.+From the [[ https://kubefarm.socs.uoguelph.ca/ |web interface ]], open the hamburger menu at the top left, and select your cluster listed under Explore Cluster. Select Download KubeConfig from the top right menu on this page. The icon looks like a sheet of paper. You can then copy it to your .kube folder which was created in the installation process.
  
 Unfortunately, due to the current lack of VPN access, this method will only work from off campus, or if you proxy your connection through portkey. Directions to do this are beyond the scope of this guide.  Unfortunately, due to the current lack of VPN access, this method will only work from off campus, or if you proxy your connection through portkey. Directions to do this are beyond the scope of this guide. 
Line 88: Line 88:
  
 Next, run the following command on your kubernetes server, specifying your token from step 3, to install the gitlab agent in kubernetes and automatically connect it to your gitlab project.  Next, run the following command on your kubernetes server, specifying your token from step 3, to install the gitlab agent in kubernetes and automatically connect it to your gitlab project. 
 +<code>helm repo add gitlab https://charts.gitlab.io</code>
 <code> helm upgrade --install gitlab-agent gitlab/gitlab-agent --set config.token='TOKEN_FROM_STEP_THREE' --namespace=gitlab-agent -f values.yml </code> <code> helm upgrade --install gitlab-agent gitlab/gitlab-agent --set config.token='TOKEN_FROM_STEP_THREE' --namespace=gitlab-agent -f values.yml </code>
  
Line 95: Line 95:
 1. Kubernetes needs to be able to connect to the Gitlab Docker Registry. In your Gitlab Project go to Settings > Repository > Deploy Tokens. Enter a name to label the token, a username, and check read_registry 1. Kubernetes needs to be able to connect to the Gitlab Docker Registry. In your Gitlab Project go to Settings > Repository > Deploy Tokens. Enter a name to label the token, a username, and check read_registry
  
-2. Run the following command, substitution the username you entered in the previous step for DOCKER_USER, the token generated for DOCKER_PASSWORD, and an email address of one of the project members for DOCKER_EMAIL. <code> kubectl create secret docker-registry regcred --namespace=infovis --docker-server=registry.socs.uoguelph.ca --docker-username=DOCKER_USER --docker-password=DOCKER_PASSWORD --docker-email=DOCKER_EMAIL </code>+2. Run the following command, substituting the username you entered in the previous step for DOCKER_USER, the token generated for DOCKER_PASSWORD, and an email address of one of the project members for DOCKER_EMAIL. <code> kubectl create secret docker-registry regcred --namespace=infovis --docker-server=registry.socs.uoguelph.ca --docker-username=DOCKER_USER --docker-password=DOCKER_PASSWORD --docker-email=DOCKER_EMAIL </code>
  
-3. A Manifest file needs to be defined in Gitlab. This is a yaml file that lists the kubernetes specifications required to deploy your application within Kubernetes. A sample mainefest file is available in the code block below, and should be placed in manifests/manifest.yml in your Gitlab project repository. The "image:" line will have to be modified with your container location, and the "host" line will need to be changed to your server URL.+3. A Manifest file needs to be defined in Gitlab. This is a yaml file that lists the kubernetes specifications required to deploy your application within Kubernetes. A sample mainefest file is available in the code block below, and should be placed in manifests/manifest.yml in your Gitlab project repository. The "image:" line will have to be modified with your container URL, and the "host" line will need to be changed to your server URL. The container URL can be found in Gitlab from Packages & Registries > Container Registry.
  
 <code> <code>
Line 161: Line 161:
 ==== Conclusion ==== ==== Conclusion ====
  
-All the pieces are now in place to deploy your application automatically to your gitlab server. You can view your application by connecting to your cis3760xx.socs.uoguelph.ca server in a web browser.+All the pieces are now in place to deploy your application automatically to your gitlab server. You can view your application by connecting to your cis3760xx.socs.uoguelph.ca server in a web browser. Each time your container is updated within Gitlab, the agent will automatically pull the latest version to the kubernetes server.  
 + 
 +==== Graphical Representation ==== 
 + 
 +The following image is a graphical representation of the SoCS Gitlab and Kubernetes Setup and how the pieces fit together and relate to each other. 
 + 
 +{{:techsupport:gitlab-k8-agent-schematic.png|}}
techsupport/kube3760.1669845122.txt.gz · Last modified: 2022/11/30 21:52 by kjohns23