Rancher和Kubesphere都是比较优秀的k8s集群管理平台,比起常规的脚本二进制部署和kebectl部署,使用Rancher或Kubesphere部署k8s 可以降低k8s集群运维复杂度,降低运维开发的成本。
PS:本文系列使用
KubernetesV1.16.15
RancherV2.5.7
centos7.6
docker18.09.9
服务器环境准备
使用三台机器来搭建Kubernetes集群
K8S-master01 172.168.0.128
K8S-master02 172.168.0.129
K8S-worker01 172.168.0.130
使用一台机器来搭建Rancher单机版
K8S-rancher01 172.168.0.131
为每台centos7.6 服务器安装docker。
详情可参考: https://www.runoob.com/docker/centos-docker-install.html
[root@K8S-master01 ~]# docker -v
Docker version 18.09.9, build 039a7df9ba
安装Rancher
详情可参考:rancher中文官网(https://rancher.com/docs/rancher)
[root@rancher ~]# systemctl start docker
[root@rancher ~]# docker pull rancher/rancher:latest
[root@rancher ~]# docker run -d --privileged --restart=unless-stopped -p 80:80 -p 443:443 rancher/rancher:latest
浏览器访问 https://172.168.0.131 ,初始化账号和密码
使用Rancher部署k8s集群
1.可以提前将部署k8s集群所需的docker镜像下载缓存到本地harbor
调整镜像文件
[root@K8S-worker01 ~]# cat rancher-linux-images.sh
docker pull busybox
docker pull rancher/calico-cni:v3.13.4
docker pull rancher/calico-cni:v3.16.5
docker pull rancher/calico-cni:v3.17.2
docker pull rancher/calico-ctl:v3.13.4
docker pull rancher/calico-ctl:v3.16.5
docker pull rancher/calico-ctl:v3.17.2
docker pull rancher/calico-kube-controllers:v3.13.4
docker pull rancher/calico-kube-controllers:v3.16.5
docker pull rancher/calico-kube-controllers:v3.17.2
docker pull rancher/calico-node:v3.13.4
docker pull rancher/calico-node:v3.16.5
docker pull rancher/calico-node:v3.17.2
docker pull rancher/calico-pod2daemon-flexvol:v3.13.4
docker pull rancher/calico-pod2daemon-flexvol:v3.16.5
docker pull rancher/calico-pod2daemon-flexvol:v3.17.2
docker pull rancher/cluster-proportional-autoscaler:1.7.1
docker pull rancher/cluster-proportional-autoscaler:1.8.1
docker pull rancher/configmap-reload:v0.3.0-rancher4
docker pull rancher/coredns-coredns:1.6.2
docker pull rancher/coredns-coredns:1.6.5
docker pull rancher/coredns-coredns:1.6.9
docker pull rancher/coredns-coredns:1.7.0
docker pull rancher/coredns-coredns:1.8.0
docker pull rancher/coreos-etcd:v3.3.15-rancher1
docker pull rancher/coreos-etcd:v3.4.13-rancher1
docker pull rancher/coreos-etcd:v3.4.14-rancher1
docker pull rancher/coreos-etcd:v3.4.3-rancher1
docker pull rancher/coreos-flannel:v0.12.0
docker pull rancher/coreos-flannel:v0.13.0-rancher1
docker pull rancher/coreos-kube-state-metrics:v1.9.7
docker pull rancher/coreos-prometheus-config-reloader:v0.39.0
docker pull rancher/coreos-prometheus-operator:v0.39.0
docker pull rancher/eks-operator:v1.0.7
docker pull rancher/flannel-cni:v0.3.0-rancher6
docker pull rancher/fluentd:v0.1.24
docker pull rancher/grafana-grafana:6.7.4
docker pull rancher/grafana-grafana:7.1.5
docker pull rancher/hyperkube:v1.16.15-rancher1
docker pull rancher/hyperkube:v1.17.17-rancher2
docker pull rancher/hyperkube:v1.18.17-rancher1
docker pull rancher/hyperkube:v1.19.9-rancher1
docker pull rancher/hyperkube:v1.20.5-rancher1
docker pull rancher/istio-1.5-migration:0.1.1
docker pull rancher/istio-citadel:1.5.9
docker pull rancher/istio-coredns-plugin:0.2-istio-1.1
docker pull rancher/istio-galley:1.5.9
docker pull rancher/istio-kubectl:1.4.6
docker pull rancher/istio-kubectl:1.5.10
docker pull rancher/istio-kubectl:1.5.9
docker pull rancher/istio-mixer:1.5.9
docker pull rancher/istio-node-agent-k8s:1.5.9
docker pull rancher/istio-pilot:1.5.9
docker pull rancher/istio-proxyv2:1.5.9
docker pull rancher/istio-sidecar_injector:1.5.9
docker pull rancher/jaegertracing-all-in-one:1.14
docker pull rancher/jenkins-jnlp-slave:3.35-4
docker pull rancher/jetstack-cert-manager-controller:v0.8.1
docker pull rancher/jimmidyson-configmap-reload:v0.3.0
docker pull rancher/k8s-dns-dnsmasq-nanny:1.15.0
docker pull rancher/k8s-dns-dnsmasq-nanny:1.15.10
docker pull rancher/k8s-dns-dnsmasq-nanny:1.15.2
docker pull rancher/k8s-dns-kube-dns:1.15.0
docker pull rancher/k8s-dns-kube-dns:1.15.10
docker pull rancher/k8s-dns-kube-dns:1.15.2
docker pull rancher/k8s-dns-node-cache:1.15.13
docker pull rancher/k8s-dns-node-cache:1.15.7
docker pull rancher/k8s-dns-sidecar:1.15.0
docker pull rancher/k8s-dns-sidecar:1.15.10
docker pull rancher/k8s-dns-sidecar:1.15.2
docker pull rancher/kiali-kiali:v1.17
docker pull rancher/kube-api-auth:v0.1.4
docker pull rancher/kubectl:v1.18.0
docker pull rancher/kubernetes-external-dns:v0.7.3
docker pull rancher/library-nginx:1.19.2-alpine
docker pull rancher/log-aggregator:v0.1.7
docker pull rancher/metrics-server:v0.3.4
docker pull rancher/metrics-server:v0.3.6
docker pull rancher/metrics-server:v0.4.1
docker pull rancher/minio-minio:RELEASE.2020-07-13T18-09-56Z
docker pull rancher/nginx-ingress-controller-defaultbackend:1.5-rancher1
docker pull rancher/nginx-ingress-controller:nginx-0.35.0-rancher2
docker pull rancher/nginx-ingress-controller:nginx-0.43.0-rancher1
docker pull rancher/opa-gatekeeper:v3.1.0-beta.7
docker pull rancher/openzipkin-zipkin:2.14.2
docker pull rancher/pause:3.1
docker pull rancher/pause:3.2
docker pull rancher/pipeline-jenkins-server:v0.1.4
docker pull rancher/pipeline-tools:v0.1.15
docker pull rancher/plugins-docker:18.09
docker pull rancher/prom-alertmanager:v0.21.0
docker pull rancher/prom-node-exporter:v1.0.1
docker pull rancher/prom-prometheus:v2.12.0
docker pull rancher/prom-prometheus:v2.18.2
docker pull rancher/prometheus-auth:v0.2.1
docker pull rancher/pstauffer-curl:v1.0.3
docker pull rancher/rke-tools:v0.1.69
docker pull rancher/rke-tools:v0.1.72
docker pull rancher/security-scan:v0.1.14
docker pull rancher/shell:v0.1.6
docker pull rancher/sonobuoy-sonobuoy:v0.16.3
docker pull rancher/system-upgrade-controller:v0.6.2
docker pull rancher/thanosio-thanos:v0.15.0
docker pull rancher/webhook-receiver:v0.2.4
docker pull registry:2
docker pull rancher/rancher-agent:v2.5.7
sh rancher-linux-images.sh
执行完命令,需耐心等待三个小时,或科学上网等待镜像拉取完成
2.可以生成命令 ,勾选角色
master节点:
[root@K8S-master01 ~]# sudo docker run -d --privileged --restart=unless-stopped --net=host
-v /etc/kubernetes:/etc/kubernetes
-v /var/run:/var/run rancher/rancher-agent:v2.5.7
--server https://172.168.0.131 --token h584lrqfjxcfxtqtc2g5wnkrsns82w6z8jz6lntrs22sk8z7
--ca-checksum 12a64dc4c91e0918b100a4134e353cace5e7706f40a9472e5fc355d6e61a
--etcd --controlplane --worker
[root@K8S-master02 ~]# sudo docker run -d --privileged --restart=unless-stopped --net=host
-v /etc/kubernetes:/etc/kubernetes
-v /var/run:/var/run rancher/rancher-agent:v2.5.7
--server https://172.168.0.131 --token h584lrqfjxcfxtqtc2g5wnkrsns82w6z8jz6lntrs22sk8z7
--ca-checksum 12a64dc4c91e0918b100a4134e353cace5e7706f40a9472e5fc355d6e61a
--etcd --controlplane --worker
worker节点
[root@K8S-worker01 ~]# sudo docker run -d --privileged --restart=unless-stopped --net=host
-v /etc/kubernetes:/etc/kubernetes
-v /var/run:/var/run rancher/rancher-agent:v2.5.7
--server https://172.168.0.131 --token h584lrqfjxcfxtqtc2g5wnkrsns82w6z8jz6lntrs22sk8z7
--ca-checksum 12a64dc4c91e0918b100a4134e353cace5e7706f40a9472e5fc355d6e61a --worker
执行完命令,需耐心等待三个小时等待集群启动
3.k8s集群部署完毕
[root@K8S-master01 ~]#kubectl get nodes
172.168.0.128 Ready master,etcd 1h v1.16.15
172.168.0.129 Ready master,etcd 1h v1.16.15
172.168.0.130 Ready worker 1h v1.16.15
精选原创推荐
docker容器部署Spring Profile参数策略
linux云服务器存储分区热挂载
Node的进程管理工具pm2
拒绝夜间上线:Eureka热部署服务
大厂必备:ansible 自动化工具
亲测好评:国产开源APM运维监控
APM钉钉告警二次开发pinpoint(附带源码)
Prometheus + Granafa 构建高大上的MySQL监控平台
syncd一款高效开源的代码部署工具
高效开发:IntelliJIDEA的这些Debug技巧你都知道吗
运维必备:goreplay流量复制工具
一款SQL高效审计工具|解放DBA双手
实用技能:git子模块功能