Rancher v2.2.0-Alpha3 具有多租户 Prometheus 支持 的功能细节
我在Rancher2.2的Alpha版中尝试了Multi-Tenant Prometheus功能,可以惊人地轻松地构建Prometheus + Grafana环境。
我在下述配置中进行了验证。

牧场主服务器版本:2.2.0-Alpha3
搭建Rancher Server
1. 準備好例子。
項目入力概要名前rancher-serverリージョンasia-northeast1(東京)ゾーンasia-northeast1-bマシンタイプvCPUx1ブートディスクUbuntu 16.04 LTS
ディスクサイズ80GBファイアウォールHTTP トラフィックを許可する、HTTPS トラフィックを許可するの両方をチェックします。
ディスクサイズ80GBファイアウォールHTTP トラフィックを許可する、HTTPS トラフィックを許可するの両方をチェックします。
2. 安装Docker
$ curl https://releases.rancher.com/install-docker/18.09.sh | sh
・
・(省略)
・
+ sudo -E sh -c docker version
Client:
Version: 18.09.3
API version: 1.39
Go version: go1.10.8
Git commit: 774a1f4
Built: Thu Feb 28 06:40:58 2019
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 18.09.3
API version: 1.39 (minimum version 1.12)
Go version: go1.10.8
Git commit: 774a1f4
Built: Thu Feb 28 05:59:55 2019
OS/Arch: linux/amd64
Experimental: false
If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:
sudo usermod -aG docker iyutaka2018
Remember that you will have to log out and back in for this to take effect!
WARNING: Adding a user to the "docker" group will grant the ability to run
containers which can be used to obtain root privileges on the
docker host.
Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
for more information.
If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:
sudo usermod -aG docker iyutaka2018
Remember that you will have to log out and back in for this to take effect!
WARNING: Adding a user to the "docker" group will grant the ability to run
containers which can be used to obtain root privileges on the
docker host.
Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
for more information.
3. 安装 Rancher2.2.0-Alpha3 服务器。
$ sudo docker run -d --restart=unless-stopped -p 80:80 -p 443:443 rancher/rancher:v2.2.0-alpha3
Unable to find image 'rancher/rancher:v2.2.0-alpha3' locally
v2.2.0-alpha3: Pulling from rancher/rancher
32802c0cfa4d: Pull complete
da1315cffa03: Pull complete
fa83472a3562: Pull complete
f85999a86bef: Pull complete
a4daac5bee2d: Pull complete
bf26f1964577: Pull complete
a00bebfc6f0e: Pull complete
3afff0aaa1d8: Pull complete
8f3d31deda5a: Pull complete
aa24579912ce: Pull complete
6d77f6748e72: Pull complete
d47b70b03591: Pull complete
Digest: sha256:db7fe1ba357cfe5238634f2fb21085177b3ad897cec1aacacca1b3e2b22152a2
Status: Downloaded newer image for rancher/rancher:v2.2.0-alpha3
3a8894aa888fdb14d08c676b51d3a4011f5ee794f61eb90a6fe013e690e73057
使用浏览器打开并访问RancherUI。
5. 首次登录
a. 创建admin用户的密码

b. 注册Rancher服务器URL

c. 登录成功

构建一个单个的Kubernetes集群。
1. 实例准备
項目入力概要名前rancher-k8s-clusterリージョンasia-northeast1(東京)ゾーンasia-northeast1-bマシンタイプvCPUx1ブートディスクUbuntu 16.04 LTS
ディスクサイズ80GBファイアウォールHTTP トラフィックを許可する、HTTPS トラフィックを許可するの両方をチェックします。
ディスクサイズ80GBファイアウォールHTTP トラフィックを許可する、HTTPS トラフィックを許可するの両方をチェックします。
将Docker安装在rancher-k8s-cluster上。
$ curl https://releases.rancher.com/install-docker/17.03.2.sh | sh
・
・(省略)
・
+ sudo -E sh -c docker version
Client:
Version: 17.03.2-ce
API version: 1.27
Go version: go1.7.5
Git commit: f5ec1e2
Built: Tue Jun 27 03:35:14 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 03:35:14 2017
OS/Arch: linux/amd64
Experimental: false
If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:
sudo usermod -aG docker iyutaka2018
Remember that you will have to log out and back in for this to take effect!
WARNING: Adding a user to the "docker" group will grant the ability to run
containers which can be used to obtain root privileges on the
docker host.
Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
for more information.
3. 构建Kubernetes集群
按下「添加集群」按钮

2. 选择「自定义」,在「集群名称」中输入任意名称,点击「下一步」按钮。

3. 在「Node Role」中选中「etcd」和「Control Plane」,点击「复制到剪贴板」按钮。

在rancher-k8s-cluster的控制台中执行复制的命令。
$ sudo docker run -d --privileged --restart=unless-stopped --net=host -v /etc/kubernetes:/etc/kubernetes -v /var/run:/var/run rancher/rancher-agent:v2.2.0-alpha3 --server https://35.243.83.224 --token xx9ttl6ckrkzppk6msvx7jzslcc75m8m7pwbws7fjvbdls2g9l6nrn --ca-checksum 487497cfc43e87a717ca8c775c2b0e19677bf0a73b5091ee1572b8546defec75 --etcd --controlplane --worker
按下「完成」按钮

选择「牧场 k8s 集群」。

选择上方菜单栏的「工具」-「监控」选项。

请点击选择Prometheus图标,然后按下”保存”按钮。
这个过程会自动地搭建Prometheus + Grafana环境。

9. 确认画面切换后,Prometheus + Grafana已启用。

10. 展开手风琴菜单
你可以从每个指标中查看图表。默认情况下,右上角的下拉菜单设置为“1小时”,如果将其更改为“5分钟”,则会显示图表。

将光标移动至图表上即可显示详细信息。

点击Grafana图标,即可在Grafana仪表盘上进行确认。



按下「启动 kubectl」按钮

执行「kubectl get pods –all-namespaces」命令,以确认当前情况。
# Run kubectl commands inside here
# e.g. kubectl get all
> kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
cattle-prometheus exporter-kube-state-cluster-monitoring-779b96cf75-gg272 1/1 Running 0 20m
cattle-prometheus exporter-node-cluster-monitoring-ljhch 1/1 Running 0 20m
cattle-prometheus grafana-cluster-monitoring-5b4bc74756-hx7mx 3/3 Running 0 20m
cattle-prometheus prometheus-cluster-monitoring-0 4/4 Running 1 20m
cattle-prometheus prometheus-cluster-monitoring-nginx-5ff785dd4d-d6l8l 1/1 Running 3 20m
cattle-prometheus prometheus-operator-system-monitor-77df6db6df-gdmmz 1/1 Running 0 20m
cattle-system cattle-cluster-agent-77498f79c-5w78s 1/1 Running 0 30m
cattle-system cattle-node-agent-s8gnz 1/1 Running 0 30m
ingress-nginx default-http-backend-5bdd9fdd69-2ntmw 1/1 Running 0 30m
ingress-nginx nginx-ingress-controller-xdwnk 1/1 Running 0 30m
kube-system canal-wzw4r 3/3 Running 0 30m
kube-system kube-dns-autoscaler-689f6f9756-zqn6f 1/1 Running 0 30m
kube-system kube-dns-ddddcfcc8-xbpwn 3/3 Running 0 30m
kube-system metrics-server-5444cf6dfc-g7xvp 1/1 Running 0 30m
kube-system rke-ingress-controller-deploy-job-bshtx 0/1 Completed 0 30m
kube-system rke-kubedns-addon-deploy-job-k9vxg 0/1 Completed 0 30m
kube-system rke-metrics-addon-deploy-job-hmr7k 0/1 Completed 0 30m
kube-system rke-network-plugin-deploy-job-tjqhn 0/1 Completed 0 31m

4. 文档
- How to Get Started with Rancher’s New Multi-Tenant Prometheus Support and Alpha Release Process