github project link
https://github.com/fanux/sealos
Initialize master and worker nodes
Initialization script init.sh
#!/bin/bash # Execute on both master and worker nodes # Install docker # The reference documents are as follows # https://docs.docker.com/install/linux/docker-ce/centos/ # https://docs.docker.com/install/linux/linux-postinstall/ # Uninstall old version yum remove -y docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-selinux \ docker-engine-selinux \ docker-engine # Set up yum repository yum install -y yum-utils \ device-mapper-persistent-data \ lvm2 yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo # Install and start docker yum install -y docker-ce-18.09.7 docker-ce-cli-18.09.7 containerd.io systemctl enable docker systemctl start docker # Install NFS utils # nfs utils must be installed before nfs networked storage can be mounted yum install -y nfs-utils # Turn off firewall systemctl stop firewalld systemctl disable firewalld # Turn off SeLinux setenforce 0 sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config # Close swap swapoff -a yes | cp /etc/fstab /etc/fstab_bak cat /etc/fstab_bak |grep -v swap > /etc/fstab # Modify / etc/sysctl.conf # If configured, modify sed -i "s#^net.ipv4.ip_forward.*#net.ipv4.ip_forward=1#g" /etc/sysctl.conf sed -i "s#^net.bridge.bridge-nf-call-ip6tables.*#net.bridge.bridge-nf-call-ip6tables=1#g" /etc/sysctl.conf sed -i "s#^net.bridge.bridge-nf-call-iptables.*#net.bridge.bridge-nf-call-iptables=1#g" /etc/sysctl.conf # Maybe not, add echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf echo "net.bridge.bridge-nf-call-ip6tables = 1" >> /etc/sysctl.conf echo "net.bridge.bridge-nf-call-iptables = 1" >> /etc/sysctl.conf # Execute command to apply sysctl -p # Configure the yum source of K8S cat <<EOF > /etc/yum.repos.d/kubernetes.repo [kubernetes] name=Kubernetes baseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64 enabled=1 gpgcheck=0 repo_gpgcheck=0 gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg http://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg EOF # Uninstall old version yum remove -y kubelet kubeadm kubectl # Install kubelet, kubeadm, kubectl yum install -y kubelet-1.16.0 kubeadm-1.16.0 kubectl-1.16.0 # Modify docker Cgroup Driver to systemd # # In the file / usr/lib/systemd/system/docker.service, execstart = / usr / bin / docked - H FD: / / -- containerd = / run / containerd / containerd.sock # # Modify to execstart = / usr / bin / docked - H FD: / / -- contained = / run / contained / contained. Sock -- exec opt native. Cgroupdriver = SYSTEMd # If you do not modify it, you may encounter the following errors when adding worker nodes # [WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". # Please follow the guide at https://kubernetes.io/docs/setup/cri/ sed -i "s#^ExecStart=/usr/bin/dockerd.*#ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --exec-opt native.cgroupdriver=systemd#g" /usr/lib/systemd/system/docker.service # Set up docker image to improve the download speed and stability of docker image # If you visit https://hub.docker.io at a very stable speed, you can also skip this step curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io # Restart docker and start kubelet systemctl daemon-reload systemctl restart docker systemctl enable kubelet && systemctl start kubelet docker version
Sealos
# Download sealos wget https://github.com/fanux/sealos/releases/download/v2.0.7/sealos # Add execution permission and move sealos to / usr/bin chmod +x sealos && mv sealos /usr/bin
sealos options
--Master master server address list --Node node server address list --User server ssh user name --passwd server ssh user password --PKG URL offline package location can be placed in the local directory or an http server. sealos will wget to the installation target machine --Version kubernetes version
Initialize k8s HA cluster
sealos init --passwd YOUR_SERVER_PASSWD --master 172.31.194.114 --master 172.31.194.116 --master 172.31.194.115 \ --node 172.31.194.117 \ --pkg-url https://sealyun.oss-cn-beijing.aliyuncs.com/37374d999dbadb788ef0461844a70151-1.16.0/kube1.16.0.tar.gz \ --version v1.16.0
After execution, the last line of the shell output is as follows, indicating that the cluster deployment is successful
2019-11-07 17:30:20 [INFO] [github.com/fanux/sealos/install/print.go:25] sealos install success.
Let's get the state of the node
[root@master01 ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION master01 Ready master 11h v1.16.0 master02 Ready master 11h v1.16.0 master03 Ready master 11h v1.16.0 node01 Ready <none> 11h v1.16.0
# Get service [root@master01 ~]# kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 17h # By looking at the ipvs rules, we can see that requests sent to 10.96.0.1 are loaded to all master nodes. [root@master01 ~]# ipvsadm -Ln IP Virtual Server version 1.2.1 (size=4096) Prot LocalAddress:Port Scheduler Flags -> RemoteAddress:Port Forward Weight ActiveConn InActConn TCP 10.96.0.1:443 rr -> 172.31.194.114:6443 Masq 1 3 0 -> 172.31.194.115:6443 Masq 1 2 0 -> 172.31.194.116:6443 Masq 1 0 0