test

Kubernetes is a way to deploy applications using docker registry images, deployment specifications, instructions, and more to a group, of computers all working together. Under the hood there is a lot to learn about kubernetes if you are from a traditional server management role. We’re going to use Gitlab to push our applications up to the cluster. Fortunately for us, gitlab does a lot of the heavy lifting when it comes to interacting with kubernetes. We just need to create a cluster, and connect it to our gitlab instance where ever we would like it to have access. (The entire gitlab instance, a group of projects, or a single repository)

Let’s create our Kubernetes cluster on Digitalocean.

k8s new do

Use the latest version, and use the region where all your other services are.

k8s buy

Create a pool with Basic nodes, using the $20/month 4GB memory 2 vCPU plan with 1 server for now (Number nodes). You can increase the servers in your cluster later.

k8s make

Now your kubernetes cluster will be created.

Once the cluster has been created, we need to connect to it using the command line. This is similar to SSH, but we will use a program called kubectl.

If you do not have the kubectl command you can install it using these instructions. Remember this is on your local computer (not your Gitlab server).

In order to connect our cluster to our computer to run commands on it, we need to copy the certificate from digitalocean to a file called config in the .kube folder in the home directory ~/.kube/config.

After your cluster is created it will look like this

k8s dashboard

Click the Download Config File button and save it to ~/.kube/config

  • You may need to make the .kube directory in your home folder first.

Test that this is working by typing

kubectl cluster-info | grep -E 'Kubernetes master|Kubernetes control plane' | awk '/http/ {print $NF}'

k8s dashboard

If you are set up correctly, the command will return your cluster API URL on digitalocean.