[原]CentOS7安装Rancher2.1并部署kubernetes (一)---部署Rancher
################## Rancher v2.1.7 + Kubernetes 1.13.4 ################
####################### 以下为声明 #####################
此文档是在两台机上进行的实践,kubernetes处于不断开发阶段
不能保证每个步骤都能准确到同步开发进度,所以如果安装部署过程中有问题请尽量google
按照下面步骤能得到什么?
1.两台主机之一会作为Rancher的server,另外一台作为Rancher Server的node节点添加进Rancher Server,得到安装好的Rancher,并以Rancher UI进行呈现
2.作为node节点的主机会被安装kubernetes,并以kubernetes dashboard的方式呈现
3.将建立一个登陆账号登陆kubernetes dashboard 并解决kubernetes dashboard token超时的问题
4.部署测试pod 和 container,(以nginx为例)
5,认识Rancher和kubernetes,知道其长什么样子能做什么工作。
6.此文不做生产环境使用,如果使用到生产环境,责任自负。只作为学习Rancher和kubernetes使用,由于时间关系,文中有错误的地方欢迎指正交流。
7.此文分为三部分:
CentOS7安装Rancher2.0并部署kubernetes (一)---部署Rancher
CentOS7安装Rancher2.0并部署kubernetes (二)---部署kubernetes
CentOS7安装Rancher2.0并部署kubernetes (三)---解决登录kubernets超时和部署测试Pod和Containter[nginx为例]
############################## 下面为文档正文 #####################################
setenforce 0 sudo sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config systemctl stop firewalld.service && systemctl disable firewalld.service
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime sudo echo 'LANG="en_US.UTF-8"' >> /etc/profile;source /etc/profile
[root@rancher ~]# cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core) [root@node01 ~]# cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core)
[root@rancher ~]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.0.166 rancher 192.168.0.167 node01 --- [root@node01 ~]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.0.166 rancher 192.168.0.167 node01
driftfile /var/lib/chrony/drift makestep 1.0 3 rtcsync allow 192.168.0.167/16 local stratum 8 logdir /var/log/chrony
server rancher iburst driftfile /var/lib/chrony/drift makestep 1.0 3 rtcsync allow 192.168.0.166/24 local stratum 9 logdir /var/log/chrony
[root@rancher ~]# chronyc sources -v 210 Number of sources = 0 .-- Source mode '^' = server, '=' = peer, '#' = local clock. / .- Source state '*' = current synced, '+' = combined , '-' = not combined, | / '?' = unreachable, 'x' = time may be in error, '~' = time too variable. || .- xxxx [ yyyy ] +/- zzzz || Reachability register (octal) -. | xxxx = adjusted offset, || Log2(Polling interval) --. | | yyyy = measured offset, || \ | | zzzz = estimated error. || | | \ MS Name/IP address Stratum Poll Reach LastRx Last sample ===============================================================================
[root@node01 ~]# chronyc sources -v 210 Number of sources = 1 .-- Source mode '^' = server, '=' = peer, '#' = local clock. / .- Source state '*' = current synced, '+' = combined , '-' = not combined, | / '?' = unreachable, 'x' = time may be in error, '~' = time too variable. || .- xxxx [ yyyy ] +/- zzzz || Reachability register (octal) -. | xxxx = adjusted offset, || Log2(Polling interval) --. | | yyyy = measured offset, || \ | | zzzz = estimated error. || | | \ MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================== ^* rancher 8 10 377 592 -190us[ -192us] +/- 496us
cat >> /etc/sysctl.conf<<EOF net.ipv4.ip_forward=1 net.bridge.bridge-nf-call-iptables=1 net.ipv4.neigh.default.gc_thresh1=4096 net.ipv4.neigh.default.gc_thresh2=6144 net.ipv4.neigh.default.gc_thresh3=8192 EOF
sysctl -p
[root@rancher ~]# cat add_mod.sh #!/bin/sh mods=( br_netfilter ip6_udp_tunnel ip_set ip_set_hash_ip ip_set_hash_net iptable_filter iptable_nat iptable_mangle iptable_raw nf_conntrack_netlink nf_conntrack nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat nf_nat_ipv4 nf_nat_masquerade_ipv4 nfnetlink udp_tunnel VETH VXLAN x_tables xt_addrtype xt_conntrack xt_comment xt_mark xt_multiport xt_nat xt_recent xt_set xt_statistic xt_tcpudp ) for mod in ${mods[@]};do modprobe $mod lsmod |grep $mod done
chmod a+x add_mod.sh ./add_mod.sh
sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
cat > /etc/yum.repos.d/CentOS-Base.repo << EOF [base] name=CentOS-$releasever - Base - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-$releasever - Updates - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #contrib - packages by Centos Users [contrib] name=CentOS-$releasever - Contrib - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 EOF
sudo yum remove 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
sudo yum update -y sudo yum install -y yum-utils device-mapper-persistent-data lvm2 bash-completion
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum makecache all version=$(yum list docker-ce.x86_64 --showduplicates | sort -r|grep ${docker_version}|awk '{print $2}') sudo yum -y install --setopt=obsoletes=0 docker-ce-${version} docker-ce-selinux-${version}# 如果已经安装高版本Docker,可进行降级安装(可选) yum downgrade --setopt=obsoletes=0 -y docker-ce-${version} docker-ce-selinux-${version}# 把当前用户加入docker组 sudo usermod -aG docker `<new_user>`# 设置开机启动 sudo systemctl enable docker
[root@rancher ~]# cat /etc/docker/daemon.json { "registry-mirrors": ["https://7bezldxe.mirror.aliyuncs.com/"], "max-concurrent-downloads": 3, "max-concurrent-uploads": 5, "storage-driver": "overlay2", "storage-opts": ["overlay2.override_kernel_check=true"], "log-driver": "json-file", "log-opts": { "max-size": "100m", "max-file": "3" } }
[root@node01 ~]# cat /etc/docker/daemon.json { "registry-mirrors": ["https://7bezldxe.mirror.aliyuncs.com/"], "max-concurrent-downloads": 3, "max-concurrent-uploads": 5, "storage-driver": "overlay2", "storage-opts": ["overlay2.override_kernel_check=true"], "log-driver": "json-file", "log-opts": { "max-size": "100m", "max-file": "3" } }
"max-concurrent-downloads": 3, "max-concurrent-uploads": 5
{ "registry-mirrors": ["https://7bezldxe.mirror.aliyuncs.com/","https://IP:PORT/"] }
{ "insecure-registries": ["192.168.1.100","IP:PORT"] }
{ "storage-driver": "overlay2", "storage-opts": ["overlay2.override_kernel_check=true"] }
{ "log-driver": "json-file", "log-opts": { "max-size": "100m", "max-file": "3" } }
[root@rancher ~]# docker version Client: Version: 17.03.2-ce API version: 1.27 Go version: go1.7.5 Git commit: f5ec1e2 Built: Tue Jun 27 02:21:36 2017 OS/Arch: linux/amd64 Server: Version: 17.03.2-ce API version: 1.27 (minimum version 1.12) Go version: go1.7.5 Git commit: f5ec1e2 Built: Tue Jun 27 02:21:36 2017 OS/Arch: linux/amd64 Experimental: false --- [root@node01 ~]# cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core) [root@node01 ~]# docker version Client: Version: 17.03.2-ce API version: 1.27 Go version: go1.7.5 Git commit: f5ec1e2 Built: Tue Jun 27 02:21:36 2017 OS/Arch: linux/amd64 Server: Version: 17.03.2-ce API version: 1.27 (minimum version 1.12) Go version: go1.7.5 Git commit: f5ec1e2 Built: Tue Jun 27 02:21:36 2017 OS/Arch: linux/amd64 Experimental: false
CentOS7安装Rancher2.0并部署kubernetes (一)---部署Rancher
CentOS7安装Rancher2.0并部署kubernetes (二)---部署kubernetes
CentOS7安装Rancher2.0并部署kubernetes (三)---解决登录kubernets超时和部署测试Pod和Containter[nginx为例]
出处:http://www.cnblogs.com/horizonli/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
支付宝(alipay) 二维码打赏 |
微信(wechat) 二维码打赏 JUST LI(**波) |
微信公众号: 木子李的菜田 |