首页 > 编程语言 >k8s 部署 node exporter

k8s 部署 node exporter

时间:2024-10-22 12:23:39浏览次数:6  
标签:node exporter name host path k8s proc

创建namespace

node-exporter-namespace.yaml

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

拉取镜像

quay.io/prometheus/node-exporter:v0.18.1

node exporter的DaemonSet

node-exporter-daemonSet.yaml

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: node-exporter
  namespace:  ns-monitor
  labels:
    name: node-exporter
spec:
  selector:
    matchLabels:
     name: node-exporter
  template:
    metadata:
      labels:
        name: node-exporter
    spec:
      containers:
      - name: node-exporter
        image: quay.io/prometheus/node-exporter:v0.18.1
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 9100
        resources:
          requests:
            cpu: 0.15
        securityContext:
          privileged: true
        args:
        - --path.procfs
        - /host/proc
        - --path.sysfs
        - /host/sys
        - --collector.filesystem.ignored-mount-points
        - '"^/(sys|proc|dev|host|etc)($|/)"'
        volumeMounts:
        - name: dev
          mountPath: /host/dev
        - name: proc
          mountPath: /host/proc
        - name: sys
          mountPath: /host/sys
        - name: rootfs
          mountPath: /rootfs
      tolerations:
      - key: "node-role.kubernetes.io/master"
        operator: "Exists"
        effect: "NoSchedule"
      volumes:
        - name: proc
          hostPath:
            path: /proc
        - name: dev
          hostPath:
            path: /dev
        - name: sys
          hostPath:
            path: /sys
        - name: rootfs
          hostPath:
            path: /

node exporter的service

node-exporter-service.yaml

apiVersion: v1
kind: Service
metadata:
  labels:
    k8s-app: node-exporter
  name: node-exporter
  namespace: ns-monitor
spec:
  ports:
  - name: http
    port: 9100
	targetPort:9100
    nodePort: 31672
    protocol: TCP
  type: NodePort
  selector:
    name: node-exporter

如果不使用Service部署,而使用hostNetwork方式部署可以不需要node-exporter-service.yaml文件。直接使用一下node-exporter-daemonSet.yaml即可

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: node-exporter
  namespace:  ns-monitor
  labels:
    name: node-exporter
spec:
  selector:
    matchLabels:
     name: node-exporter
  template:
    metadata:
      labels:
        name: node-exporter
    spec:
	  hostPID: true        # 使用主机的PID
      hostIPC: true        # 使用主机的IPC
      hostNetwork: true    # 使用主机的网络
      containers:
      - name: node-exporter
        image: quay.io/prometheus/node-exporter:v0.18.1
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 9100
        resources:
          requests:
            cpu: 0.15
        securityContext:
          privileged: true
        args:
        - --path.procfs
        - /host/proc
        - --path.sysfs
        - /host/sys
        - --collector.filesystem.ignored-mount-points
        - '"^/(sys|proc|dev|host|etc)($|/)"'
        volumeMounts:
        - name: dev
          mountPath: /host/dev
        - name: proc
          mountPath: /host/proc
        - name: sys
          mountPath: /host/sys
        - name: rootfs
          mountPath: /rootfs
      tolerations:
      - key: "node-role.kubernetes.io/master"
        operator: "Exists"
        effect: "NoSchedule"
      volumes:
        - name: proc
          hostPath:
            path: /proc
        - name: dev
          hostPath:
            path: /dev
        - name: sys
          hostPath:
            path: /sys
        - name: rootfs
          hostPath:
            path: /

多增加了

	  hostPID: true        # 使用主机的PID
      hostIPC: true        # 使用主机的IPC
      hostNetwork: true    # 使用主机的网络

启动

kubectl apply -f node_export-namespace.yaml
kubectl apply -f .

查看

kubectl get pod -n ns-monitor -o wide
kubectl get svc -n ns-monitor

访问

http://10.0.2.13:31672

10.0.2.13为宿主机的ip,31672为node exporter service的port

标签:node,exporter,name,host,path,k8s,proc
From: https://www.cnblogs.com/happyhuangjinjin/p/18492308

相关文章

  • k8s 部署 tomcat
    创建namespacetomcat-namespace.yamlapiVersion:v1kind:Namespacemetadata:name:ns-tomcat创建Deploymenttomcat-deployment.yamlapiVersion:apps/v1kind:Deploymentmetadata:name:tomcat-deploymentnamespace:ns-tomcatspec:replicas:1selector:matchLa......
  • k8s部署nginx
    创建namespacenginx-namespace.yamlapiVersion:v1kind:Namespacemetadata:name:ns-nginx创建Deploymentnginx-deployment.yamlapiVersion:apps/v1kind:Deploymentmetadata:name:nginx-deploymentnamespace:ns-nginxspec:selector:matchLabels:......
  • k8s 部署 prometheus
    创建namespaceprometheus-namespace.yamlapiVersion:v1kind:Namespacemetadata:name:ns-prometheus拉取镜像dockerpullswr.cn-north-4.myhuaweicloud.com/ddn-k8s/quay.io/prometheus/prometheus:v2.54.0prometheus配置文件configmapprometheus-configmap.yaml......
  • k8s 部署 grafana
    创建namespacegrafana-namespace.yamlapiVersion:v1kind:Namespacemetadata:name:ns-grafana拉取镜像swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/rancher/mirrored-grafana-grafana:10.3.3grafana的Deploymentgrafana-deployment.yamlapiVersion:apps......
  • Node.js 创建MySql服务
    1.MySql服务1.安装依赖在终端执行如下脚本:npminstallmysql2npminstallcorsnpminstallexpress2.连接数据库并创建获取数据Apijs文件:index.jsconstexpress=require('express');constmysql=require('mysql2');constcors=require('cors');constap......
  • K8s - Helm的使用
    安装Helmhttps://helm.sh/zh/docs/https://github.com/helm/helm/releaseshttps://get.helm.sh/helm-v3.16.2-linux-amd64.tar.gz在master节点安装Helm[root@k8s-master~]#tar-xvzfhelm-v3.16.2-linux-amd64.tar.gzlinux-amd64/linux-amd64/LICENSElinux-amd64/h......
  • 基于node.js+vue河北水利电力学院校园图书馆热门借阅书目智慧推荐系统(开题+程序+论文)
    本系统(程序+源码+数据库+调试部署+开发环境)带文档lw万字以上,文末可获取源码系统程序文件列表开题报告内容进度安排:2023.10.8--2023.11.7:指导教师出题、教研室审核、学院审核、选题系统导入、选题。2023.11.8--2023.11.12:对选题进行详细的了解分析,查看文献完成任务书。2......
  • Node.js EventEmitter
    Node.jsEventEmitterNode.js所有的异步I/O操作在完成时都会发送一个事件到事件队列。Node.js里面的许多对象都会分发事件:一个net.Server对象会在每次有新连接时触发一个事件,一个fs.readStream对象会在文件被打开的时候触发一个事件。所有这些产生事件的对象都是even......
  • 基于node.js+vue基于Android的商品房验收服务平台设计与实现(开题+程序+论文)计算机毕业
    本系统(程序+源码+数据库+调试部署+开发环境)带文档lw万字以上,文末可获取源码系统程序文件列表开题报告内容一、选题背景随着房地产市场的不断发展,商品房的质量验收成为购房者关注的焦点。关于商品房验收的研究,现有研究主要以整体建筑质量评估、相关法律法规探讨为主 1。专......
  • 基于node.js+vue基于Android的租房平台的设计与实现(开题+程序+论文)计算机毕业设计
    本系统(程序+源码+数据库+调试部署+开发环境)带文档lw万字以上,文末可获取源码系统程序文件列表开题报告内容一、选题背景关于租房平台的研究,现有研究主要以传统租房模式或Web端租房平台为主。在移动互联网迅速发展的当下,专门针对基于Android的租房平台的研究较少。随着智能......