Install MicroK8s offline (deprecated)

This document details the procedure to install MicroK8s on an offline machine.

Prerequisites

Please ensure that the installation of MicroK8s is performed on a machine that meets the technical requirements.

Get required files

  1. Connect via SSH on a machine with the same operating system as the machine where Cyberwatch will be deployed. This machine must be connected to the internet.

  2. Create the sources directory:

    mkdir microk8s_sources; cd microk8s_sources
    
  3. Download the packages:

    1. On a Red Hat based distribution:

      1. Install yum-utils:

        sudo yum install yum-utils curl epel-release
        
      2. Download snapd and its dependencies:

        sudo yumdownloader --resolve snapd
        
      3. Install snapd:

        sudo yum install snapd
        
      4. Install podman:

        sudo yum install podman
        export CONTAINER_DOWNLOADER=podman
        
    2. On a Debian-based distribution:

      1. Download dependencies of package snapd:

        This command downloads the whole dependency tree to ensure that the installation will work on the offline machine.

        apt-get download $(apt-cache depends --recurse --no-recommends --no-suggests \
           --no-conflicts --no-breaks --no-replaces --no-enhances \
           --no-pre-depends snapd | grep "^\w")
        
      2. Install snapd

        sudo apt install snapd
        
      3. Install docker:

        sudo apt install docker.io
        export CONTAINER_DOWNLOADER=docker
        
  4. Download the container images required by MicroK8s:

    sudo $CONTAINER_DOWNLOADER pull docker.io/calico/cni:v3.13.2
    sudo $CONTAINER_DOWNLOADER pull docker.io/calico/pod2daemon-flexvol:v3.13.2
    sudo $CONTAINER_DOWNLOADER pull docker.io/calico/kube-controllers:v3.13.2
    sudo $CONTAINER_DOWNLOADER pull docker.io/calico/node:v3.13.2
    sudo $CONTAINER_DOWNLOADER pull docker.io/coredns/coredns:1.6.6
    sudo $CONTAINER_DOWNLOADER pull k8s.gcr.io/pause:3.1
    
    sudo $CONTAINER_DOWNLOADER save docker.io/calico/cni:v3.13.2                -o cni.tar
    sudo $CONTAINER_DOWNLOADER save docker.io/calico/pod2daemon-flexvol:v3.13.2 -o pod2daemon.tar
    sudo $CONTAINER_DOWNLOADER save docker.io/calico/kube-controllers:v3.13.2   -o kube-controllers.tar
    sudo $CONTAINER_DOWNLOADER save docker.io/calico/node:v3.13.2               -o node.tar
    sudo $CONTAINER_DOWNLOADER save docker.io/coredns/coredns:1.6.6             -o coredns.tar
    sudo $CONTAINER_DOWNLOADER save k8s.gcr.io/pause:3.1                        -o pause.tar
    
  5. Download snap packages for microk8s and helm:

    sudo snap download core
    sudo snap download microk8s --channel=1.20/stable
    
    sudo snap download core18
    sudo snap download helm --channel=3.5/stable
    
  6. Archive all the files:

    cd ..
    sudo tar czvf microk8s_sources.tar.gz microk8s_sources
    

Install MicroK8s

  1. Transfer the archive on the offline machine.

  2. Switch to the root user:

    sudo su
    
  3. Extract the sources:

    tar xvzf microk8s_sources.tar.gz
    cd microk8s_sources
    
  4. Install snapd:

    1. On a Red Hat based distribution:

      yum install *.rpm
      
    2. On a Debian-based distribution:

      dpkg -i *.deb
      
  5. Enable and start snapd and snap’s classic mode:

    systemctl enable snapd --now
    ln -s /var/lib/snapd/snap /snap
    
  6. Install microk8s and helm:

    ls *.assert | xargs -n 1 snap ack
    ls *.snap | xargs -n 1 snap install --classic
    
  7. Start MicroK8s:

    /snap/bin/microk8s start
    
  8. Load the images into MicroK8s:

    ls *.tar| xargs -n 1 -I {} /snap/bin/microk8s ctr i import $(pwd)/{}