Logo

Armand.nz

Home / About / Linkedin / Github

local Kubernetes with MicroK8s

#Kubernetes #MicroK8s #ubuntu |

I will following the typical setup but opt to install my own nginx ingress so it is consistent with the manifests i use on other kubernetes platforms

  1. Enable snapd
    sudo apt update
    sudo apt install snapd
    
  2. Install microk8s
# Install MicroK8s from the command line
# This may take a while...
sudo snap install microk8s --classic
  1. If you have ufw enabled. You may need to configure your firewall to allow pod-to-pod and pod-to-internet communication:
sudo ufw allow in on cni0 && sudo ufw allow out on cni0
sudo ufw default allow routed
  1. Enable addons
# Dashboard,dashboard, core-dns or local storage and metalLB l
microk8s enable dns dashboard storage metallb


# These addons can be disabled at anytime by running the microk8s disable command:
# microk8s disable dns dashboard storage metallb
  1. MetalLB requires a CIDR notation to occupy a address space
# Disable default implementation
microk8s disable metallb

# Enable with address space
#microk8s enable metallb:10.0.222.0/24
microk8s enable metallb:10.0.0.210-10.0.0.220

Start and Stop

Start — Stop

  1. To start and stop microk8s run the following commands

microk8s start

and

microk8s stop

Using kubectl with microk8s

  1. Add microk8s kubeconfig and ensure you have adeduate permissions to access MicroK8s.This allows you to use helm and other kubernetes tooling
sudo usermod -a -G microk8s armand
sudo chown -f -R armand ~/.kube
newgrp microk8s
sudo microk8s config > ~/.kube/config
chmod go-r ~/.kube/config

Using

  1. For temporary binding for “microk8s kubectl” to “kubectl” or “k

MicroK8s uses a namespaced kubectl command to prevent conflicts with any existing installs of kubectl. If you don’t have an existing install, it is easier to add an alias (append to ~/.bash_aliases) like this:

#alias kubectl='microk8s kubectl'
alias k='microk8s kubectl'

Check the alias works

k get nodes

NAME     STATUS   ROLES    AGE   VERSION
pop-os   Ready    <none>   16d   v1.25.4

comments powered byDisqus

Copyright © Armand