博客 > 术业专攻> 云计算> rancher> rancher-2.1.6的ha版本部署记录《一》 2019年08月29日 11:23:53
rancher2.1版本的功能介绍:https://www.cnrancher.com/docs/rancher/v2.x/cn/overview/feature/
本次部署所用机器均为CentOS Linux release 7.6.1810 (Core)
。
节点名称 | IP | 安装组件 |
---|---|---|
nginx | 192.168.10.2 | nginx |
node1 | 192.168.10.3 | etcd, docker, k8s |
node2 | 192.168.10.4 | etcd, docker, k8s |
node3 | 192.168.10.5 | etcd, docker, k8s |
harbor | 192.168.10.6 | harbor私服 |
因为软件版本可能中有变更,所以我把这次部署的包都放在百度网盘,下载之后部署,以保证部署过程的流畅。
文件下载 | 文件名称:rancher.tar | 文件大小:138M |
下载声明:本站文件大多来自于网络,仅供学习和研究使用,不得用于商业用途,如果有版权问题,请联系博主进行相关处理! | ||
下载地址:https://pan.baidu.com/s/1fBalGCouDxmiWK8RKHJAzA |
文中相关部署软件的命令,可做相对应的调整。
初始化部分,三台node机器都要操作。
systemctl stop firewalld
systemctl disable firewalld
$ sudo setenforce 0
$ grep SELINUX /etc/selinux/config
SELINUX=disabled
swapoff -a && sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
$ sudo hostnamectl set-hostname node1
$ sudo hostnamectl set-hostname node2
$ sudo hostnamectl set-hostname node3
$ cat > /etc/hosts << EOF
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.10.3 node1
192.168.10.4 node2
192.168.10.5 node3
EOF
echo -e "root soft nofile 65535\nroot hard nofile 65535\n* soft nofile 65535\n* hard nofile 65535\n" >> /etc/security/limits.conf
sed -i 's#4096#65535#g' /etc/security/limits.d/20-nproc.conf
cat >> /etc/sysctl.conf<
yum -y install wget ntpdate lrzsz curl yum-utils device-mapper-persistent-data lvm2 bash-completion && ntpdate -u cn.pool.ntp.org
groupadd docker
useradd rancher -G docker
echo "123456" | passwd --stdin rancher
在node1
服务器上执行下面命令:
su - rancher
ssh-keygen
ssh-copy-id rancher@192.168.10.3
ssh-copy-id rancher@192.168.10.4
ssh-copy-id rancher@192.168.10.5
需要在三台主机上一起安装docker。
rke工具要求docker版本为v17.03.2,请务必保持版本一致,否则后续安装会报错。
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
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 \
container*
export docker_version=17.03.2
version=$(yum list docker-ce.x86_64 --showduplicates | sort -r|grep ${docker_version}|awk '{print $2}')
yum -y install --setopt=obsoletes=0 docker-ce-${version} docker-ce-selinux-${version}
$ systemctl enable docker
$ systemctl start docker
$ systemctl status docker
cat > /etc/docker/daemon.json << EOF
{
"registry-mirrors": ["https://7bezldxe.mirror.aliyuncs.com/","https://kw88y6eh.mirror.aliyuncs.com"],
"insecure-registries":["192.168.10.6"],
"storage-driver": "overlay2",
"storage-opts": [
"overlay2.override_kernel_check=true"
]
}
EOF
registry-mirrors
:表示公网的加速器地址,可设置多个,地址需要添加协议头(https或者http)
。insecure-registries
:表示内网的私服地址,地址不能添加协议头(http)
。storage-driver
:表示使用OverlayFS的overlay2存储驱动。
systemctl daemon-reload
systemctl restart docker
在192.168.10.2
服务器上安装nginx,用于rancher-server负载均衡。
安装nginx:
sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum install nginx -y
sudo systemctl enable nginx.service
修改配置文件:vi /etc/nginx/nginx.conf
user nginx;
worker_processes 4;
worker_rlimit_nofile 40000;
events {
worker_connections 8192;
}
http {
# Gzip Settings
gzip on;
gzip_disable "msie6";
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_vary on;
gzip_static on;
gzip_proxied any;
gzip_min_length 0;
gzip_comp_level 8;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/xml application/xml application/atom+xml application/rss+xml application/xhtml+xml image/svg+xml application/font-woff text/javascript application/javascript application/x-javascript text/x-json application/json application/x-web-app-manifest+json text/css text/plain text/x-component font/opentype application/x-font-ttf application/vnd.ms-fontobjectfont/woff2 image/x-icon image/png image/jpeg;
server {
listen 80;
return 301 https://$host$request_uri;
}
}
stream {
upstream rancher_servers {
least_conn;
server 192.168.10.3:443 max_fails=3 fail_timeout=5s;
server 192.168.10.4:443 max_fails=3 fail_timeout=5s;
server 192.168.10.5:443 max_fails=3 fail_timeout=5s;
}
server {
listen 443;
proxy_pass rancher_servers;
}
}
启动nginx:
sudo systemctl restart nginx.service
以下操作只需在192.168.10.3
这一台上操作即可。
su root
wget https://www.cnrancher.com/download/rke/rke_linux-amd64
chmod +x rke_linux-amd64
mv rke_linux-amd64 /usr/bin/rke
wget https://www.cnrancher.com/download/kubectl/kubectl_amd64-linux
chmod +x kubectl_amd64-linux
mv kubectl_amd64-linux /usr/bin/kubectl
wget https://www.cnrancher.com/download/helm/helm-linux.tar.gz
tar zxvf helm-linux.tar.gz
mv linux-amd64/helm /usr/bin/helm
mv linux-amd64/tiller /usr/bin/tiller
rm -rf helm-linux.tar.gz linux-amd64/
其它工具下载地址:https://www.cnrancher.com/docs/rancher/v2.x/cn/install-prepare/download/
/usr/local/bin
下即可。之前原本完整的文章,经过修改竟然无法完整发布了,因此不得不将一篇文章拆分成两篇,以上算是整个部署的准备工作,下一篇进入正式的部署。
可以直接点击下边链接进行跳转。
↓
↓
↓
1,安装k8s 1、切换到rancher用户 su - rancher 注意:必须使用普通用户操作,否则后边的操作会报下边的错: Please check if the configured user can execute `docker ps` on the node, and if the SSH server version is at least version 6.7 or higher. If you
© 2018 www.qingketang.net 鄂ICP备18027844号-1
武汉快勤科技有限公司 13554402156 武汉市东湖新技术开发区关山二路特一号国际企业中心6幢4层7号
扫码关注,全站教程免费播放
订单金额:
支付金额:
支付方式: