Kubernetes Installation Guide - YuntechNet/Kubernetes-Deployment GitHub Wiki

Version

Kubernetes 1.14

Environment

Version
Storage 10GB
Memory 4GB
OS ubuntu 18.04 LTS
Docker 18.09.7

Before Begin

If the hostname requires to change, please follow the following instruction.

  1. Use hostnamectl to replace your hostname.
    sudo hostnamectl set-hostname k8s-hostname
    (* Replace k8s-hostname with the hostname you want)
  2. After changing the hostname, open /etc/cloud/cloud.cfg and set preserve_hostname to true .
    preserve_hostname: true

Installation

Disable swap

  1. Turn off the swap file by running the following command: sudo swapoff -a
  2. Disable the swap file in '/etc/fstab'. In '/etc/fstab' file, please comment 'swapfile'. (have a '#' in front of '/swapfile')
  3. Remove '/swapfile' if exist. If exist, running the following command: sudo rm -f /swapfile

Install Docker

  1. Install Docker
    sudo apt-get install -y docker.io
  2. Start the service
    sudo systemctl start docker
  3. Enable the service
    sudo systemctl enable docker
  4. Set the cgroup driver to systemd
  5. open /etc/docker/daemon.json and paste the following json.
    {
        "exec-opt": ["native.cgroupdriver=systemd"]
    }
  6. Reload the daemon
    sudo systemctl daemon-reload
  7. Restart the service
    sudo systemctl restart docker

Installing kubeadm, kubelet, kubectl

  1. Update list of available packages
    sudo apt-get update
  2. Install apt-transport-https curl
    sudo apt-get install apt-transport-https curl
  3. Add key
    curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add
  4. Add the repository of Kubernetes
    cat << EOF > /etc/apt/source.list.d/kubernetes.list deb https://apt.kubernetes.io/kubernetes-xenial main EOF
  5. Update list of available packages
    sudo apt-get update
  6. Install kubeadm, kubelet, kubectl
    sudo apt-get install kubelet kubeadm kubectl -y
  7. Keep the current version and keep not updating
    sudo apt-mark hold kubelet kubeadm kubectl
⚠️ **GitHub.com Fallback** ⚠️