Installing Kubernetes manually

Procedure
  1. If you use proxy servers for the Internet connectivity, ensure that the following entries are available in the /etc/profile file:
    export http_proxy=<IP address of the proxy server and port number>
    export https_proxy=<IP address of the proxy server and port number>
    export no_proxy=<IP address of the NPS host>,localhost,XXX.X.X.X,XX.XX.X.X/XX,XX.XX.X.X/XX,<hostname>
    export KUBECONFIG=/etc/kubernetes/admin.conf
  2. Navigate to the Kubernetes local repo using the following command:
    cd <directory_path>/nps2/install/utils/kubernetes_repo

    directory_path: The path where the untar operation of nps.tar.gz is done.

  3. To install Kubernetes, execute the following command:
    yum install *.rpm -y
  4. To disable the swap partitions and modify the /etc/fstab file for persistence, execute the following commands:
    swapoff –a
    sed -i '/swap/s/^/#/g' /etc/fstabfstab
  5. To add the NPS VM IP for firewalld and reload, execute the following commands:
    firewall-cmd --permanent --add-source=<nps_vm_ip>
    firewall-cmd --reload
  6. To stop and disable firewall daemon, execute the following commands:
    systemctl disable firewalld
    systemctl stop firewalld
  7. To enable traffic forwarding, execute the following commands:
    echo "net.bridge.bridge-nf-call-iptables=1" > /etc/sysctl.d/k8s.conf; sysctl --system
  8. To create the required folders and mark the labels for SELinux, execute the following commands:
    setenforce 0
    sed -i 's/enforcing/permissive/g' /etc/selinux/config
    mkdir -p /var/lib/etcd
    chcon -R -t container_file_t /var/lib/etcd
    mkdir -p /etc/kubernetes
    chcon -R -t container_file_t /etc/kubernetes
    mkdir -p /var/nps
    chcon -R -t container_file_t /var/nps
  9. After Kubernetes is successfully installed, the Kubernetes cluster must be initialized. To initialize the Kubernetes cluster, perform the following steps:
    1. To enable and start the kubelet daemon, execute the following commands:
      systemctl enable kubelet
      systemctl restart kubelet
    2. To initialize the cluster, execute the following command:
      kubeadm init --kubernetes-version=1.18.8
    3. After the initialization is successfully completed, to copy the config file, execute the following commands:
      mkdir -p /root/.kube
      cp /etc/kubernetes/admin.conf /root/.kube/config
      chown 666 /root/.kube/config
  10. To set up the container networking, execute the following commands:
    kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$
    (kubectl version | base64 | tr -d '\n')&env.IPALLOC_RANGE=<ipalloc_range_cidr>"
  11. By default, the Kubernetes cluster is set up as a master. This configuration does not allow any functional containers to be scheduled on the master node. To convert this node to a single node cluster, execute the following command:
    kubectl taint nodes --all node-role.kubernetes.io/master-
  12. To create the required folders for NPS toolkit and copy the Kubernetes configuration file, execute the following commands:
    mkdir -p /var/nps/platform/api/ssl/certs 
    mkdir -p /var/nps/platform/api/ssl/private
    cp /root/.kube/config /var/nps/platform/api/ssl
    chmod 444 /var/nps/platform/api/ssl/config
    NOTE:

    If you want to clean up the Kubernetes installation, execute the following commands:

    kubeadm reset –f
    systemctl disable kubelet
    systemctl stop kubelet
    rm –rf /etc/kubernetes /var/lib/etcd /root/.kube /var/nps/platform/api/ssl/config
    rpm -ev kubeadm kubelet kubectl kubernetes-cni