IT 3300 : Virtualization

Kubernetes — Building a Cluster

MicroK8s

    sudo apt update
    sudo snap install microk8s --classic
    sudo usermod -a -G microk8s $USER
    sudo chown -f -R $USER ~/.kube
    # log out and back in
    sudo snap alias microk8s.kubectl kubectl

Clustering MicroK8s

  • Install MicroK8s on each of your nodes

  • Make sure nodes can resolve each other (/etc/hosts or DNS)

  • On the first node:

      microk8s add-node
    
  • Paste the printed join command on each other node

  • Then: kubectl get nodes

kubectl — your remote control

  • kubectl talks to the API server
  • Config lives in ~/.kube/config (server address + credentials)
  • Everything you do to the cluster goes through kubectl

First commands

  • kubectl get nodes — are all nodes Ready?
  • kubectl get pods -A — every pod, all namespaces
  • kubectl cluster-info — where's the control plane?
  • kubectl describe node <name> — capacity and health

Add-ons

  • MicroK8s ships add-ons you enable as needed:

      microk8s enable dns
      microk8s enable ingress
      microk8s enable hostpath-storage
    

Lab goals

  • Stand up a 3-node cluster on your VMs
  • Confirm all nodes are Ready
  • Enable DNS and (later) ingress