DEV Community

Pradeep Kumar
Pradeep Kumar

Posted on • Edited on

Connect DigitalOcean Kubernetes to GitLab - Tutorial for Windows 10 Users

It requires many step and there is no complete guide available. Hence, this tutorial exist.

Step 1: Create DigitalOcean Kubernetes

It's fairly straight forward process. Once it done, click on Download config file button. It will download .yaml file.

Step 2: Install kubectl

More information: https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl-on-windows

  • Open C:\Users\<windows-user>\ and create kubectl folder
  • Copy kubectl.exe in C:\Users\<windows-user>\kubectl
  • Press Windows + R keys together, type the command "ysdm.cpl" in the Run dialog box and press Enter.
  • Click on Advanced > Environment Variables > Under System Variables > Select Path > Click Edit > Click New > Enter C:\Users\<windows-user>\kubectl
  • Open Command Prompt and type kubectl and press enter. If you get message instead error that mean kubectl is configured.

Step 3: Install awk

  • Download and install awk

  • Similary like previus example, add new path to Environment Variables and Path will be C:\Program Files (x86)\GnuWin32\bin

  • Open Command Prompt and type awk and press enter. If you get message instead error that mean awk is configured.

Step 4: Install doctl

  • Download and install windows version from doctl

  • Create DigitalOcean (DO) Token. Login to DO > Click API > Generate New Token . Copy token.

  • Open C:\Users\<windows-user>\kubectl in Command Prompt and run doctl auth init command. It will ask you the Token to enter.

  • Run the command provided in DO Screenshot

Step 5: Create gitlab-setup.yml

  • Open C:\Users\<windows-user>\kubectl and create gitlab-setup.yml file with following content:
apiVersion: v1
kind: ServiceAccount
metadata:
  name: gitlab
  namespace: default
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: gitlab-cluster-admin
subjects:
- kind: ServiceAccount
  name: gitlab
  namespace: default
roleRef:
  kind: ClusterRole
  name: cluster-admin
  apiGroup: rbac.authorization.k8s.io
Enter fullscreen mode Exit fullscreen mode
  • Open cmd and type cd C:\Users\<windows-user>\kubectl

  • Type kubectl apply -f gitlab-setup.yml and press enter;

Step 6: Get Gitlab Kubernetes cluster details

Reference: https://www.youtube.com/watch?v=7ycuOLa5mtM

App URL:
  • Run following command to get APP URL:
kubectl cluster-info | findstr "Kubernetes master" | awk "/http/ {print $NF}"
Enter fullscreen mode Exit fullscreen mode
  • Get secrete, run
kubectl get secrets --all-namespaces|awk "/gitlab-token/ {print $2}"
Enter fullscreen mode Exit fullscreen mode

Note the text echo/printed on the screen. Let's call this text as $SECRETE

  • Get CA Certificate, run following command:
kubectl get secret $SECRETE -o jsonpath="{['data']['ca\.crt']}"
Enter fullscreen mode Exit fullscreen mode

Note: replace $SECRETE with the actual text which was printed.

This command will give you a string/text. Copy that text and paste at https://www.base64decode.org/ then click on decode, this give you the CERTIFICATE simloar to follow:

-----BEGIN CERTIFICATE-----
MIIDJzCCAg+gAwIBAgICBnUwDQYJKoZIhvcNAQELBQAwMzEVMBMGA1UEChMMRGln
....
....
DD/JYjdMdAewoEXZlXPAJIS+eQjXi6AWbLYzBTRHc55GjJoxugWYF0xrTg==
-----END CERTIFICATE-----
Enter fullscreen mode Exit fullscreen mode
  • Get Service Token, run following command:
kubectl get secret $SECRETE -o jsonpath="{['data']['token']}"
Enter fullscreen mode Exit fullscreen mode

Note: replace $SECRETE with the actual text which was printed.

This command will give you a string/text. Copy that text and paste at https://www.base64decode.org/ then click on decode, this give you the CERTIFICATE simloar to follow:

eyJhbGciOi......66GmIE4KH4OHr44Py-4HA
Enter fullscreen mode Exit fullscreen mode

Step 4: Configure Gitlab Kubernetes

  • Visit: <gitlab-url>/admin/clusters
  • Enter the details that you collected in previous steps and Click on save
  • In Helm Tiller, click Install
  • Then, in Ingress, click Install. After install it will give an IP and an URL in Base domain, copy this URL and enter in Base domain input and click save.
  • In Cert-Manager, click Install.
  • In GitLab Runner, click Install.

Step 5: Test Project

  • Visit <gitlab-url>/admin/runners, here you will see a new runner. You can edit the runner and remove tags so that it can pick all the CI jobs. You can also assign project to this runner.

  • Create New Project.

  • Auto DevOps will automatically kick and run the pipelines.

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay