初始化系统(脚本)
安装docker
准备好安装包:
1.下载二进制安装包
wget https://download.docker.com/linux/static/stable/x86_64/docker-18.06.3-ce.tgz
2.解压并安装
tar zxvf docker-18.06.3-ce.tgz
cp docker/* /usr/bin/
### 注册为服务
[root@xkdl<a href="http://yw8.tech/tag/k8s/" title="查看与 k8s 相关的文章" target="_blank">k8s</a>06 ~]# cat /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
3.优化设置
<br /># 设置开机启动
echo "10.4.31.153 harbor.xikang.com" >> /etc/hosts
mkdir -p /etc/docker
cat > /etc/docker/daemon.json <<EOF
{
"registry-mirrors": ["https://kvvfjpdn.mirror.aliyuncs.com"],
"insecure-registries": ["harbor.xikang.com"],
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2"
}
EOF
systemctl daemon-reload
systemctl enable docker
systemctl restart docker
service docker stop
mv /var/lib/docker/ /data/docker
ln -s /data/docker/ /var/lib/docker
service docker start
docker -v
安装K8S
下载离线包,并拷贝到各个节点上。
wget https://sealyun.oss-cn-beijing.aliyuncs.com/6300ecea5ab9621-14-1/kube1.14.1.tar.gz
下载sealos
wget https://github.com/fanux/sealos/releases/download/v2.0.7/sealos && chmod +x sealos && mv sealos /usr/bin
安装k8s集群
sealos init --master 10.3.201.108 --master 10.3.201.109 --master 10.3.201.110 --node 10.3.201.111 --node 10.3.201.112 --user root --passwd xikang@2018 --version v1.14.1 --pkg-url /root/kube1.14.1.tar.gz
清理k8s集群
sealos clean --master 10.3.201.108 --master 10.3.201.109 --master 10.3.201.110 --node 10.3.201.111 --node 10.3.201.112 --user root --passwd xikang@2018
加入rancher纳管注意:
由于无DNS,需要手工添加hosts到Pod,rancherweb添加集群后,执行
kubectl -n cattle-system patch deployments cattle-cluster-agent --patch '{
"spec": {
"template": {
"spec": {
"hostAliases": [
{
"hostnames":
[
"dlrc.xikang.com"
],
"ip": "10.3.31.101"
}
]
}
}
}
}'
kubectl -n cattle-system \
patch daemonsets cattle-node-agent --patch '{
"spec": {
"template": {
"spec": {
"hostAliases": [
{
"hostnames":
[
"dlrc.xikang.com"
],
"ip": "10.3.31.101"
}
]
}
}
}
}'
添加节点
sealos join --master 10.3.201.108 --master 10.3.201.109 --master 10.3.201.110 --vip 10.103.97.2 --node 10.3.201.113 --user root --passwd xikang@2018 --pkg-url /root/kube1.14.1.tar.gz
sealos clean --node 10.3.201.113 --user root --passwd xikang@2018
安装 Kuboard
kubectl apply -f https://kuboard.cn/install-script/kuboard.yaml
http://任意一个Worker节点的IP地址:32567/
获取token
kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep kuboard-user | awk '{print $1}')
「真诚赞赏,手留余香」
请我喝杯咖啡?
使用微信扫描二维码完成支付
