首页 > 其他分享 >k8s Error: failed to prepare subPath for volumeMount "custom-logo" of container "graf

k8s Error: failed to prepare subPath for volumeMount "custom-logo" of container "graf

时间:2023-05-23 13:03:00浏览次数:43  
标签:container name prepare svg subPath grafana logo custom

前言

使用 k8s 挂载卷文件时,使用了 hostPathtype: File

 volumeMounts:
        - mountPath: /usr/share/grafana/public/img/grafana_icon.svg
          name: custom-logo
          subPath: grafana_icon.svg
 volumes:
      - hostPath:
          path: /root/test/logo.svg
          type: File
        name: custom-logo

结果报错,kubectl describe pod

Error: failed to prepare subPath for volumeMount "volume-mount-name" of container "container-name"

报错原因为找不到 subPath,随后使用了 initContainers,在 busybox 镜像的 mkdir 命令初始化创建该目录:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: grafana
spec:
  replicas: 1
  selector:
    matchLabels:
      app: grafana
  template:
    metadata:
      labels:
        app: grafana
    spec:
      initContainers:
      - name: create-directories
        image: busybox
        command: ['sh', '-c', 'mkdir -p /usr/share/grafana/public/img']
        volumeMounts:
        - name: custom-logo
          mountPath: /usr/share/grafana/public/img
      containers:
      - name: grafana
        image: grafana/grafana:latest
        ports:
        - containerPort: 3000
        volumeMounts:
        - name: custom-logo
          mountPath: /usr/share/grafana/public/img/grafana_icon.svg
          subPath: grafana_icon.svg
      volumes:
      - name: custom-logo
        hostPath:
          path: /root/test/logo.svg

这时 pod 状态为 Init:CrashLoopBackOff,而 kubectl describe pod,报错 Back-off restarting failed container,索性就不使用 subPath 了。

最终写法

 volumeMounts:
        - mountPath: /usr/share/grafana/public/img/grafana_icon.svg
          name: custom-logo
 volumes:
      - hostPath:
          path: /root/test/logo.svg
          type: File
        name: custom-logo

成功挂载使用了 /root/test/logo.svg 文件。

标签:container,name,prepare,svg,subPath,grafana,logo,custom
From: https://www.cnblogs.com/niuben/p/17424216.html

相关文章

  • 当k8s拉镜像出现问题时 需要修改 /etc/containerd/config.toml 配置
    找到plugins."io.containerd.grpc.v1.cri".registry添加此两处配置 [plugins."io.containerd.grpc.v1.cri".registry.configs][plugins."io.containerd.grpc.v1.cri".registry.configs."192.168.16.185:8088".tls]insecu......
  • 关于CentOS8出现“Error: Failed to download metadata for repo 'appstream': Cannot
    原因因为centOS8于2021年12月31日停止了源的服务,而现在时间是2023年,所以之前的方法都不行的原因所在(本质是源的问题)。 解决方法 cd/etc/yum.repos.dsed-i's/mirrorlist/#mirrorlist/g'/etc/yumrepos.d/CentOS-*sed-i's|#baseurl=http://mirror.centos.o......
  • containerlab 简单试用
    以下是containerlab简单试用的测试预备需要docker环境安装基于vm运行yum-config-manager--add-repo=https://yum.fury.io/netdevops/&&\echo"gpgcheck=0"|sudotee-a/etc/yum.repos.d/yum.fury.io_netdevops_.reposudoyuminstallcontainerlab......
  • k8s主备Master安装(Containerd)
    原创文档编写不易,未经许可请勿转载。文档中有疑问的可以邮件联系我。邮箱:[email protected]文章基于CentOS7.8系统使用Containerdr作为容器运行时通过kubeadm指导搭建k8s多master节点集群。必备条件:需要服务器可以联网。环境节点说明主机名IP地址操作系统作用ma......
  • 【深入浅出 Yarn 架构与实现】6-4 Container 生命周期源码分析
    本文将深入探讨AM向RM申请并获得Container资源后,在NM节点上如何启动和清理Container。将详细分析整个过程的源码实现。一、Container生命周期介绍Container的启动由ApplicationMaster通过调用RPC函数ContainerManagementProtocol#startContainers()发起请求,NM......
  • JDBC学习日志四,PreparedStatement
    PreparedStatement可以防止sql注入问题,效率更高先进行预编译sql,将要设置的字段值使用占位符本质:预编译会将传递进来的参数包裹成字符,而单引号会被转义字符转换为空内容,有效的防止sql注入的问题CRUD--SELECTStringsql="select*fromuserswhereid=?";st=......
  • Containerd 的 Bug 导致容器被重建!如何避免?
    作者简介邓宇星,SUSERancher中国区软件架构师,6年云原生领域经验,参与Rancher1.x到Rancher2.x版本迭代,目前负责RancherForopenEuler(RFO) 项目开发。最近我们关注到一个关于 containerd运行时的 issue(https://github.com/containerd/containerd/issues/7843),该问题在co......
  • k8s-mount中subpath的用法
    1.k8s中挂载的如果是pvc,那么挂载的应该是目录,在subpath处如果有填写,那subpath处是volume的子目录,也就是说把容器的mountpath的路径,映射到相应的volume里的path路径里,例如将mysql里的/var/lib/mysql映射到volume下的mysql目录,则subpath为mysql,如果是直接映射到volume只subpath空......
  • 一、全面理解JWT | 二、对比Statement与prepareStatemen
    一、全面理解JWT-海~~D-博客园(cnblogs.com)结合抖音:@渡一Web前端学习频道---->第179集|彻底理解JWT可以更透彻的弄清JWT。 二、javaJDBCStatement的用途对比Statement与prepareStatement1.Statement存在SQL注入,PrepareStatement不存在SQL注入......
  • 威联通NAS使用Container搭建我的世界服务器,带网页管理面板
    QNAP使用LXC容器搭建Minecraft游戏服务器,带WEB管理面板Linux搭建我的世界服务器:https://blog.zeruns.tech/archives/584.htmlwindows搭建MC服务器教程:https://blog.zeruns.tech/archives/529.htmlMC开服交流群:966038270视频教程:https://www.bilibili.com/video/BV1Fv411471D/安卓安......