先决条件: 已经部署好k8s
#这里我使用的版本是1.28.12
[root@prometheus-operator /zpf/prometheus/kube-prometheus/manifests]$kubectl version
Client Version: v1.28.12
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.28.12
安装git服务
#安装git服务,用于后面拉取prometheus代码
[root@prometheus-operator /zpf/prometheus/kube-prometheus/manifests]$yum install git -y
下载kube-prometheus 源代码
#说明一下这里默认拉取的是最新版本的代码版本.可以根据自己的k8s版本来获取对应的kube-prometheus代码版本
#拉取代码
[root@prometheus-operator /zpf/prometheus/kube-prometheus/manifests]$git clone https://github.com/prometheus-operator/kube-prometheus.git
下面是部分兼容性示例图,

代码拉取完成后会有一个kube-prometheus目录以下是相关的源码内容.
[root@prometheus-operator /zpf/prometheus]$cd kube-prometheus/
[root@prometheus-operator /zpf/prometheus/kube-prometheus]$ls
build.sh CONTRIBUTING.md example.jsonnet go.mod jsonnetfile.json kustomization.yaml manifests scripts
CHANGELOG.md developer-workspace examples go.sum jsonnetfile.lock.json LICENSE README.md tests
code-of-conduct.md docs experimental jsonnet kubescape-exceptions.json Makefile RELEASE.md
[root@prometheus-operator /zpf/prometheus/kube-prometheus]$cd manifests/
[root@prometheus-operator /zpf/prometheus/kube-prometheus/manifests]$ls
.
.
.
grafana-config.yaml nodeExporter-prometheusRule.yaml prometheus-podDisruptionBudget.yaml
grafana-dashboardDatasources.yaml nodeExporter-serviceAccount.yaml prometheus-prometheusRule.yaml
grafana-dashboardDefinitions.yaml nodeExporter-serviceMonitor.yaml prometheus-prometheus.yaml
.
.
.
setup
#这里的setup是一个目录
首先创建预置资源,注册相关的资源项目
#当前目录位置
[root@prometheus-operator /zpf/prometheus/kube-prometheus/manifests]$pwd
/zpf/prometheus/kube-prometheus/manifests
#创建注册相关资源
[root@prometheus-operator /zpf/prometheus/kube-prometheus/manifests]$kubectl create -f ./setup/
customresourcedefinition.apiextensions.k8s.io/alertmanagerconfigs.monitoring.coreos.com created
customresourcedefinition.apiextensions.k8s.io/alertmanagers.monitoring.coreos.com created
customresourcedefinition.apiextensions.k8s.io/podmonitors.monitoring.coreos.com created
customresou

最低0.47元/天 解锁文章
340

被折叠的 条评论
为什么被折叠?



