Rancher v2.6.0 单节点安装部署记录

1. 环境准备

  • 安装 Docker
    # 查看已安装 docker
    yum list installed | grep docker
    # 卸载
    yum remove -y \
    containerd.io.x86_64 \
    docker-ce.x86_64 \
    docker-ce-cli.x86_64 \
    docker-ce-rootless-extras.x86_64 \
    docker-scan-plugin.x86_64
    
    # 通过脚本安装
    curl https://releases.rancher.com/install-docker/20.10.sh | sh
    
  • 关闭防火墙 firewalld
  • 关闭 SELinux

2. 安装 Rancher

  • 启动 Rancher 服务

    docker run -d --restart=unless-stopped \
      -p 80:80 -p 443:443 \
      --privileged \
      rancher/rancher:v2.6.0
    
  • 查看安装过程日志

    docker ps | grep rancher | awk '{print $1}' | xargs docker logs -f
    
  • 日志中有打印初始密码

    2021/09/28 10:10:30 [INFO] -----------------------------------------
    2021/09/28 10:10:30 [INFO] Welcome to Rancher
    2021/09/28 10:10:30 [INFO] A bootstrap password has been generated for your admin user.
    2021/09/28 10:10:30 [INFO]
    2021/09/28 10:10:30 [INFO] Bootstrap Password: c66frm6dtlls945z4fw29kb9xkz66qxdrbbdxfpqghnpcp7c7pjkgq
    2021/09/28 10:10:30 [INFO]
    2021/09/28 10:10:30 [INFO] Use https://172.17.0.2/dashboard/?setup=c66frm6dtlls945z4fw29kb9xkz66qxdrbbdxfpqghnpcp7c7pjkgq to complete setup in the UI
    2021/09/28 10:10:30 [INFO] -----------------------------------------
    
  • 或者安装完成后筛选过滤该密码

    docker logs  container-id  2>&1 | grep "Bootstrap Password:"
    
  • 打开浏览器 http://192.168.1.10 输入初始密码
    Rancher v2.6.0 单节点安装部署记录_第1张图片

  • 设置新密码
    Rancher v2.6.0 单节点安装部署记录_第2张图片

  • 创建集群
    Rancher v2.6.0 单节点安装部署记录_第3张图片

  • 选择自定义集群
    Rancher v2.6.0 单节点安装部署记录_第4张图片

  • 参数保持默认即可
    Rancher v2.6.0 单节点安装部署记录_第5张图片

  • 勾选全部角色,复制命令
    Rancher v2.6.0 单节点安装部署记录_第6张图片

  • 执行加入节点命令

    sudo docker run -d --privileged --restart=unless-stopped --net=host \
      -v /etc/kubernetes:/etc/kubernetes \
      -v /var/run:/var/run  rancher/rancher-agent:v2.6.0 \
      --server https://192.168.1.10:443 \
      --token d7ck5vm5lshgm98wzvznbsfbnrtqmgnl6g2sxnk85ll5psw7xs7vgg 
      --ca-checksum 413df4f04a0f00ffaa9b445431e76da26dbd678c21b4d5111cbedbbb37d14588 \
      --etcd --controlplane --worker
    
  • 等待时发现有报错
    Rancher v2.6.0 单节点安装部署记录_第7张图片

  • 查看 etcd 日志,可能是网络不好,耐心等待

    docker logs -f etcd
    
  • 一段时间后所有服务均正常,至此安装结束
    Rancher v2.6.0 单节点安装部署记录_第8张图片


3. 卸载 Rancher

  • 删除 Rancher 并清理
# 删除容器
docker rm -f $(sudo docker ps -aq);
# 删除卷
docker volume rm $(sudo docker volume ls -q);
# 卸载 kubelet 挂载目录
for m in $(sudo tac /proc/mounts | sudo awk '{print $2}' | sudo grep /var/lib/kubelet);do
sudo umount $m||true
done
# 卸载 rancher 挂载目录
for m in $(sudo tac /proc/mounts | sudo awk '{print $2}' | sudo grep /var/lib/rancher);do
sudo umount $m||true
done
# 删除相关目录
rm -rf /etc/cni \
       /etc/kubernetes \
       /opt/cni \
       /opt/rke \
       /run/secrets/kubernetes.io \
       /run/calico \
       /run/flannel \
       /var/lib/calico \
       /var/lib/etcd \
       /var/lib/cni \
       /var/lib/kubelet \
       /var/lib/rancher \
       /var/log/containers \
       /var/log/pods \
       /var/run/calico

rm -f /var/lib/containerd/io.containerd.metadata.v1.bolt/meta.db
sudo systemctl restart containerd
sudo systemctl restart docker

你可能感兴趣的:(Rancher,docker,运维,jenkins)