官网文档
https://rancher.com/docs/rancher/v1.6/zh/installing-rancher/installing-server/#multi-nodes
术语
实验环境3台机器
172.17.3.164 dev1
172.17.3.168 dev2
172.17.3.169 dev3
既然需要HA,那么SLB需要解析到各个node上的8080
rancher有不同的安装方式,单节点的多节点的,对于HA on docker有2种
rancher 安装在k8s 上
https://rancher.com/docs/rancher/v2.5/en/installation/install-rancher-on-k8s/
rancher 安装在docker 上
https://rancher.com/docs/rancher/v2.5/en/installation/other-installation-methods/single-node-docker/
HA部署需求
3个节点安装docker,rundeck推送下
curl https://get.docker.com | sh
docker 各个work node需要时间同步,ntpdate下
ntpdate 0.pool.ntp.org
dev1 上安装helm3
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 chmod 700 get_helm.sh ./get_helm.sh
一条命令
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 chmod 700 get_helm.sh ./get_helm.sh
添加helm repo
helm repo add rancher-latest https://releases.rancher.com/server-charts/latest
搜索下包验证安装,看起来没问题
helm search repo --versions
fetch最新版本
helm fetch rancher-latest/rancher
or fetch指定版本
helm fetch rancher-stable/rancher --version=v2.0.0
安装rke,其实就是一个可执行文件,下载后改名丢%PATH目录
https://github.com/rancher/rke/releases
wget https://github.com/rancher/rke/releases/download/v1.2.8/rke_linux-amd64 mv rke_linux-amd64 rke chmod +x rke $PATH cp rke /usr/bin rke --version
安装kubectl
https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/
应该是3个node都要这个命令的,rundeck下发3台主机
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
校验下文件
curl -LO "https://dl.k8s.io/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256" echo "$(<kubectl.sha256) kubectl" | sha256sum --check
没问题就推送3台
安装kubectl
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl kubectl version --client
3台都应该返回kubect client信息就对了
安装包管理
cat <<EOF > /etc/yum.repos.d/kubernetes.repo [kubernetes] name=Kubernetes baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64 enabled=1 gpgcheck=1 repo_gpgcheck=1 gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg EOF yum install -y kubectl
配置kubectl的shell补全
yum install bash-completion -y echo "source <(kubectl completion bash)" >> ~/.bashrc
创建rancher用户
useradd rancher passwd rancher gpasswd -a rancher docker newgrp docker su rancher ssh-keygen -t rsa -P "" -f ~/.ssh/id_rsa_rancher cat ~/.ssh/id_rsa_rancher.pub >> ~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keys ssh-copy-id 172.17.3.164 ssh-copy-id 172.17.3.168 ssh-copy-id 172.17.3.168
ssh dev1 到dev2 正常
rancher 集群高可用 1 - 环境配置 ntpd ssh helm kubectl等
原文:https://blog.51cto.com/u_433266/2959418