快速安装高可用Kubernetes 集群
添加/删除节点
清理集群、备份与自动恢复等
OpenEBS, MinIO, Ingress, PostgreSQL, MySQL, Redis 等
用Dockerfile 构建分布式应用镜像,保存所有的依赖
发布分布式应用镜像到Docker Hub
融合多个应用构建专属的云平台
支持运行分布式应用程序
拥有完整的公共云功能,可以畅意运行
systemctl stop firewalld
systemctl disable firewalld
yum -y install iptables-services ipvsadm ; systemctl start iptables ; systemctl enable iptables ;iptables -F : service iptables save
#关闭selinux[所有节点都执行]
setenforce 0
vim /etc/selinux/config
#修改SELINUX=enforcing 为 SELINUX=disabled
hostnamectl set-hostname 主机名
cat > /etc/hosts <<EOF
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost,localdomain localhost6 localhost6.localdomain6
192.168.1.233 master-1
192.168.1.234 master-2
192.168.1.235 master-3
192.168.1.236 node-1
EOF
#选择一个节点作为服务端,剩下的作为客户端
master1为时间服务器的服务端
#其他的为时间服务器的客户端
1)配警k8s-master1
yum install chrony -y
vi /etc/chrony.conf
#修改三项
server 127.127.1.0 iburst
a11ow 10.1.0.0/24
local stratum 10
systemctl start chronyd
systemctl enable chronyd
ss -unlap | grep 323
配置其他节点
yum install chrony -y
vi /etc/chrony.conf
server 192.168.1.233 iburst
chronyc sources
chronyc -a makestep
swapoff -a
sed -ri 's/.*swap.*/#&/' /etc/fstab
swapoff -a
free -m
cat > kubernetes.conf <<EOF
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
net.ipv4.tcp_tw_recycle = 0
fs.inotify.max_user_instances = 8192
fs.inotify.max_user_watches = 1048576
fs.file-max = 52706963
fs.nr_open = 52706963
net.ipv6.conf.all.disable_ipv6 = 1
EOF
cp kubernetes.conf /etc/sysct1.d/
sysctl -p /etc/sysctl.d/kubernetes.conf
yum -y upgrade systemd
systemctl stop postfix && systemctl disable postfix
mkdir /var/log/journal
mkdir /etc/systemd/journald.conf.d
cat > /etc/systemd/journald.conf.d/99-prophet.conf <<EOF
[Journal]
#持久化保存到磁盘
Storage=persistent
#压缩历史日志
Compress=yes
SyncIntervalSec=5m
RateLimitInterval=30s
RateLimitBurst=1000
#最大占用空间 10G
SystemMaxUse=10G
#单日志文件最大 200M
SystemMaxFileSize=200M
#日志保存时间 2 周l
MaxRetentionSec=2week
#不将日志转发到 syslog
ForwardToSyslog=no
EOF
systemctl restart systemd-journald
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
yum --enablerepo=elrepo-kernel install -y kernel-lt
grep initrd16 /boot/grub2/grub.cfg
grub2-set-default 0
reboot
modprobe br_netfilter
cat > /etc/sysconfig/modules/ipvs.modules <<EOF
#!/bin/bash
modprobe -- ip_vs
modprobe -- ip_vs_rr
modprobe -- ip_vs_wrr
modprobe -- ip_vs_sh
modprobe -- nf_conntrack
EOF
chmod 755 /etc/sysconfig/modules/ipvs.modules && bash /etc/sysconfig/modules/ipvs.modules && lsmod |grep -e ip_vs -e nf_conntrack
yum -y install lrzsz
modprobe br_netfilter
cat > /etc/sysconfig/modules/ipvs.modules <<EOF
#!/bin/bash
modprobe -- ip_vs
modprobe -- ip_vs_rr
modprobe -- ip_vs_wrr
modprobe -- ip_vs_sh
modprobe -- nf_conntrack
EOF
chmod 755 /etc/sysconfig/modules/ipvs.modules && bash /etc/sysconfig/modules/ipvs.modules && lsmod |grep -e ip_vs -e nf_conntrack
yum -y install lrzsz
wget -c https://sealyun.oss-cn-beijing.aliyuncs.com/latest/sealoswget -c https://sealyunoss-cn-beijing.aliyuncs.com/05a3db657821277f5f3b92d834bbaf98-v1.22.0/kube1.22.0.tar.gz
tar zxvf sealos.tar.gz
chmod +x sealos && mv sealos /usr/bin
sealos init --passwd 'Hmop!QAZ' \
--master 192.168.1.233 --master 192.168.1.234 --master 192.168.1.235 \
--node 192.168.1.236 \
--pkg-url /root/kube1.22.0.tar.gz \
--version v1.22.0
kubectl apply -f https://addons.kuboard.cn/kuboard/kuboard-v3.yaml
# 您也可以使用下面的指令,唯一的区别是,该指令使用华为云的镜像仓库替代 docker hub 分发 Kuboard 所需要
kubectl apply -f https://addons.kuboard.cn/kuboard/kuboard-v3-swr.yaml
watch kubectl get pods -n kuboard
# 执行指今 watch kubectl get pods -n kuboard,等待 kuboard 名称空间中所有的 Pod 就绪,如下所示,# 如果结果中没有出现 kuboard-etcd-xxxxx 的容器,请查看 中关于 缺少 Master Role 的描述
定位异常命令
kubectl get pod -A 查看所有的pod
kubectl logs pod(NAME) -n 命名空间(NAMESPACE) 查看日志异常
kubectl describe nodes (node名称)
解决办法如下命令执行完毕即可。如果还是显示异常,使用K8S命令删除
systemctl stop containerd
systemctl stop kubelet
iptables --flush
iptables -tnat --flush
systemctl start kubelet
systemctl start containerd
注释掉/etc/containerd/config
当我们删除所有节点后再删除执行节点会导致整个K8S和sealos系统崩溃需要重新安装