当前位置: 首页 > news >正文

k8s 部署 prometheus

创建namespace

prometheus-namespace.yaml

apiVersion: v1
kind: Namespace
metadata:name: ns-prometheus

拉取镜像

docker pull swr.cn-north-4.myhuaweicloud.com/ddn-k8s/quay.io/prometheus/prometheus:v2.54.0

prometheus配置文件configmap

prometheus-configmap.yaml

apiVersion: v1
kind: ConfigMap
metadata:name: prometheus-confignamespace: ns-prometheus
data:prometheus.yml: |-# Prometheus配置内容global:scrape_interval: 15sevaluation_interval: 15sscrape_configs:- job_name: 'prometheus'static_configs:- targets: ['localhost:9090', '10.0.2.13:31672']

localhost:9090为prometheus服务自己本身的metrics;10.0.2.13:31672为node exporter的metrics。targets是一个数组可以增加多个。

prometheus 的 Deployment

prometheus-deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:name: prometheusnamespace: ns-prometheus
spec:replicas: 1selector:matchLabels:name: prometheustemplate:metadata:labels:name: prometheusspec:# hostNetwork: truecontainers:- name: prometheusimage: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/quay.io/prometheus/prometheus:v2.54.0args:- --config.file=/etc/prometheus/prometheus.ymlports:- containerPort: 9090volumeMounts:- mountPath: /etc/prometheusname: prometheus-configvolumes:- name: prometheus-configconfigMap:name: prometheus-config

使用Service模式部署可以注释hostNetwork: true

prometheus 的 Service

prometheus-service.yaml

apiVersion: v1
kind: Service
metadata:name: prometheus-servicenamespace: ns-prometheus
spec:selector:name: prometheusports:- protocol: TCPport: 9090targetPort: 9090nodePort: 30090type: NodePort

启动

kubectl apply -f prometheus-namespace.yaml
kubectl apply -f prometheus-configmap.yaml
kubectl apply -f .

查看

kubectl get pod -n ns-prometheus
kubectl get svc -n ns-prometheus

访问

http://10.0.2.12:30090/

10.0.2.12为宿主机ip,30090为Service映射的port

http://www.lryc.cn/news/450873.html

相关文章:

  • 使用VBA快速生成Excel工作表非连续列图片快照
  • 解决GitHub下载速度慢
  • 【机器学习(五)】分类和回归任务-AdaBoost算法
  • 【设计模式-模板】
  • 小程序原生-列表渲染
  • JAVA认识异常
  • 2024年10月计划(工作为主,Ue5独立游戏为辅,)
  • 并发、并行和异步设计
  • 求职Leetcode题目(12)
  • 【YashanDB知识库】如何配置jdbc驱动使getDatabaseProductName()返回Oracle
  • Hadoop三大组件之MapReduce(一)
  • SQL Server 分页查询的学习文章
  • 告别PDF大文件困扰!4款PDF在线压缩工具助你轻松优化!
  • Find My汽车钥匙|苹果Find My技术与钥匙结合,智能防丢,全球定位
  • mysql学习教程,从入门到精通,SQL UNION 运算符(27)
  • PKCE3-PKCE实现(SpringBoot3.0)
  • C++详解vector
  • Redis实战--Redis的数据持久化与搭建Redis主从复制模式和搭建Redis的哨兵模式
  • World of Warcraft [CLASSIC] Engineering 421-440
  • VUE3.5版本解读
  • spark计算引擎-架构和应用
  • VUE 开发——AJAX学习(二)
  • 机器学习-KNN分类算法
  • 云计算 Cloud Computing
  • 【算法】DFS 系列之 穷举/暴搜/深搜/回溯/剪枝(上篇)
  • 怎么绕开华为纯净模式安装软件
  • CentOS7 离线部署docker和docker-compose环境
  • Vue 自定义组件实现 v-model 的几种方式
  • Python Pandas数据处理效率提升指南
  • 最大正方形 Python题解