Guides

Install Kubernetes - Ubuntu

All the packages introduced below can be download from the link:

https://pan.baidu.com/s/1lWLyyT1jAbADGuxEG3m4gA
Password: ge4d

Environment Requirement

  • Use the IOS installation system from the link above.

    Path: iManager部署包/软件工具包/OS/OS-ISO/ubuntu-18.04.2-live-server-amd64.iso

  • When installing the system, all the partitioned file systems select ext4, except swap partition. The device select LVM. The root(/) partition must occupies 90% or more resources of the total disk.
  • System Requirements:

    • Number of processors: 4 cores+
    • Memory: 8 GB+

Installation Package Preparation

Path: iManager部署包/软件工具包/Kubernetes离线安装包/kubernetes-1.14.1-ubuntu-18.04-deploy.zip

Install Kubernetes Master Node

Unzip kubernetes-1.14.1-ubuntu-18.04-deploy.zip, copy the offline-kubernetes-1.14-ubuntu.tar.gz package to any directory of the machine.

Unzip:

tar -zxf offline-kubernetes-1.14-ubuntu.tar.gz

Enter the directory that you unzipped:

cd offline-kubernetes-1.14-ubuntu

Execute the following command with root permission:

chmod +x install.sh && ./install.sh master

Notes:

If you have multiple network cards on the machine, please assign one network card for Kubernetes, execute the command --apiserver-advertise-address IP(replace the IP in the command to the actual IP of network card). For instance, if the IP of network card is 172.16.16.9, the completely command should be chmod +x install.sh && ./install.sh --apiserver-advertise-address 172.16.16.9.

After installing, you can visit Kubernetes UI by the address http://IP:31234, please replace the IP by the actual IP.

It is ready to install and use iManager after installing the Kubernetes master node. By the increase of demands, add Kubernetes worker nodes anytime.

Install Kubernetes Worker Node(Optional)

If you need to install the Kubernetes worker node, please prepare another machine, the worker node can not be installed on the same machine of master node.

  1. Execute the command on the worker node to set the node name. If you have multiple nodes, you could set the names like node1, node2, node3…

    # Modify system configuration
    sed -i "s|preserve_hostname: false|preserve_hostname: true|g" /etc/cloud/cloud.cfg
    # Modify node name
    hostnamectl set-hostname node1
  2. Put the offline-kubernetes-1.14-ubuntu.tar.gz package in any directory of the Kubernetes machine and unzip:

    tar -zxvf offline-kubernetes-1.14-ubuntu.tar.gz
  3. Enter the directory that you unzipped:

    cd offline-kubernetes-1.14-ubuntu
  4. Execute the command on the Kubernetes master node to achieve the token:

    kubeadm token list
  5. Install worker node:

    chmod +x install.sh && ./install.sh join <master-ip>:6443 --token <kubernetes-token>

    Notes:

    • <master-ip> is the IP of master node.
    • <kubernetes-token> is the token achieved in step 5.
    • If you have multiple network cards on the machine, please assign one network card for Kubernetes, execute the command --apiserver-advertise-address IP(replace the IP in the command to the network card’s actual IP). For instance, if the IP of network card is 172.16.16.10, the completely command should be chmod +x install.sh && ./install.sh join <master‐ip>:6443 ‐‐token <kubernetes‐token> ‐‐apiserver‐advertise‐address 172.16.16.10.
  6. Execute the command in master node to verify if the worker node joined the cluster:

    kubectl get nodes

FAQ

  1. If you could not achieve the token from the master node, please execute the following command on the master node:

    kubeadm token create
  2. If the error in below occurs when installing the worker node, it means the token was expired, you need to create a new token in the master node by the command ‘Kubeadm token create’.

    Error:

    couldn't validate the identify of the API server: abort connection to API server after timeout of 5m0s
  3. If you want to remove the worker node from Kubernetes cluster, execute the command on the master node:

    kubectl delete node <nodeName>

    Notes:

    <nodeName> is the name of the worker node you would like to remove.

  4. Please execute the following command to reset the removed node.

    kubeadm reset
  5. If you want to rejoin the removed worker node in the Kubernetes cluster, please execute the command:

    kubeadm join <master-ip>:6443 --token <kubernetes-token> --discovery-token-unsafe-skip-ca-verification

    Notes:

    • <master-ip> is the IP of master node.
    • <kubernetes-token> is the token achieved by checking the master node.
  6. If you want to uninstall Kubernetes, please execute the command in the root directories(both master and worker nodes):

    chmod +x install.sh && ./install.sh down