Getting Started

In this tutorial you’ll create a full Kubernetes cluster with just one node including both the controller and the worker. This is well suited for environments where the high-availability and multiple nodes are not needed. This is the easiest install method to start experimenting k0s.

Prerequisites

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.

Before proceeding, make sure to review the System Requirements.

Installation steps

1. Download k0s

The k0s download script downloads the latest stable k0s and makes it executable from /usr/bin/k0s.

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

2. Install k0s as a service

The k0s install sub-command will install k0s as a system service on the local host running one of the supported init systems: Systemd or OpenRC. Install can be executed for workers, controllers or single node (controller+worker) instances.

This command will install a single node k0s including the controller and worker functions with the default configuration:

  1. $ sudo k0s install controller --single

The k0s install controller sub-command accepts the same flags and parameters as the k0s controller. See manual install for an example for entering a custom config file.

3. Start k0s as a service

To start the k0s service, run

  1. $ sudo systemctl start k0scontroller

It usually takes 1-2 minutes until the node is ready for deploying applications.

If you want to enable the k0s service to be started always after the node restart, enable the service. This command is optional.

  1. $ sudo systemctl enable k0scontroller

4. Check service, logs and k0s status

You can check the service status and logs like this:

  1. $ sudo systemctl status k0scontroller
  2. Loaded: loaded (/etc/systemd/system/k0scontroller.service; enabled; vendor preset: enabled)
  3. Active: active (running) since Fri 2021-02-26 08:37:23 UTC; 1min 25s ago
  4. Docs: https://docs.k0sproject.io
  5. Main PID: 1408647 (k0s)
  6. Tasks: 96
  7. Memory: 1.2G
  8. CGroup: /system.slice/k0scontroller.service
  9. ....

To get general information about your k0s instance:

  1. $ sudo k0s status
  2. Version: v0.11.0
  3. Process ID: 436
  4. Parent Process ID: 1
  5. Role: controller+worker
  6. Init System: linux-systemd

5. Access your cluster using kubectl

The Kubernetes command-line tool ‘kubectl’ is included into k0s. You can use it for example to deploy your application or check your node status like this:

  1. $ sudo k0s kubectl get nodes
  2. NAME STATUS ROLES AGE VERSION
  3. k0s Ready <none> 4m6s v1.20.5-k0s1

6. Clean-up

If you want to remove the k0s installation you should first stop the service:

  1. $ sudo systemctl stop k0scontroller

Then you can execute k0s reset, which cleans up the installed system service, data directories, containers, mounts and network namespaces. There are still few bits (e.g. iptables) that cannot be easily cleaned up and thus a reboot after the reset is highly recommended.

  1. $ sudo k0s reset

Next Steps