前言

使用 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. Mybatis-plus关于代码生成器的使用

    1.添加依赖 2.在test包下创建一个CodeGet类,实现生成代码的功能.注意:全局配置.数据源配置一定要和自己的电脑配置一致! 3.执行CodeGet类中的main方法.打印台有如下图提示字样, ...

  2. 开源for Huawei,Beam适配GaussDB实践案例分享

    沃土云创开源开发者专项计划是华为给开源开发者提供专属激励资源,鼓励开发者积极参与开源 for Huawei适配,践行"让优秀开发者支持更优秀开发者"的理念. 之前我们介绍了fake ...

  3. PostgreSQL 数据库的启动与停止管理

    title: PostgreSQL 数据库的启动与停止管理 date: 2024/12/28 updated: 2024/12/28 author: cmdragon excerpt: 作为一个强大的 ...

  4. vue3项目中报错:Unexpected mutation of "xxx" prop

    vue3 中element 弹窗绑定需要通过v-model,这个时候父级会传个dialogVisible(boolean值)过来,结果会报eslint的错. Unexpected mutation o ...

  5. IDEA中基于SSM框架进行web开发部署项目到Tomcat时报错:Error:Cannot build artifact '******:war exploded' because it is included into a circular depency的解决办法

    在Idea中使用Maven创建父子工程,第一个Model的那个项目可以很好的运行,在创建一个Model运行时报这个错.原因是tomcat部署了多个Web项目,可能最开始是两个项目的配置文件混用用,最后 ...

  6. R语言画图常用参数

    plot(x,xlab = "degree",ylab = "number of nodes",main = "mRNA degree distrib ...

  7. PyScript 使用(1)

    今天按照官方文档进行pyscript的调用,发现paths下总是出现问题,于是调试了一下,问题解决了: # data.py import numpy as np def make_x_and_y(n) ...

  8. KeyDB-键值存储

    KeyDB项目是从redis fork出来的分支.众所周知redis是一个单线程的kv内存存储系统,而KeyDB在100%兼容redis API的情况下将redis改造成多线程. 多线程架构 线程模型 ...

  9. iptables使用详解(示例如何屏蔽docker 暴露的端口)

    [场景]搭建了一台CentOS虚拟机,并在上面搭了DOCKER,然后再DOCKER中安装Mysql.但只要将网络端口映射到宿主机上,那么外部网络就可以直接访问该数据.为此,我们需要使用防火墙(暂且不考 ...

  10. 正确停止Oracle expdp/impdp作业操作方法

    1.使用命令查看在运行的作业名称,找到STATE是EXECUTING的作业名称. select job_name,state from dba_datapump_jobs; 2.再CMD命令窗口,键入 ...