Skip to main content

Pre-requisites for Kubernetes Labs

Updated Jul 07, 2022 ·

Install Kubernetes on Ubuntu​

This section discuss how to install Kubernetes on virtual machines and/or bare metal servers.

System Requirements:

  • Linux OS
  • 2 CPUs
  • 2 GB RAM
  • Disable Swap

Container Runtime Requirements:

  • Compatible with CRI (Container Runtime Interface)
  • We can also use Docker

Networking Requirements:

  • Connectivity between all nodes

Note that we have to install these packages on ALL the nodes that will be part of the Kubernetes cluster.

  • kubelet
  • kubeadm
  • kubectl
  • container runtime (docker)

Begin by installing the packages, which includes adding the signing key and the repository.

curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add
sudo bash -c 'cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
EOF'

We can inspect the versions available in the repository using apt-cache.

sudo apt-get update
apt-cache policy kubelet | head -20
apt-cache policy docker.io | head -20

Install the Kubernetes tools.

sudo apt-get install -y kubeadm kubelet kubectl docker.io
sudo apt-mark hold kubeadm kubelet kubectl docker.io

Disable the swap.

swapoff -a

Check the status of the kubelet and docker. Notice that kubelet will show an "activating" status. This will stay in this status until a work is assigned to the kubelet.

sudo systemctl status kubelet
sudo systemctl status docker

Install CLI Tools​

When you click the links, it should bring you to the official installation pages. Note that only the kubectl is necessary for running Kubernetes locally but I recommend installing the other CLI tools too.

  • aws cli v2 - used by eksctl to grab authentication token
  • eksctl - setup and operation of EKS cluster
  • kubectl - interaction with K8S API server

If you're using WSL running Ubuntu in a Windows laptop, you may simply use these commands:

  • AWS CLI

    # aws cli
    curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
    sudo apt install unzip
    unzip awscliv2.zip
    sudo ./aws/install

    To verify the AWS CLI version:

    aws --version
  • eksctl

    curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
    sudo mv /tmp/eksctl /usr/local/bin

    To verify the eksctl version:

    eksctl version
  • kubectl

    curl https://storage.googleapis.com/kubernetes-release/release/stable.txt > ./stable.txt
    export KUBECTL_VERSION=$(cat stable.txt)
    curl -LO https://storage.googleapis.com/kubernetes-release/release/$KUBECTL_VERSION/bin/linux/amd64/kubectl
    chmod +x ./kubectl
    sudo mv ./kubectl /usr/local/bin/kubectl
    mkdir -p ~/.kube
    ln -sf "/mnt/c/users/$USER/.kube/config" ~/.kube/config
    rm ./stable.txt

    To verify the kubectl version:

    kubectl version --output=json

We can also enable eksctl bash completion:

eksctl completion bash >> ~/.bash_completion
. /etc/profile.d/bash_completion.sh
. ~/.bash_completion

Install Helm​

Helm is the Kubernetes package manager which helps us manage Kubernetes applications. To learn more, visit the official Helm website.

Helm can be installed in two ways:

  • install it from a source, or
  • install it from pre-built binary releases

Detailed setup instructions for different OS can be found in the Installing Helm page.

If you're using WSL running Ubuntu in a Windows laptop, you may simply use these commands:

curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh