This series of articles:
Chapter one: nine analyze with you easily install the complete explosion helm3
Chapter II: nine analyze with you easily complete explosion helm3 public warehouseChapter 3: nine analyze with you easily complete explosion helm3 private warehouse
Chapter 4: nine analyze with you easily complete explosion helm3 chart
Chapter V: nine analyze with you easily complete explosion helm3 release
Chapter 6: nine analyze with you easily complete explosion helm3 gitlab
Chapter 7: nine analyze with you easily complete explosion helm3 nginx-ingress
Chapter 8: nine analyze with you easily complete explosion helm3 gitlab nfs
Chapter 9: nine analyze with you easily complete explosion helm3 nexus
Chapter X: nine analyze with you easily complete explosion helm3 heapster
Chapter 11: nine analyze with you easily complete explosion helm3 kubernetes-dashboard
Chapter XII: nine analyze with you easily complete explosion helm3 harbor
Chapter XIII: nine analyze with you easily complete explosion helm3 prometheus
table of Contents
1 Introduction
2 Download Prometheus
3 prometheus create a namespace
4 Installation prometheus
4.1 modify the deployment apiVersion
4.2 Add daemonset selector
4.3 Adding deployment selector
4.4 modify ingress apiVersion
4.5 installation verification prometheus
5 Install nfs
6 Create pv
7 Verify prometheus
8 modify service type
9 Access prometheus
1 Introduction
In this paper, helm v3.0.0; k8s v1.16.3.
2 Download Prometheus
Search helm Prometheus:
helm search repo prometheus
helm download extract Prometheus:
helm fetch stable/prometheus
tar -zxvf prometheus-5.4.0.tgz
3 prometheus create a namespace
kubectl create ns prometheus
4 Installation prometheus
The first is a prometheus helm release name, the second is the namespace, and the third is prometheus local unzipped directory.
helm install prometheus -n prometheus prometheus
4.1 modify the deployment apiVersion
If there is an error during the installation follows:
Error: unable to build kubernetes objects from release manifest: unable to recognize "": no matches for kind "Deployment" in version "extensions/v1beta1"
Execute the following statement relaxed after blasting:
grep -irl 'extensions/v1beta1' prometheus/ | xargs sed -i 's#extensions/v1beta1#apps/v1#g'
4.2 Add daemonset selector
If you install again the following errors:
Error: unable to build kubernetes objects from release manifest: error validating "": error validating data: ValidationError(DaemonSet.spec): missing required field "selector" in io.k8s.api.apps.v1.DaemonSetSpec
Edit templates / node-exporter-daemonset.yaml file, add the following:
4.3 Adding deployment selector:
If the installation again reported the following error:
Error: unable to build kubernetes objects from release manifest: error validating "": error validating data: ValidationError(Deployment.spec): missing required field "selector" in io.k8s.api.apps.v1.DeploymentSpec
Edit templates / alertmanager-deployment.yaml file, add the following:
Edit templates / kube-state-metrics-deployment.yaml file, add the following:
编辑 templates/pushgateway-deployment.yaml 文件,添加如下内容:
编辑 templates/server-deployment.yaml 文件,添加如下内容:
4.4 修改 ingress apiVersion
再次安装如果报如下错:
Error: unable to build kubernetes objects from release manifest: unable to recognize "": no matches for kind "Ingress" in version "apps/v1"
编辑 templates/alertmanager-ingress.yaml 文件,将 apps/v1 修改为 extenstions/v1beta1:
4.5 验证 prometheus 安装
如果执行安装后,显示如下内容:
执行如下操作语句,如果出现如下结果,则说明安装成功:
helm list -n prometheus
但安装成功,并不代表运行成功。还需要做进一步的配置。
5 安装 nfs
如何安装 nfs 服务器,请参考本人《轻松完爆 nfs 安装》,不用担心,简单到爆,让你分分钟轻松完爆。
mkdir -p /data/nfs/prometheus/2g
mkdir -p /data/nfs/prometheus/8g
chmod 777 -R /data/nfs/prometheus
systemctl restart nfs
6 创建 pv
安装完 nfs 后,查看 prometheus pvc:
kubectl get pvc -n prometheus
发现 pvc 处于 pending 状态,原因在于并没有可用的 pv 可以使用,需要手动创建 pv。
发现 pvc 的申请规格有 2 种,分别是 2Gi 和 8Gi。下面分别创建 pv 资源文件, 注意这里的 server 地址就是 nfs 服务器所在地址。
创建 pv-prometheus-2g.yaml 文件,内容如下:
apiVersion: v1
kind: PersistentVolume
metadata:
name: prometheus-2g
spec:
capacity:
storage: 2Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
nfs:
server: 10.110.101.106
path: /data/nfs/prometheus/2g
创建 pv-prometheus-8g.yaml 文件,内容如下:
apiVersion: v1
kind: PersistentVolume
metadata:
name: prometheus-8g
spec:
capacity:
storage: 8Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
nfs:
server: 10.110.101.106
path: /data/nfs/prometheus/8g
执行如下语句创建 pv:
kubectl apply -f pv-prometheus-2g.yaml
kubectl apply -f pv-prometheus-8g.yaml
查看 pvc 状态:
kubectl get pvc -n prometheus
自此,pvc 和 pv 已经关联。
7 验证 prometheus
查看 prometheus pod 运行状态,发现 prometheus-server 并没有启动成功:
kubectl get pod -n prometheus
查看容器日志状态发现报如下错误:
err="Error loading config couldn't load configuration (--config.file=/etc/config/prometheus.yml): parsing YAML file /etc/config/prometheus.yml: yaml: line 160: mapping values are not allowed in this context"
解决方案:
kubectl edit configmap -n prometheus prometheus-prometheus-server
定位 “target_label: kubernetes_pod_namealerting:”
修改为:
修改完保存退出,然后删除 prometheus-prometheus-server pod,让控制器再重新生成新的 pod,从而读取修改过的 configmap 信息。再次查看整个 pod 状态,发现全部启动成功:
8 修改 service type
将 prometheus service type 修改为 NodePort 类型:
kubectl patch svc -n prometheus prometheus-prometheus-server -p '{"spec": {"type": "NodePort"}}'
kubectl get svc -n prometheus
9 访问 prometheus
打开浏览器,访问 prometheus-server,注意端口正确,本人是 30347:
Since then, helm3 easy installation prometheus after blasting.