Skip to main content

Set up Kubernetes with k0s

This page, based on k0s's Quick Start Guide, outlines the steps for setting up Kubernetes with k0s for the purpose of running neon-proxy later on.

k0s is an all-inclusive Kubernetes distribution that offers an easy, smooth way to create Kubernetes clusters ready for production usage. k0s fits well in any cloud environment on any system that includes the Linux kernel. Please note that this tutorial has been written for Debian/Ubuntu, but it can be used for any Linux running one of the supported init systems: Systemd or OpenRC.

Prerequisites

Before you start, verify that your environment meets the system requirements for k0s.

In addition, make sure the following software is installed on your device:

  • kubectl, a command-line tool for Kubernetes' control plane
  • Helm 3, Kubernetes' package manager

Set up a Single Kubernetes Node with k0s

Download the k0s binary

Run the k0s download script to download the latest stable version of k0s and make it executable from /usr/bin/k0s

sudo curl -sSLf https://get.k0s.sh | sudo sh

Install k0s as a service

Install k0s controller as a system service and enable worker

sudo k0s install controller --enable-worker

Start k0s as a service

To start the k0s service, run

sudo k0s start

Check status

Check service, logs, and k0s status

sudo k0s status

Access the k0s cluster using kubectl

Check if your node is ready running

sudo k0s kubectl get nodes

List the default namespaces for your k0s installation

sudo k0s kubectl get namespaces

You now have a working Kubernetes cluster and can spin up a neon-proxy with it.

Add More Kubernetes Nodes to the Cluster

For scaling purposes, you may opt to add multiple workers to your Kubernetes cluster. To do so, you need to generate a token that can be shared between your nodes/workers. This token contains all the information in order to join the cluster.

First, log in your control-plane/controller node and generate the main token as a base64-encoded file

k0s token create --role=worker
caution

Please keep this token file in a safe and secure location!

Now log into worker/node and install k0s

sudo curl -sSLf https://get.k0s.sh | sudo sh

In your worker/node, paste the base64 token generated by the controller node earlier into a file, e.g., /tmp/token.cluster, and then start the k0s service

sudo k0s install worker --token-file /tmp/token.cluster
sudo k0s start

The worker is now a part of the cluster. Wait a few minutes and you can see that your node has been added to the cluster:

kubectl get nodes

For a full list of configuration options, please refer to the official k0s documentation.

Was this page helpful?