open /prometheus/queries.active: permission denied(已解决)

部署prom时,prom的
kubectl -n monitoring get pod
pod的状态为error
在这里插入图片描述
出现error一般是容器里面有报错,所以需要查看日志
#查看pod的log日志

kubectl logs prometheus-deployment-6495dcc86c-jtkxw

在这里插入图片描述
可知,没有创建这个目录的权限,
解决办法,使用initcontainer为目录赋予权限

我的配置:

    spec:
      initContainers:
          - name: "init-datapath"
            image: debian:stable
            command: ["chown", "-R", "65534:65534", "/prometheus"]
            command: ["/bin/chmod","-R","777","/prometheus"]
            volumeMounts:
            - name: prometheus-storage-volume
              mountPath: /prometheus
              subPath: ""
      containers:
        - name: prometheus
          image: prom/prometheus
          args:
            - "--storage.tsdb.retention.time=12h"
            - "--config.file=/etc/prometheus/prometheus.yml"
            - "--storage.tsdb.path=/prometheus/"
          ports:
            - containerPort: 9090
          resources:
            requests:
              cpu: 500m
              memory: 500M
            limits:
              cpu: 1
              memory: 1Gi
          volumeMounts:
            - name: prometheus-config-volume
              mountPath: /etc/prometheus/
            - name: prometheus-storage-volume
              mountPath: /prometheus/
      volumes:
        - name: prometheus-config-volume
          configMap:
            defaultMode: 420
            name: prometheus-server-conf
  
        - name: prometheus-storage-volume
          persistentVolumeClaim:
            claimName: pvc-nfs-data

最后查看状态,
在这里插入图片描述
解决!

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要运行docker命令"docker run -p 9090:9090 -v /etc/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus",你需要先按照Prometheus镜像,可以使用命令"docker pull prom/prometheus"来下载镜像。然后,你需要创建一个名为prometheus.yml的文件,可以使用以下命令来创建和编辑该文件: ``` mkdir /usr/local/notribe/prometheus cd /usr/local/notribe/prometheus vim prometheus.yml ``` 在打开的编辑器中,你可以将以下内容粘贴到prometheus.yml文件中: ``` global: scrape_interval: 15s evaluation_interval: 15s scrape_configs: - job_name: 'prometheus' static_configs: - targets: ['localhost:9090'] ``` 保存并关闭文件。现在,你可以使用以下命令来运行Prometheus容器并将prometheus.yml文件挂载到容器中: ``` docker run -d --name=prometheus -p 9090:9090 -v /usr/local/notribe/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus:latest ``` 这将在后台运行一个名为"prometheus"的容器,并将主机的9090端口映射到容器的9090端口,同时将prometheus.yml文件挂载到容器的/etc/prometheus/prometheus.yml路径下。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [使用docker安装Prometheus](https://blog.csdn.net/xgkgcs/article/details/119148413)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *3* [prometheus-docker-sd:Docker容器的Prometheus服务发现](https://download.csdn.net/download/weixin_42127775/18439980)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值