kubernetes之hyperkube方式安装文档-部署k8s集群监控prometheus-operator(五)

在上一编文章部署kubernetes集群成功之后,接下来就是部署监控系统了,本编博客主要是基于coreos开源的prometheus-operator监控系统,该监控系统比较全面,主要是已经搞定了grafana的监控模版,废话不多说,接下来就进入正题:

下载v0.16.0.tar.gz release版本的prometheus-operator,然后解压(也可以下载源码自行编译)

wget https://github.com/coreos/prometheus-operator/archive/v0.16.0.tar.gz
tar -zvxf v0.16.0.tar.gz

[root@master-27 prometheus]# ls -l
total 5968
drwxrwxr-x 13 root root    4096 Jan 12 21:41 prometheus-operator-0.16.0
-rw-r--r--  1 root root    2068 Jun 20 19:37 prometheus.yaml
-rwxr-xr-x  1 root root 6102555 Jun 20 20:03 v0.16.0.tar.gz

部署prometheus-operator的deployment

//用到的镜像是
 - --config-reloader-image=quay.io/coreos/configmap-reload:v0.0.1
        image: quay.io/coreos/prometheus-operator:v0.16.0

kubectl create -f bundle.yaml 

部署成功查看

[root@master-27 prometheus-operator-0.16.0]# kubectl get deployment 
NAME                  DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
prometheus-operator   1         1         1            1           13h

[root@master-27 prometheus-operator-0.16.0]# kubectl get pod 
NAME                                   READY     STATUS    RESTARTS   AGE
prometheus-operator-1084866340-sfpl3   1/1       Running   0          13h

部署grafana alternanager kube-status-meric

[root@master-27 prometheus-operator-0.16.0]# cd contrib/kube-prometheus/
[root@master-27 kube-prometheus]# pwd
/root/prometheus/prometheus-operator-0.16.0/contrib/kube-prometheus
./hack/cluster-monitoring/deploy

[root@master-27 kube-prometheus]# ./hack/cluster-monitoring/deploy 
namespace "monitoring" created
Warning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl apply
clusterrolebinding.rbac.authorization.k8s.io "prometheus-operator" configured
Warning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl apply
clusterrole.rbac.authorization.k8s.io "prometheus-operator" configured
serviceaccount "prometheus-operator" created
service "prometheus-operator" created
deployment.extensions "prometheus-operator" created
Waiting for Operator to register custom resource definitions...done!
daemonset.extensions "node-exporter" created
serviceaccount "node-exporter" created
service "node-exporter" created
unable to recognize "manifests/node-exporter/node-exporter-cluster-role-binding.yaml": no matches for kind "ClusterRoleBinding" in version "rbac.authorization.k8s.io/v1"
unable to recognize "manifests/node-exporter/node-exporter-cluster-role.yaml": no matches for kind "ClusterRole" in version "rbac.authorization.k8s.io/v1"
clusterrolebinding.rbac.authorization.k8s.io "kube-state-metrics" created
clusterrole.rbac.authorization.k8s.io "kube-state-metrics" created
deployment.extensions "kube-state-metrics" created
rolebinding.rbac.authorization.k8s.io "kube-state-metrics" created
role.rbac.authorization.k8s.io "kube-state-metrics-resizer" created
serviceaccount "kube-state-metrics" created
service "kube-state-metrics" created
secret "grafana-credentials" created
secret "grafana-credentials" unchanged
configmap "grafana-dashboards-0" created
deployment.apps "grafana" created
service "grafana" created
servicemonitor.monitoring.coreos.com "prometheus-operator" created
serviceaccount "prometheus-k8s" created
servicemonitor.monitoring.coreos.com "kube-controller-manager" created
servicemonitor.monitoring.coreos.com "node-exporter" created
servicemonitor.monitoring.coreos.com "prometheus" created
prometheus.monitoring.coreos.com "k8s" created
servicemonitor.monitoring.coreos.com "kube-state-metrics" created
servicemonitor.monitoring.coreos.com "alertmanager" created
servicemonitor.monitoring.coreos.com "kubelet" created
servicemonitor.monitoring.coreos.com "kube-scheduler" created
configmap "prometheus-k8s-rules" created
service "prometheus-k8s" created
servicemonitor.monitoring.coreos.com "kube-apiserver" created
role.rbac.authorization.k8s.io "prometheus-k8s" created
role.rbac.authorization.k8s.io "prometheus-k8s" created
role.rbac.authorization.k8s.io "prometheus-k8s" created
clusterrole.rbac.authorization.k8s.io "prometheus-k8s" created
rolebinding.rbac.authorization.k8s.io "prometheus-k8s" created
rolebinding.rbac.authorization.k8s.io "prometheus-k8s" created
rolebinding.rbac.authorization.k8s.io "prometheus-k8s" created
clusterrolebinding.rbac.authorization.k8s.io "prometheus-k8s" created
secret "alertmanager-main" created
service "alertmanager-main" created
alertmanager.monitoring.coreos.com "main" created

用到的镜像好多,这里就不多说了,主要是有个镜像是谷歌的需要翻墙,可以自行翻墙下载,其他镜像都是quay.io/coreos,这个特别的镜像是

gcr.io/google_containers/addon-resizer:1.0

查看结果

[root@master-27 kube-prometheus]# kubectl get deployment -n monitoring 
NAME                  DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
grafana               1         1         1            1           13h
kube-state-metrics    1         1         1            1           13h
prometheus-operator   1         1         1            1           13h

[root@master-27 kube-prometheus]# kubectl get pods -n monitoring 
NAME                                   READY     STATUS    RESTARTS   AGE
alertmanager-main-0                    2/2       Running   0          13h
alertmanager-main-1                    2/2       Running   0          13h
alertmanager-main-2                    2/2       Running   0          13h
grafana-2315080943-nzl62               2/2       Running   0          12h
kube-state-metrics-2381097451-06789    4/4       Running   0          40s
node-exporter-2s6bm                    2/2       Running   0          13h
node-exporter-q79n2                    2/2       Running   0          13h
node-exporter-r4dqt                    2/2       Running   0          13h
prometheus-k8s-0                       2/2       Running   0          13h
prometheus-k8s-1                       2/2       Running   0          13h
prometheus-operator-1084866340-ljvfm   1/1       Running   0          13h
[root@master-27 kube-prometheus]# kubectl get svc -n monitoring 
NAME                    TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)             AGE
alertmanager-main       NodePort    10.12.192.98   <none>        9093:30903/TCP      13h
alertmanager-operated   ClusterIP   None           <none>        9093/TCP,6783/TCP   13h
grafana                 NodePort    10.0.122.89    <none>        3000:30902/TCP      13h
kube-state-metrics      ClusterIP   None           <none>        8443/TCP,9443/TCP   13h
node-exporter           ClusterIP   None           <none>        9100/TCP            13h
prometheus-k8s          NodePort    10.3.237.34    <none>        9090:30900/TCP      13h
prometheus-operated     ClusterIP   None           <none>        9090/TCP            13h
prometheus-operator     ClusterIP   10.10.228.57   <none>        8080/TCP            13h

访问grafana的页面master-ip:/30902,
grafana
访问prometheus的页面master-ip:/30900
111

访问alertmanager 告警页面master-ip:/30903
1al
到此为止,已经成功部署了k8s集群监控prometheus-operator

参考:
Kubernetes监控(coreos/prometheus-operator)
官方网站

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值