Kubernetes 之 Rancher

[root@xianchaomaster1 ~]# mkdir Rancher
[root@xianchaomaster1 ~]# cd Rancher/
You have new mail in /var/spool/mail/root
[root@xianchaomaster1 Rancher]# ll
total 1003732
-rw-r--r-- 1 root root 1027820032 Apr 10 19:45 rancher-2-5-7.tar.gz
[root@xianchaomaster1 Rancher]# du -sh
981M    .
[root@xianchaomaster1 Rancher]# clear
[root@xianchaomaster1 Rancher]# docker load -i rancher-2-5-7.tar.gz
837d6facb613: Loading layer [==================================================>]  65.62MB/65.62MB
0dd1581dbc3c: Loading layer [==================================================>]  15.87kB/15.87kB
07adad8f2cae: Loading layer [==================================================>]  3.072kB/3.072kB
6134744da509: Loading layer [==================================================>]  133.7MB/133.7MB
692ca7cda317: Loading layer [==================================================>]  6.656kB/6.656kB
49b3fb23ffd0: Loading layer [==================================================>]  115.5MB/115.5MB
f43f4ad6d6d6: Loading layer [==================================================>]  74.54MB/74.54MB
12b5b239b8dc: Loading layer [==================================================>]   35.8MB/35.8MB
004a98f887c8: Loading layer [==================================================>]  88.59MB/88.59MB
16b4e3a7f161: Loading layer [==================================================>]  75.46MB/75.46MB
875b916353d1: Loading layer [==================================================>]  174.3MB/174.3MB
6fee877a92bf: Loading layer [==================================================>]  3.072kB/3.072kB
9172cf8e8dfc: Loading layer [==================================================>]  98.13MB/98.13MB
c9acfde923ec: Loading layer [==================================================>]  119.9MB/119.9MB
5f315516d4c5: Loading layer [==================================================>]  3.072kB/3.072kB
34501118e215: Loading layer [==================================================>]   5.12kB/5.12kB
96024a9c6f76: Loading layer [==================================================>]  44.05MB/44.05MB
0fd54d1fc7c7: Loading layer [==================================================>]  3.584kB/3.584kB
1dd8d7a2da11: Loading layer [==================================================>]  3.072kB/3.072kB
00383549aebd: Loading layer [==================================================>]  2.042MB/2.042MB
Loaded image: rancher/rancher:v2.5.7

[root@xianchaomaster1 Rancher]# docker run -d --restart=unless-stopped -p 80:80 -p 443:443 --privileged rancher/rancher:v2.5.7
afd51ff022356c584c9fdb42766fd6a5e4cb350035a3eee0580d3e24fbc006f4
You have new mail in /var/spool/mail/root
[root@xianchaomaster1 Rancher]# docker ps | grep rancher
afd51ff02235   rancher/rancher:v2.5.7                              "entrypoint.sh"          12 seconds ago   Up 11 seconds   0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp   infallible_kare

通过 Rancher 管理已存在的 k8s 集群

 

#第一次执行会错误 在执行一次就好了
[root@xianchaomaster1 Rancher]#       curl --insecure -sfL https://192.168.40.180/v3/import/6bhr8dlgjxjnm2n777dbz22twhz9k765mkrdmdwrn6297kjx5n7tjr_c-7mkj4.yaml | kubectl apply -f -
error: no objects passed to apply

[root@xianchaomaster1 Rancher]#       curl --insecure -sfL https://192.168.40.180/v3/import/6bhr8dlgjxjnm2n777dbz22twhz9k765mkrdmdwrn6297kjx5n7tjr_c-7mkj4.yaml | kubectl apply -f -
clusterrole.rbac.authorization.k8s.io/proxy-clusterrole-kubeapiserver created
clusterrolebinding.rbac.authorization.k8s.io/proxy-role-binding-kubernetes-master created
namespace/cattle-system created
serviceaccount/cattle created
clusterrolebinding.rbac.authorization.k8s.io/cattle-admin-binding created
secret/cattle-credentials-be2b57a created
clusterrole.rbac.authorization.k8s.io/cattle-admin created
deployment.apps/cattle-cluster-agent created
[root@xianchaomaster1 Rancher]#

#各个节点 镜像启动rancher-agent-2-5-7.tar.gz

-rw-r--r-- 1 root root 1027820032 Apr 10 19:45 rancher-2-5-7.tar.gz
-rw-r--r-- 1 root root  535855104 Apr 10 20:04 rancher-agent-2-5-7.tar.gz
You have new mail in /var/spool/mail/root
[root@xianchaomaster1 Rancher]# docker load -i rancher-agent-2-5-7.tar.gz
4a7e51aee906: Loading layer [==================================================>]  2.048kB/2.048kB
0b27beb522e7: Loading layer [==================================================>]  179.7MB/179.7MB
2152f68efad9: Loading layer [==================================================>]  5.941MB/5.941MB
bc5f3e9c1c4d: Loading layer [==================================================>]  47.41MB/47.41MB
145c9df4dc20: Loading layer [==================================================>]  117.5MB/117.5MB
d41ab309aa5c: Loading layer [==================================================>]  119.6MB/119.6MB
cf5db7c761f5: Loading layer [==================================================>]  3.072kB/3.072kB
Loaded image: rancher/rancher-agent:v2.5.7

通过 Rancher 部署监控系统

启用 Rancher 集群级别监控
#把 prometheus-grafana.tar.gz 镜像压缩包上传到 xianchaonode1 机器上,手动解压
[root@xianchaonode1~]# docker load -i prometheus-grafana.tar.gz
#在开启监控的时候默认会拉取一些镜像,速度较慢,所以大家先把安装监控需要的镜像解压
启动监控时间可能比较长,需要等 10-20 分钟
在 rancher 主页面,点击集群名称 xianchao-test

[root@xianchaonode1 Rancher]# ll
total 1466508
-rw-r--r-- 1 root root 965845504 Apr 10 20:10 prometheus-grafana.tar.gz
-rw-r--r-- 1 root root 535855104 Apr 10 20:05 rancher-agent-2-5-7.tar.gz
[root@xianchaonode1 Rancher]# docker load -i prometheus-grafana.tar.gz
50644c29ef5a: Loading layer [==================================================>]  5.845MB/5.845MB
cb596e3b6acf: Loading layer [==================================================>]  6.286MB/6.286MB
43376507b219: Loading layer [==================================================>]  15.96MB/15.96MB
5c98ed105d7e: Loading layer [==================================================>]  155.2MB/155.2MB
7fcdc437fb25: Loading layer [==================================================>]   51.2kB/51.2kB
9c957ea29f01: Loading layer [==================================================>]   5.12kB/5.12kB
Loaded image: rancher/grafana-grafana:7.1.5
7ef368776582: Loading layer [==================================================>]  65.61MB/65.61MB
83f4287e1f04: Loading layer [==================================================>]  991.7kB/991.7kB
d3a6da143c91: Loading layer [==================================================>]  15.87kB/15.87kB
8682f9a74649: Loading layer [==================================================>]  3.072kB/3.072kB
10a0f337dc54: Loading layer [==================================================>]  71.79MB/71.79MB
dd3f9ef9d4f5: Loading layer [==================================================>]  112.6kB/112.6kB
c53dfaa10f54: Loading layer [==================================================>]  39.27MB/39.27MB
db34920da7b0: Loading layer [==================================================>]  39.27MB/39.27MB
Loaded image: rancher/istio-kubectl:1.5.10
bef00f7ac5a9: Loading layer [==================================================>]  5.424MB/5.424MB
bb208cc3e926: Loading layer [==================================================>]  2.743MB/2.743MB
53fe7fa9c07c: Loading layer [==================================================>]  19.66MB/19.66MB
Loaded image: rancher/prom-node-exporter:v1.0.1
0d1435bd79e4: Loading layer [==================================================>]  3.062MB/3.062MB
d1ce60962f06: Loading layer [==================================================>]     31MB/31MB
Loaded image: rancher/coreos-kube-state-metrics:v1.9.7
69e42300d7b5: Loading layer [==================================================>]  224.6MB/224.6MB
Loaded image: kubernetesui/dashboard:v2.0.0
0d315111b484: Loading layer [==================================================>]  1.441MB/1.441MB
f78d3758f4e1: Loading layer [==================================================>]  8.478MB/8.478MB
Loaded image: rancher/jimmidyson-configmap-reload:v0.3.0
0b36f08e48e4: Loading layer [==================================================>]  3.343MB/3.343MB
cbab3b82f1f9: Loading layer [==================================================>]  30.18MB/30.18MB
Loaded image: rancher/prometheus-auth:v0.2.1
6bcd003260b2: Loading layer [==================================================>]   17.7MB/17.7MB
5d9ee84be1ec: Loading layer [==================================================>]  3.072kB/3.072kB
425ee8569962: Loading layer [==================================================>]  4.096kB/4.096kB
6ad8d562c843: Loading layer [==================================================>]  3.584kB/3.584kB
Loaded image: rancher/library-nginx:1.19.2-alpine
1da8e4c8d307: Loading layer [==================================================>]  1.437MB/1.437MB
7a151fe67625: Loading layer [==================================================>]  2.595MB/2.595MB
dba5490526c5: Loading layer [==================================================>]  87.18MB/87.18MB
20115e9c48df: Loading layer [==================================================>]  49.99MB/49.99MB
0dff84f572aa: Loading layer [==================================================>]  3.584kB/3.584kB
7bb65727b1b1: Loading layer [==================================================>]  13.31kB/13.31kB
3566bbfd73a9: Loading layer [==================================================>]  28.16kB/28.16kB
fed7b05a096c: Loading layer [==================================================>]  13.31kB/13.31kB
f3786f18463b: Loading layer [==================================================>]   5.12kB/5.12kB
887245d48bab: Loading layer [==================================================>]  112.6kB/112.6kB
3cbd8562011a: Loading layer [==================================================>]  3.072kB/3.072kB
7e797ec137fe: Loading layer [==================================================>]   5.12kB/5.12kB
Loaded image: rancher/prom-prometheus:v2.18.2
e1666201d4e7: Loading layer [==================================================>]  7.518MB/7.518MB
Loaded image: rancher/coreos-prometheus-config-reloader:v0.39.0
ecaf2833dc8f: Loading layer [==================================================>]  31.71MB/31.71MB
Loaded image: rancher/coreos-prometheus-operator:v0.39.0
57757cd7bb95: Loading layer [==================================================>]  238.6kB/238.6kB
14f2e8fb1e35: Loading layer [==================================================>]   36.7MB/36.7MB
52b345e4c8e0: Loading layer [==================================================>]  2.048kB/2.048kB
Loaded image: kubernetesui/metrics-scraper:v1.0.4

 

显示监控 API 未就绪,需要等待 10-20 分钟,才能就绪

 

 

 

过 10-20 分钟后,监控 API 已经就绪了,那就刷新当前页面,监控部署完成后就可以看到我们的监控信息了。

 通过 Rncher 仪表盘管理 k8s 集群:部署 tomcat 服务

#把 tomcat.tar.gz 镜像压缩包上传到 xianchaonode1 节点,手动解压:
[root@xianchaonode1 ~]# docker load -i tomcat.tar.gz
1、创建名称空间 namespace
打开 rancher 主页面,点击仪表盘

[root@xianchaonode1 Rancher]# docker load -i tomcat.tar.gz
df64d3292fd6: Loading layer [==================================================>]  4.672MB/4.672MB
0c3170905795: Loading layer [==================================================>]  3.584kB/3.584kB
9bca1faaa73e: Loading layer [==================================================>]  79.44MB/79.44MB
e927085edc33: Loading layer [==================================================>]   2.56kB/2.56kB
e5f8376fd9dc: Loading layer [==================================================>]  27.08MB/27.08MB
e82a3681bb38: Loading layer [==================================================>]  2.048kB/2.048kB
Loaded image: tomcat:8.5.34-jre8-alpine

 

 

 

 

 

posted @ 2023-04-10 20:21  しみずよしだ  阅读(69)  评论(0编辑  收藏  举报