Creating a single-node cluster

These instructions outline a quick method for running a local k0s master and worker in a single node.

NOTE: This method of running k0s is only recommended for dev, test or POC environments.

Prepare dependencies

1. Download the k0s binary

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

2. Download the kubectl binary

  1. sudo curl --output /usr/local/sbin/kubectl -L "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"

3. Make both binaries executable

  1. sudo chmod +x /usr/local/sbin/kubectl
  2. sudo chmod +x /usr/bin/k0s

Start k0s

1. Create the k0s config directory

  1. mkdir -p ${HOME}/.k0s

2. Generate a default cluster configuration

  1. k0s default-config | tee ${HOME}/.k0s/k0s.yaml

3. Start k0s

  1. sudo k0s server -c ${HOME}/.k0s/k0s.yaml --enable-worker &

Use kubectl to access k0s

1. Save kubeconfig for user

  1. sudo cat /var/lib/k0s/pki/admin.conf | tee ~/.k0s/kubeconfig

2. Set the KUBECONFIG environment variable

  1. export KUBECONFIG="${HOME}/.k0s/kubeconfig"

3. Monitor cluster startup

  1. kubectl get pods --all-namespaces