Home Deploying Kubernetes With K3S and Proxmox
Post
Cancel

Deploying Kubernetes With K3S and Proxmox

Kubernetes (k8s) is the most popular and powerful container-orchestration platform. It lets you rapidly deploy, manage, and maintain applications. K3S is the lightweight and certified Kubernetes distribution that’s perfect for development, CI/CD, edge computing and arm-based architectures. With a reduced footprint and easy setup, K3S can be up and running in minutes - taking Kubernetes anywhere.

Let’s dive into what makes K3S so great! Unlike other Kubernetes distributions, K3S packs all of the features you’d expect from a production-ready Kubernetes deployment into a single binary of less than 50MB. This compactness has dramatic benefits when time and space are both limited. Additionally, to get the most out of K3S, it includes a bundle of additional components such as Helm and Traefik.

K3S also contains an embedded database, making cluster services quick to start up. This ensures that all your nodes remain in sync with each other. Furthermore, K3S is one of the few distributions to offer support for arm-based architectures. As a cloud-native and low-resource solution, K3S is designed to work well with a wide range of IoT devices and edge computing tasks.

K3S’ one-click install and kubeconfig generation means that you can quickly spin up an application ready for use. This benefit decreases setup time and comes in particularly handy when deploying micro-services to multiple cloud and on-premise servers. All of this considered, K3S is one of the easiest ways to get Kubernetes up and running in no time flat.

Table of Contents

Create a Virtual Machine in Proxmox

Once again I will be leveraging my terraform code that I have mentioned and provided in previous posts. In the case of k3s I will still deploy 3 nodes so that I can demonstrate adding addtional nodes to the cluster.

If you want to check out the terraform code I am using for deployment of my VMs in Proxmox then please check out Deploying Kubernetes With Rancher and Proxmox and Deploying VMs With Terraform In ProxMox.

Install K3S

Let’s start by visiting the K3S website: k3s.io

Copy the command from their frontpage K3S Website

1
curl -sfL https://get.k3s.io | sh -

Paste and run the command into your master node and give it a few moments to install. Running K3S Command

Now to check your K3S node is up and running, run the second command from the site.

1
k3s kubectl get node

Getting K3S Node Status

Congrats! This is basically all it takes to get Kubernetes up and running with K3S! However, I want to take it a couple of steps further in this post with K3S, so let’s continue.

Deplopying Portainer with Kubernetes

I am going to be using YAML manifests and the documentation for portainer and Kubernetes can be found here: Install Portainer-CE on Kubernetes

K3S ships with traefik, which is a load balancer, by default. So we are able to leverage this by choosing the “Expose via Load Balancer” tab and then copying/running the command below.

Portainer Using YAML Manifest

Deploying Portainer in K3S

There is a security feature with Portainer that may prevent you from creating the inital admin user password because of timeout reasons. If you run into this issue, it will require that you restart the service. To restart the services simply run the following command:

1
sudo kubectl rollout restart deployment portainer -n portainer

Now if we run the following command we will be able to see Portainer running in Kubernetes, what external IP, and what port it is listening on:

1
sudo kubectl get service -A

kubcectl get service

Now we can access Portainer with the following: https://<externalIP>:9443

This will bring us to the admin password creation page. Create Admin Account

Next choose “Get Started”

Choose Get Started

Adding Nodes to the Cluster

Now that K3S is installed and running, we have successfully set up Portainer and are ready to complete our cluster. To do so, let’s add some additional nodes to our cluster.

The first thing we need to grab for this step is our node token. This can be found at the following directory: NODE_TOKEN comes from /var/lib/rancher/k3s/server/node-token on your server

Once you have your node token, we can run the following command on the other machines we want to add as nodes for our cluster: curl -sfL https://get.k3s.io | K3S_URL=https://myserver:6443 K3S_TOKEN=mynodetoken sh -

Adding Node to Cluster

Now we can check Portainer and see our nodes have been added.

Nodes Have Been Added

This post is licensed under CC BY 4.0 by the author.