前言

使用 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. React部署到线上Nginx环境中刷新页面后404解决方案

    我们需要在Nginx的配置文件中修改以下内容(通常Nginx配置文件位置为/etc/nginx/nginx.conf): server { # ... location / { # ... # 增加下 ...

  2. Qt编译数据库插件通用步骤说明

    近期特意花了点时间,在之前数据库集成应用这个组件的基础上再次迭代完善,历经九九八十一难,将Qt的各种数据库插件,十几个Qt版本,全部编译一遍,同时打通了插件形式直连数据库和ODBC数据源连接方式,做过 ...

  3. C#中串口类SerialPort类的详细用法

    原文链:serialport控件的详细用法

  4. 跟着源码一起学:手把手教你用WebSocket打造Web端IM聊天

    本文作者芋艿,原题"芋道 Spring Boot WebSocket 入门",本次有修订和改动. 一.引言 WebSocket如今在Web端即时通讯技术应用里使用广泛,不仅用于传统 ...

  5. milvus操作

    java 引入依赖 <dependency> <groupId>io.milvus</groupId> <artifactId>milvus-sdk-j ...

  6. springboot整合security实现权限控制

    1.建表,五张表,如下:1.1.用户表CREATE TABLE `t_sys_user` ( `user_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT ...

  7. 第八章 (Nginx+Lua)流量复制/AB测试/协程

    流量复制 在实际开发中经常涉及到项目的升级,而该升级不能简单的上线就完事了,需要验证该升级是否兼容老的上线,因此可能需要并行运行两个项目一段时间进行数据比对和校验,待没问题后再进行上线.这其实就需要进 ...

  8. 利用mybatis拦截器记录sql,辅助我们建立索引(二)

    背景 上一篇中讲述了mybatis的mapper初始化过程和执行过程,这篇再讲讲具体的拦截器的使用,以实现记录sql到持久化存储,通过分析这些sql,我们就能更方便地建立索引. 利用mybatis拦截 ...

  9. 060_面向过程和面向对象区别 061_对象是什么_对象和数据管理 062_对象和类的关系_属性_成员变量_方法 063_一个典型类的写法和调用_类的UML图入门 064_内存分析详解_栈_堆_方法区_栈帧_程序执行的内存变化过程

    060_面向过程和面向对象区别 061_对象是什么_对象和数据管理 062_对象和类的关系_属性_成员变量_方法 public class SxtStu {//定义了一个类,包含的成员变量,属性,方法 ...

  10. ctfshow--web9 md5二进制格加密的绕过

    dirsearch 扫到robots文件 查看一下 发现有个index.phps文件 访问这个index.phps,可以下载下来 我们来审计一下这里的代码 <?php $flag="& ...