Welcome to the Linux Foundation Forum!

2.2 CP Setup Script Error

johannespn
johannespn Posts: 3
edited June 2023 in LFD259 Class Forum

Hi there and thanks for helping.

I'm using the following virtual machine setup on Mac M1 chip.

$ multipass info --all                   
Name:           cp
State:          Running
IPv4:           192.168.64.6
                172.17.0.1
Release:        Ubuntu 20.04.6 LTS
Image hash:     6de60c14be0f (Ubuntu 20.04 LTS)
CPU(s):         2
Load:           0.24 0.16 0.10
Disk usage:     2.3GiB out of 20.3GiB
Memory usage:   273.4MiB out of 7.8GiB
Mounts:         --

With this, I'm getting some errors on the LFD259/SOLUTIONS/s_02/k8scp.sh script. I've been executing the script line by line and the first errors come up here.

# Install the containerd software
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
$ sudo apt-get update
$ sudo apt-get install containerd.io -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package containerd.io
E: Couldn't find any package by glob 'containerd.io'
E: Couldn't find any package by regex 'containerd.io'

I got around this by running

$ sudo apt-get install containerd -y

but then...

ubuntu@cp:~$ sudo crictl config --set runtime-endpoint=unix:///run/containerd/containerd.sock --set image-endpoint=unix:///run/containerd/containerd.sock
/usr/local/bin/crictl: 1: Syntax error: end of file unexpected (expecting ")")
ubuntu@cp:~$ sudo kubeadm init --pod-network-cidr=192.168.0.0/16 | sudo tee /var/log/kubeinit.log

[init] Using Kubernetes version: v1.27.3
[preflight] Running pre-flight checks
error execution phase preflight: [preflight] Some fatal errors occurred:
    [ERROR CRI]: container runtime is not running: output: , error: executable file not found in $PATH
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher

Can somebody please help me troubleshoot this?

Answers

  • chrispokorni
    chrispokorni Posts: 2,372

    Hi @johannespn,

    I remember some strange behaviors reported a while back on environments provisioned with multipass. You may find some tips in those earlier posts.
    One thing I'd recommend however, to not assign 192.168.x.y IP addresses to your VMs, because that very same private network will be used for the application pods network layer, and such overlaps will cause routing conflicts in your cluster.

    I just ran the installation steps, and it seems that the recommended containerd.io package from Docker repo installs just fine. It is the most up to date package, as opposed to the containerd package downloaded from Ubuntu repo, that may be older. On M1 you may run into issues with some container images not supporting the chipset, so you'd need to find alternate images built specifically for the ARM architecture.

    Regards,
    -Chris

  • johannespn
    johannespn Posts: 3
    edited June 2023

    Hi and thanks a lot, I solved by running my cluster on AWS instead. The costs are quite cheap :)

  • Hi,
    I was having the same issue with installation today. I've modified the script slightly so now it runs on arm64 architecture without any errors.
    https://gist.github.com/kindejak/a16ee99e92e8e98c265f5256f6902f58

    #!/bin/bash
    # ###############################################################
    # NOTE: This script was slightly edited by Jakub Kindermann on 16/11/2023 to run the script on arm64-linux architecture 
    ################# LFD459:1.25.1 s_02/k8scp.sh ################
    # The code herein is: Copyright the Linux Foundation, 2022
    #
    # This Copyright is retained for the purpose of protecting free
    # redistribution of source.
    #
    #     URL:    https://training.linuxfoundation.org
    #     email:  info@linuxfoundation.org
    #
    # This code is distributed under Version 2 of the GNU General Public
    # License, which you should have received with the source.
    #Version 1.26.1
    #
    # This script is intended to be run on an Ubuntu 20.04,
    # 2cpu, 8G.
    # By Tim Serewicz, 05/2022 GPL
    
    # Note there is a lot of software downloaded, which may require
    # some troubleshooting if any of the sites updates their code,
    # which should be expected
    
    
    # Check to see if the script has been run before. Exit out if so.
    FILE=/k8scp_run
    if [ -f "$FILE" ]; then
        echo "WARNING!"
        echo "$FILE exists. Script has already been run on control plane."
        echo
        exit 1
    else
        echo "$FILE does not exist. Running  script"
    fi
    
    
    # Create a file when this script is started to keep it from running
    # twice on same node
    sudo touch /k8scp_run
    
    # Update the system
    sudo apt-get update ; sudo apt-get upgrade -y
    
    # Install necessary software
    sudo apt-get install curl apt-transport-https vim git wget gnupg2 software-properties-common apt-transport-https ca-certificates -y
    
    # Add repo for Kubernetes
    curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
    echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
    
    # Install the Kubernetes software, and lock the version
    sudo apt-get update
    sudo apt-get -y install kubelet=1.28.1-00 kubeadm=1.28.1-00 kubectl=1.28.1-00
    sudo apt-mark hold kubelet kubeadm kubectl
    
    # Ensure Kubelet is running
    sudo systemctl enable --now kubelet
    
    # Disable swap just in case
    sudo swapoff -a
    
    # Ensure Kernel has modules
    sudo modprobe overlay
    sudo modprobe br_netfilter
    
    # Update networking to allow traffic
    cat <<EOF | sudo tee /etc/sysctl.d/kubernetes.conf
    net.bridge.bridge-nf-call-ip6tables = 1
    net.bridge.bridge-nf-call-iptables = 1
    net.ipv4.ip_forward = 1
    EOF
    
    sudo sysctl --system
    
    # Configure containerd settings
    cat <<EOF | sudo tee /etc/modules-load.d/containerd.conf
    overlay
    br_netfilter
    EOF
    
    sudo sysctl --system
    
    
    export CLI_ARCH=amd64
    
    # Ensure correct architecture
    if [ "$(uname -m)" = "aarch64" ]; then CLI_ARCH=arm64; fi
    
    
    # Install the containerd software
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    sudo add-apt-repository "deb [arch=${CLI_ARCH}] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
    sudo apt-get update
    sudo apt-get install containerd.io -y
    
    # Configure containerd and restart
    sudo mkdir -p /etc/containerd
    containerd config default | sudo tee /etc/containerd/config.toml
    sudo sed -e 's/SystemdCgroup = false/SystemdCgroup = true/g' -i /etc/containerd/config.toml
    sudo systemctl restart containerd
    sudo systemctl enable containerd
    
    
    #  Create the config file so no more errors
    # Install and configure crictl
    export VER="v1.26.0"
    
    wget https://github.com/kubernetes-sigs/cri-tools/releases/download/$VER/crictl-$VER-linux-$CLI_ARCH.tar.gz
    
    tar zxvf crictl-$VER-linux-$CLI_ARCH.tar.gz
    
    sudo mv crictl /usr/local/bin
    
    # Set the endpoints to avoid the deprecation error
    sudo crictl config --set \
    runtime-endpoint=unix:///run/containerd/containerd.sock \
    --set image-endpoint=unix:///run/containerd/containerd.sock
    
    # Configure the cluster
    sudo kubeadm init --pod-network-cidr=192.168.0.0/16 | sudo tee /var/log/kubeinit.log
    
    # Configure the non-root user to use kubectl
    mkdir -p $HOME/.kube
    sudo cp -f /etc/kubernetes/admin.conf $HOME/.kube/config
    sudo chown $(id -u):$(id -g) $HOME/.kube/config
    
    # Use Cilium as the network plugin
    # Install the CLI first
    export CILIUM_CLI_VERSION=$(curl -s https://raw.githubusercontent.com/cilium/cilium-cli/master/stable.txt)
    curl -L --fail --remote-name-all https://github.com/cilium/cilium-cli/releases/download/${CILIUM_CLI_VERSION}/cilium-linux-${CLI_ARCH}.tar.gz{,.sha256sum}
    
    # Make sure download worked
    sha256sum --check cilium-linux-${CLI_ARCH}.tar.gz.sha256sum
    
    # Move binary to correct location and remove tarball
    sudo tar xzvfC cilium-linux-${CLI_ARCH}.tar.gz /usr/local/bin
    rm cilium-linux-${CLI_ARCH}.tar.gz{,.sha256sum}
    
    # Now that binary is in place, install network plugin
    echo '********************************************************'
    echo '********************************************************'
    echo
    echo Installing Cilium, this may take a bit...
    echo
    echo '********************************************************'
    echo '********************************************************'
    echo
    
    cilium install
    
    echo
    sleep 3
    echo Cilium install finished. Continuing with script.
    echo
    
    
    # Add Helm to make our life easier
    wget https://get.helm.sh/helm-v3.11.1-linux-${CLI_ARCH}.tar.gz
    tar -xf helm-v3.11.1-linux-amd64.tar.gz
    sudo cp linux-amd64/helm /usr/local/bin/
    
    sleep 15
    # Output the state of the cluster
    kubectl get node
    
    # Ready to continue
    sleep 3
    echo
    echo
    echo '***************************'
    echo
    echo "Continue to the next step"
    echo
    echo '***************************'
    echo
    

Categories

Upcoming Training