1.Helm客户端安装
https://github.com/helm/helm/releases
下载二进制包,将helm文件复制到/usr/bin
helm version查看是否生效
fxx2@kube-node-1:~$ helm version
Client: &version.Version{SemVer:"v2.16.1", GitCommit:"bbdfe5e7803a12bbdf97e94cd847859890cf4050", GitTreeState:"clean"}
2.Tiller服务器安装
创建服务账号并授权
fxx2@kube-node-1:~$ cat rbac-config.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: tiller
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: tiller
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: tiller
namespace: kube-system
fxx2@kube-node-1:~$ sudo kubectl apply -f rbac-config.yaml
安装非常简单,执行helm init即可,但默认初始化过程需拉取google镜像,需指定国内镜像源。
fxx2@kube-node-1:~$ sudo helm init --service-account tiller --upgrade -i registry.cn-hangzhou.aliyuncs.com/google_containers/tiller:v2.16.1 \
--stable-repo-url https://kubernetes-charts.storage.googleapis.com
##################
fxx2@kube-node-1:~$ sudo helm repo list ###查看仓库源,可通过helm repo add添加
[sudo] password for fxx2:
NAME URL
stable https://kubernetes-charts.storage.googleapis.com
local http://127.0.0.1:8879/charts
fxx2@kube-node-1:~$ helm version ###查看tiller是否初始化成功
Client: &version.Version{SemVer:"v2.16.1", GitCommit:"bbdfe5e7803a12bbdf97e94cd847859890cf4050", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.16.1", GitCommit:"bbdfe5e7803a12bbdf97e94cd847859890cf4050", GitTreeState:"clean"}
3.安装Prometheus Operator
为方便管理,可单独创建一个namespace
kubectl create namespace monitoring
安装Prometheus Operator Deployment
helm install --name prometheus-operator --set rbacEnable=true --namespace=monitoring stable/prometheus-operator
安装Prometheus
helm install --name prometheus --set serviceMonitorsSelector.app=prometheus --set ruleSelector.app=prometheus --namespace=monitoring stable/prometheus
查看安装结果
fxx2@kube-node-1:~$ kubectl get deploy --namespace=monitoring
NAME READY UP-TO-DATE AVAILABLE AGE
prometheus-alertmanager 0/1 1 0 3d16h
prometheus-kube-state-metrics 1/1 1 1 3d16h
prometheus-operator-grafana 1/1 1 1 3d17h
prometheus-operator-kube-state-metrics 1/1 1 1 3d17h
prometheus-operator-operator 1/1 1 1 3d17h
prometheus-pushgateway 1/1 1 1 3d16h
prometheus-server 0/1 1 0 3d16h
修改service类型ClusterIP为NodePort
kubectl edit svc prometheus-operator-grafana -n monitoring
kubectl edit svc prometheus-operator-alertmanager -n monitoring
kubectl edit svc prometheus-operator-prometheus -n monitoring
查看grafana 的NodePort
fxx2@kube-node-1:~$ kubectl get svc prometheus-operator-grafana -n monitoring
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
prometheus-operator-grafana NodePort 10.110.245.253 <none> 80:31415/TCP 3d17h
查看grafana的登陆账号密码
fxx2@kube-node-1:~$ kubectl get secret --namespace monitoring prometheus-operator-grafana -o yaml
...
admin-password: YWRtaW4=
admin-user: YWRtaW4=
ldap-toml: ""
kind: Secret
metadata:
...
#######
echo "YWRtaW4=" | base64 --decode ###解码
4.访问grafana
http://<ip>:<grafana_service_nodeport> #如上文的31415
参考链接:
https://github.com/coreos/prometheus-operator.git
https://github.com/helm/charts/tree/master/stable/prometheus-operator#prometheus-operator
「 文章如果对你有帮助,请点个赞哦^^ 」 
0
若无特殊注明,文章均为本站原创或整理发布。
转载请注明本文地址:https://om.fangxiaoxiong.com/1860.html