前言

使用 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 文件。

k8s Error: failed to prepare subPath for volumeMount "custom-logo" of container "grafana"的更多相关文章

  1. IDEA升级,提示"Connection Error Failed to prepare an update"

    问题来源: 之前修改了IDEA的默认配置文件路径,然后升级新版本时就无法升级,提示"Failed to prepare an update Temp directory inside ins ...

  2. IDEA Failed to prepare an update: Temp directory inside installation

    具体错误: Connection Error Failed to prepare an update: Temp directory inside installation: F:\IDEA_Tool ...

  3. Arch更新时failed to prepare transaction

    error: failed to prepare transaction (could not satisfy dependencies) :: ffmpeg2.8: installing x265 ...

  4. linux下yum无法安装lrzsz,Error: Failed to download metadata for repo ‘appstream‘: Cannot prepare internal

    镜像下载.域名解析.时间同步请点击阿里云开源镜像站 linux虚拟机上准备安装一下rz sz,执行yum命令后提示如下: [root@tony001 ~]# yum install lrzsz Cen ...

  5. log4j:ERROR Failed to rename [/log/xxx.log] to [/log/xxx.log.2016-11-23.log]

    Log4j报错: log4j:ERROR Failed to rename [/log/xxx.log] to [/log/xxx.log.2016-11-23.log] google了一下发现是个b ...

  6. git rebase与 git合并(error: failed to push some refs to)解决方法

    1.遇到的问题 本地有一个git仓库,在github上新建了一个空的仓库,但是更新了REWADME.md的信息,即在github上多了一个提交. 关联远程仓库,操作顺序如下: git remote a ...

  7. GConf error:Failed to contact configuration server

    Linux系统运行一直正常,但是图形界面使用root账号登录时遇到下面错误,第一次遇到这么怪异的状况 具体错误信息如下所示: GConf error:Failed to contact configu ...

  8. [ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.3.1:

    security-sdk-1.0.jar已经存在于D:/secServerSDK-test/src/main/resources/lib下 报错如下: xxxxxx@xxxxxxxx /d/secSe ...

  9. Spring Boot + Bootstrap 出现"Failed to decode downloaded font"和"OTS parsing error: Failed to convert WOFF 2.0 font to SFNT"

    准确来讲,应该是maven项目使用Bootstrap时,出现 "Failed to decode downloaded font"和"OTS parsing error: ...

  10. [ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.4:create (default-cli) on project standalone-pom: Unable to parse configuration of 3: mojo org.apache.maven.plugins:

    问题: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.4:create (defau ...

随机推荐

  1. SolidState靶机通关教程及提权

    声明!本文章及工具分享仅仅只是供大家学习交流为主,如有任何触犯法律的行为,均与本人及团队无关!!! 工具链接:https://pan.quark.cn/s/33795a10039c 一.靶机搭建 点击 ...

  2. FLASK的基础

    1.导入flask from flask import Flask  #导入所需要的包 app = Flask(__name__)  #实例化对象 @app.route('/hello') #装饰器r ...

  3. 以大模型攻大模型之💫Jailbreaking Black Box Large Language Models in 🎢Twenty Queries

    "在高层次上,PAIR将两个黑盒LLMs--我们称之为攻击者和目标--相互对抗--"具体是如何对抗的?请各位看官仔细阅读~

  4. ThreeJs-12使用着色器加工材质

    一.three框架材质原理与应用 其实three里面所有的材质不管是基础还是点等等之类最终都会编译为shader然后执行,所以如果拿到一个材质我想对某个地方小改一下,那么也是可以用shader来进行修 ...

  5. 给DevOps加点料:融入安全性的DevSecOps

    从前,安全防护只是特定团队的责任,在开发的最后阶段才会介入.当开发周期长达数月.甚至数年时,这样做没什么问题:但是现在,这种做法现在已经行不通了.采用 DevOps 可以有效推进快速频繁的开发周期(有 ...

  6. Solution Set -「LOCAL」冲刺省选 Round XXXI

    \(\mathscr{Summary}\)   前期节奏太懒散,后面发现 C 题是水题都没时间写,提起精神来啊!   A 题卡得比较久,对线性基的理解不够深刻,思来想去半天才把转移系数调对.B 题也卡 ...

  7. CDS标准视图:设备描述 I_EquipmentText

    视图名称: I_EquipmentText 视图类型:基础视图 视图代码: 点击查看代码 @EndUserText.label: 'Equipment - Text' @ObjectModel.dat ...

  8. Java技术栈总结-提升

    1 java基础: 1.1 算法 1.1 排序算法:直接插入排序.希尔排序.冒泡排序.快速排序.直接选择排序.堆排序.归并排序.基数排序 1.2 二叉查找树.红黑树.B树.B+树.LSM树(分别有对应 ...

  9. PDCA使用指南详解(史上最强)

    PDCA循环,一个老话题了,大家都知道要这么做,但在平时的生活和工作当中,你是否真的都这样做呢? 当你发现你面对的困难重重,寸步难行时,是否反思过是因为自己一开始的方法就不正确? 本文包涵了PDCA循 ...

  10. MongoDB:【索引的管理操作】