K8S - 理解volumeMounts 中的subpath

Kubernetes概念详解之:subPath字段的使用原理及案例分析 阅读详情
AI摘要

本文介绍了Spring Boot服务在K8S上的部署过程,包括放置配置文件、修改Dockerfile、构建和部署镜像、编写K8S YAML文件等。还探讨了使用ConfigMap管理配置,实时修改配置,以及处理Volumes Mount覆盖文件夹问题,同时提及了Subpath方法及其限制。

在上一篇文章中
springboot service如何动态读取外部配置文件

介绍了springboot 中如何实时读取外部配置文件的内容



部署在K8S

接下来我把它部署在k8s



首先, 我们把配置文件放入项目某个目录

这步部是必须的, 毕竟我们要引入是项目外部的文件, 这一步只是方便在不同CICD 环境下的docker 构建
我们就放在 src 外面的configs folder
在这里插入图片描述


修改docker file

# use the basic openjdk image
FROM openjdk:17

# setup working directory
WORKDIR /app

# create /app/config
RUN mkdir -p /app/config/config2

# copy configs files from project folder to /app/config
# When using COPY with more than one source file, the destination must be a directory and end with a /
COPY configs/external-config.properties /app/config/
COPY configs/external-config2.properties /app/config/config2/

# copy and rename jar file into container
COPY target/*.jar app.jar

# expose port
EXPOSE 8080

# define environment variable, and provide a default value
ENV APP_ENVIRONMENT=dev

# define the default startup command, it could be overridden in k8s
# CMD java -jar -Dserver.port=8080 -Dspring.config.name=application-${APP_ENVIRONMENT} app.jar
CMD java -jar -Dserver.port=8080 app.jar --spring.profiles.active=${APP_ENVIRONMENT}

需要创建/app/configs 并把配置文件复制到这里, 因为springboot service 会从这个path读取
注意有两个config 文件, 他们并不在同1个folder
external-config2.properties 在subfolder config2里面



构建镜像和部署镜像到GAR

这一步我们用google cloudbuild 完成
至于cloudbuild 的介绍请参考
初探 Google 云原生的CICD - CloudBuild

cloudbuild-gcr.yaml

# just to update the docker image to GAR with the pom.xml version

steps:
  - id: run maven install
    name: maven:3.9.6-sapmachine-17 # https://hub.docker.com/_/maven
    entrypoint: bash
    args:
      - '-c'
      - |
        whoami
        set -x
        pwd
        mvn install
        cat pom.xml | grep -m 1 "<version>" | sed -e 's/.*<version>\([^<]*\)<\/version>.*/\1/' > /workspace/version.txt
        echo "Version: $(cat /workspace/version.txt)"


  - id: build and push docker image
    name: 'gcr.io/cloud-builders/docker'
    entrypoint: bash
    args:
      - '-c'
      - |
        set -x
        echo "Building docker image with tag: $(cat /workspace/version.txt)"
        docker build -t $_GAR_BASE/$PROJECT_ID/$_DOCKER_REPO_NAME/${_APP_NAME}:$(cat /workspace/version.txt) .
        docker push $_GAR_BASE/$PROJECT_ID/$_DOCKER_REPO_NAME/${_APP_NAME}:$(cat /workspace/version.txt)


logsBucket: gs://jason-hsbc_cloudbuild/logs/
options: # https://cloud.google.com/cloud-build/docs/build-config#options
  logging: GCS_ONLY # or CLOUD_LOGGING_ONLY https://cloud.google.com/cloud-build/docs/build-config#logging



substitutions:
  _DOCKER_REPO_NAME: my-docker-repo
  _APP_NAME: cloud-order
  _GAR_BASE: europe-west2-docker.pkg.dev

部署完成后, 我们得到1个gar的对应image的url
europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/cloud-order:1.1.0



编写k8s yaml 和部署到k8s

apiVersion: apps/v1
kind: Deployment
metadata:
  labels: # label of this deployment
    app: cloud-order # custom defined
    author: nvd11
  name: deployment-cloud-order # name of this deployment
  namespace: default
spec:
  replicas: 3            # desired replica count, Please note that the replica Pods in a Deployment are typically distributed across multiple nodes.
  revisionHistoryLimit: 10 # The number of old ReplicaSets to retain to allow rollback
  selector: # label of the Pod that the Deployment is managing,, it's mandatory, without it , we will get this error 
            # error: error validating data: ValidationError(Deployment.spec.selector): missing required field "matchLabels" in io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector ..
    matchLabels:
      app: cloud-order
  strategy: # Strategy of upodate
    type: RollingUpdate # RollingUpdate or Recreate
    rollingUpdate:
      maxSurge: 25% # The maximum number of Pods that can be created over the desired number of Pods during the update
      maxUnavailable: 25% # The maximum number of Pods that can be unavailable during the update
  template: # Pod template
    metadata:
      labels:
        app: cloud-order # label of the Pod that the Deployment is managing. must match the selector, otherwise, will get the error Invalid value: map[string]string{"app":"bq-api-xxx"}: `selector` does not match template `labels`
    spec: # specification of the Pod
      containers:
      - image: europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/cloud-order:1.1.0 # image of the container
        imagePullPolicy: Always
        name: container-cloud-order
        command: ["bash"]
        args: 
          - "-c"
          - |
            java -jar -Dserver.port=8080 app.jar --spring.profiles.active=$APP_ENVIRONMENT
        env: # set env varaibles
        - name: APP_ENVIRONMENT # name of the environment variable
          value: prod # value of the environment variable
            
            
      restartPolicy: Always # Restart policy for all containers within the Pod
      terminationGracePeriodSeconds: 10 # The period of time in seconds given to the Pod to terminate gracefully

没什么特别

部署:

gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ kubectl apply -f deployment-cloud-order-with-subpath.yaml 
deployment.apps/deployment-cloud-order created
gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ kubectl get pods
NAME                                         READY   STATUS      RESTARTS       AGE
deployment-bq-api-service-6f6ffc7866-8djx9   1/1     Running     3 (12d ago)    17d
deployment-bq-api-service-6f6ffc7866-g4854   1/1     Running     12 (12d ago)   61d
deployment-bq-api-service-6f6ffc7866-lwxt7   1/1     Running     14 (12d ago)   63d
deployment-bq-api-service-6f6ffc7866-mxwcq   1/1     Running     11 (12d ago)   61d
deployment-cloud-order-58ddcf894d-8pjsz      1/1     Running     0              5s
deployment-cloud-order-58ddcf894d-mp4js      1/1     Running     0              5s
deployment-cloud-order-58ddcf894d-sszjd      1/1     Running     0              5s

检查容器内的配置文件:

gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ kubectl exec -it deployment-cloud-order-58ddcf894d-8pjsz -- /bin/bash
bash-4.4# pwd
/app
bash-4.4# ls config
config2  external-config.properties
bash-4.4# ls config/config2/
external-config2.properties
bash-4.4# 



测试api

gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ curl http://www.jp-gcp-vms.cloud:8085/cloud-order/actuator/info | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1842    0  1842    0     0   1827      0 --:--:--  0:00:01 --:--:--  1829
{
  "app": "Cloud Order Service",
  "appEnvProfile": "prod",
  "version": "1.1.0",
  "hostname": "deployment-cloud-order-58ddcf894d-8pjsz",
  "dbUrl": "jdbc:mysql://192.168.0.42:3306/demo_cloud_order?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true",
  "description": "This is a simple Spring Boot application to for cloud order...",
  "customConfig1": "value of config1",
  "customConfig2": "value of config2",
  }
}

注意 customConfig1 和 customConfig2 的值, 部署是成功的



For customConfig2 使用configMap

由于customConfig2 是实时更新的
我们尝试用configmap 来取代 上面external-config2.properties 的配置
注意这里的值改成 value of config2 - from k8s configmap 方便区分



构建1个external-config2 的configmap 资源对象

configmap-cloud-order-external-config2.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: configmap-cloud-order-external-config2
data:
  external.custom.config2: external.custom.config2=value of config2 - from k8s configmap

部署:

gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ kubectl apply -f configmap-cloud-order-external-config2.yaml 
configmap/configmap-cloud-order-external-config2 created
gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ kubectl describe cm configmap-cloud-order-external-config2
Name:         configmap-cloud-order-external-config2
Namespace:    default
Labels:       <none>
Annotations:  <none>

Data
====
external.custom.config2:
----
external.custom.config2=value of config2 - from k8s configmap

BinaryData
====

Events:  <none>



修改deployment yaml 引入configmap

apiVersion: apps/v1
kind: Deployment
metadata:
  labels: # label of this deployment
    app: cloud-order # custom defined
    author: nvd11
  name: deployment-cloud-order # name of this deployment
  namespace: default
spec:
  replicas: 3            # desired replica count, Please note that the replica Pods in a Deployment are typically distributed across multiple nodes.
  revisionHistoryLimit: 10 # The number of old ReplicaSets to retain to allow rollback
  selector: # label of the Pod that the Deployment is managing,, it's mandatory, without it , we will get this error 
            # error: error validating data: ValidationError(Deployment.spec.selector): missing required field "matchLabels" in io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector ..
    matchLabels:
      app: cloud-order
  strategy: # Strategy of upodate
    type: RollingUpdate # RollingUpdate or Recreate
    rollingUpdate:
      maxSurge: 25% # The maximum number of Pods that can be created over the desired number of Pods during the update
      maxUnavailable: 25% # The maximum number of Pods that can be unavailable during the update
  template: # Pod template
    metadata:
      labels:
        app: cloud-order # label of the Pod that the Deployment is managing. must match the selector, otherwise, will get the error Invalid value: map[string]string{"app":"bq-api-xxx"}: `selector` does not match template `labels`
    spec: # specification of the Pod
      containers:
      - image: europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/cloud-order:1.1.0 # image of the container
        imagePullPolicy: Always
        name: container-cloud-order
        command: ["bash"]
        args: 
          - "-c"
          - |
            java -jar -Dserver.port=8080 app.jar --spring.profiles.active=$APP_ENVIRONMENT
        env: # set env varaibles
        - name: APP_ENVIRONMENT # name of the environment variable
          value: prod # value of the environment variable
        volumeMounts:
          - name: volume-external-config2
            mountPath: /app/config/config2/
	    volumes:
	      - name: volume-external-config2
	        configMap:
	          name: configmap-cloud-order-external-config2
	          items:
	            - key: external.custom.config2
	              path: external-config2.properties # name of the file to be mounted
            
            
      restartPolicy: Always # Restart policy for all containers within the Pod
      terminationGracePeriodSeconds: 10 # The period of time in seconds given to the Pod to terminate gracefully

注意这里使用了 volume 和 volumemount



重新部署 cloud-order service

gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ kubectl delete deploy deployment-cloud-order
deployment.apps "deployment-cloud-order" deleted
gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ kubectl apply -f deployment-cloud-order-with-subpath.yaml 
deployment.apps/deployment-cloud-order created



测试api

gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ curl http://www.jp-gcp-vms.cloud:8085/cloud-order/actuator/info | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1863    0  1863    0     0   3888      0 --:--:-- --:--:-- --:--:--  3889
{
  "app": "Cloud Order Service",
  "appEnvProfile": "prod",
  "version": "1.1.0",
  "hostname": "deployment-cloud-order-69d4cd76d6-hwtfj",
  "dbUrl": "jdbc:mysql://192.168.0.42:3306/demo_cloud_order?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true",
  "description": "This is a simple Spring Boot application to for cloud order...",
  "customConfig1": "value of config1",
  "customConfig2": "value of config2 - from k8s configmap",

并没什么大问题, 证明configmap 的配置是可以覆盖docker里面定义的配置文件的



实时修改configmap 的配置

这时我们修改一下 configmap configmap-cloud-order-external-config2 里的值
由 external.custom.config2: external.custom.config2=value of config2 - from k8s configmap
改成 external.custom.config2: external.custom.config2=value of config2 - from k8s configmap updated!

apiVersion: v1
kind: ConfigMap
metadata:
  name: configmap-cloud-order-external-config2
data:
  external.custom.config2: external.custom.config2=value of config2 - from k8s configmap updated!

更新:

gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ kubectl apply -f configmap-cloud-order-external-config2.yaml 
configmap/configmap-cloud-order-external-config2 configured

等半分钟后 (1是 k8s 需要时间把 configmap的值刷新到 pods里的volumes, 2时是springboot本身需要定时器去重新获取值)
再测试api

gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ curl http://www.jp-gcp-vms.cloud:8085/cloud-order/actuator/info | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1872    0  1872    0     0   3900      0 --:--:-- --:--:-- --:--:--  3900
{
  "app": "Cloud Order Service",
  "appEnvProfile": "prod",
  "version": "1.1.0",
  "hostname": "deployment-cloud-order-69d4cd76d6-qj98f",
  "dbUrl": "jdbc:mysql://192.168.0.42:3306/demo_cloud_order?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true",
  "description": "This is a simple Spring Boot application to for cloud order...",
  "customConfig1": "value of config1",
  "customConfig2": "value of config2 - from k8s configmap updated!",

果然customConfig2的值自动更新了, 正是我们想要的
而且容器里的文件也的确更新了

gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ kubectl exec -it deployment-cloud-order-69d4cd76d6-hwtfj -- /bin/bash
bash-4.4# pwd
/app
bash-4.4# ls config
config2  external-config.properties
bash-4.4# cat config/config2/external-config2.properties 
external.custom.config2=value of config2 - from k8s configmap updated!



volumes mount 会覆盖整个文件夹(其他文件被删除)

下面来点整活
我们修改一下deployment 的yaml 配置, 把configmap的值 mark成另1个文件名

  volumeMounts:
          - name: volume-external-config2
            mountPath: /app/config/config2/
	    volumes:
	      - name: volume-external-config2
	        configMap:
	          name: configmap-cloud-order-external-config2
	          items:
	            - key: external.custom.config2
	              path: external-config2-1.properties # name of the file to be mounted

按照设想, 容器内的configmap里的
/app/config/config2/ 文件内将会有两个文件

dockerfile 定义的external-config2.properties
和 k8s 定义的 external-config2-1.properties

实际部署测试:

gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ curl http://www.jp-gcp-vms.cloud:8085/cloud-order/actuator/info | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1837    0  1837    0     0    926      0 --:--:--  0:00:01 --:--:--   926
{
  "app": "Cloud Order Service",
  "appEnvProfile": "prod",
  "version": "1.1.0",
  "hostname": "deployment-cloud-order-6878b85d44-cdvlc",
  "dbUrl": "jdbc:mysql://192.168.0.42:3306/demo_cloud_order?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true",
  "description": "This is a simple Spring Boot application to for cloud order...",
  "customConfig1": "value of config1",
  "customConfig2": "not defined",

customConfig2 居然是not defined
检查容器
发现 external-config2.properties 没了

gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ kubectl exec -it deployment-cloud-order-6878b85d44-cdvlc -- /bin/bash
bash-4.4# ls
app.jar  config
bash-4.4# ls config
config2  external-config.properties
bash-4.4# ls config/config2/
external-config2-1.properties
bash-4.4# 

原因是 当k8s 把 volume volume-external-config2 mount在 /app/config/config2 中的时候, 原来的文件就会消失



尝试把新文件mount到1个subfolder

解决方法1:
把 volume volume-external-config2 mount在 /app/config/config2/config-sub
应该可以解决

我们修改deployment yaml

  volumeMounts:
          - name: volume-external-config2
            mountPath: /app/config/config2/config-sub
	    volumes:
	      - name: volume-external-config2
	        configMap:
	          name: configmap-cloud-order-external-config2
	          items:
	            - key: external.custom.config2
	              path: external-config2-1.properties # name of the file to be mounted

mountPath 改成了/app/config/config2/config-sub

这种方法是可行的

gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ kubectl exec -it deployment-cloud-order-654974f855-cmdz7 -- /bin/bash
bash-4.4# ls
app.jar  config
bash-4.4# cd config
bash-4.4# ls
config2  external-config.properties
bash-4.4# cd config2
bash-4.4# ls
config-sub  external-config2.properties
bash-4.4# cd config-sub
bash-4.4# ls
external-config2-1.properties
bash-4.4# 

而且证明了, mountpath中的路径不存在的话, k8s会尝试创建。



利用subpath 去把文件mount在同样的folder

但是上面的做法, 能把新文件mount在1个字母中, 的确不会另旧文件消失,但是并直接真正解决问题

K8S 提供了subpath 的方法:
我们修改deployment yaml

        volumeMounts:
          - name: volume-external-config2
            mountPath: /app/config/config2/external-config2-1.properties # if we need to use subpath, need to provide the filename as well
            subPath: external-config2-1.properties # name of the file to be mounted, if we use subpath, the other files in that same folder will not dispear
      volumes:
        - name: volume-external-config2
          configMap:
            name: configmap-cloud-order-external-config2
            items:
              - key: external.custom.config2
                path: external-config2-1.properties # name of the file to be mounted                                                               

注意这里有两个改动:

  1. mountpath 上加上了文件名
  2. 添加subpath 配置, 其值还是文件名

这次的确能令两个配置文件同时存在, 原来的文件external-config2.properties 并没有被抹除

gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ kubectl exec -it deployment-cloud-order-7775b8c7cd-jnv7v -- /bin/bash
bash-4.4# pwd
/app
bash-4.4# ls
app.jar  config
bash-4.4# ls config
config2  external-config.properties
bash-4.4# ls config/config2/
external-config2-1.properties  external-config2.properties
bash-4.4# 



subpath的一些限制

k8s 设计的 subpath 其实并不是那么直接
参考:
https://hackmd.io/@maelvls/kubernetes-subpath?utm_source=preview-mode&utm_medium=rec

第1个限制就是 subpath 只能1个文件1个文件地mount, 不支持mount整个folder

参考:
https://kubernetes.io/docs/concepts/configuration/configmap/

第2个限制就是, 用subpath mount的configmap , 即使configmap的值被外部修改, 也不会同步到容器…

Kubernetes ConfigMap实战:从配置解耦到企业级应用部署 在云原生应用部署中,配置管理是连接应用代码与运行环境的关键环节。传统硬编码方式将配置与镜像捆绑,导致部署僵化、缺乏弹性,违背了不可变基础设施的原则。Kubernetes通过ConfigMap这一原生资源对象,实现了配置数据与容器镜像的解耦,将配置外置为可独立管理的键值对或文件。其核心价值在于支持配置的动态更新与版本控制,无需重建镜像即可调整应用行为,显著提升了部署灵活性和运维效率。ConfigMap可通过环境变量注入、文件挂载等多种方式供Pod使用,特别适用于微服务架构下的多环境配置管理、共享中间件连接信息 阅读详情

相关推荐

Okteto加速Flask应用Kubernetes开发调试

Flask作为轻量级Python Web框架,天然适配容器化与Kubernetes云原生环境;但传统Docker+Kubectl工作流导致本地开发与集群部署割裂,引发ModuleNotFoundError、端口冲突等高频问题。Okteto通过文件实时同步、进程热重载和端口自动映射,在Kubernetes原生架构上重建本地级调试体验。其核心价值在于 bridging the gap——无需改造Flask代码或深入K8s细节,即可实现秒级代码变更生效、VS Code断点调试与标准日志输出。适用于微服务快速验证、

weixin_33968104的博客 345

k8s存储 : volumeMounts

原文:https://blog.51cto.com/forall/2135152 在Docker中就有数据卷的概念,当容器删除时,数据也一起会被删除,想要持久化使用数据,需要把主机上的目录挂载到Docker中去,在K8S中,数据卷是通过Pod实现持久化的,如果Pod删除,数据卷也会一起删除,k8s的数据卷是docker数据卷的扩展,K8S适配各种存储系统,包括本地存储EmptyDir,HostPath,网络存储NFS,GlusterFS,PV/PVC等,下面就详细介绍下K8S的存储如何实现。 一.本地.

yuezhilangniao的博客 2万+

持续集成部署-k8s-配置与存储-配置管理:SubPath

在`Kubernetes (K8s)` 中,`SubPath`是用于指定容器内部目录挂载的一个属性。它可以在Pod中指定某个Volume挂载到容器内部的特定目录下,以便容器可以访问该目录中的文件。

种一棵树最好的时间是十年前,其次是现在。 2161

Kubernets——subPath介绍

Kubernetes中SubPath的使用介绍

xiayping的博客 2879

K8S--- volumes&volumeMount

K8S volume volumeMounts emptyDir

qq_41768644的博客 1489

单细胞分析实战:用R语言绘制带连线的堆叠柱状图(附完整代码)

本文详细介绍了如何使用R语言绘制带连线的堆叠柱状图进行单细胞转录组数据分析,特别适用于展示细胞比例变化趋势。通过完整代码示例和实战技巧,帮助研究者优化多组别比较的可视化效果,提升科研图表质量。

yhn4567890的博客 392

一文搞懂 K8s ConfigMap 挂载:path、subPath 与 Spring Boot 配置加载全链路

ConfigMap 的 key 通过items.path改名 → 进入 Volume → 被subPath选中 → 贴到mountPath指定的完整路径 → Spring Boot 按路径读取。每一步都是独立映射,不存在隐那些事儿!

IT_Octopus的博客 453

CentOS7无网环境实战:MySQL8.0完整离线安装与避坑指南(附依赖包下载)

本文详细介绍了在CentOS7无网环境下MySQL8.0的完整离线安装流程,包括依赖包获取、系统预处理、MySQL二进制安装、服务配置与优化等关键步骤。特别针对离线安装的特殊需求,提供了从依赖包下载到服务调优的全链路解决方案,帮助用户在企业内网或隔离环境中高效部署MySQL数据库。

bush的博客 179

subPath的详解

k8s subPathx详解 subpath 挂载文件巧用 subpath挂载普通文件 subpath挂载configMap和secret巧用

weixin_44770684的博客 4837

tecplot 通过数据点、坐标点绘制云图、三维云图

使用坐标点绘制二维云图或三维云图

medicalmask的博客 3万+

TI CC2642R蓝牙5.2模块实战:从零搭建智能门锁原型(附电路图)

本文详细介绍了如何基于TI CC2642R蓝牙5.2模块从零搭建智能门锁原型,涵盖硬件选型、低功耗配置、蓝牙安全交互等关键环节。通过CC2642R的高性能MCU和蓝牙5.2技术,开发者可实现低功耗、高安全性的智能门锁设计,并提供实用的电路图和PCB布局建议。

o5p6q的博客 119

Kubernetes ConfigMap 热更新机制全解析:Env、Volume、subPath 与滚动更新实战

ConfigMap 是 Kubernetes 中用于存储配置数据的核心资源对象,其配置内容全部持久化于 etcd 中。本篇技术指南聚焦 ConfigMap 的创建与更新流程,通过实测验证"更新 ConfigMap 后容器内挂载内容是否同步更新"这一关键问题,并给出 Env、Volume、subPath 三种挂载方式下的行为差异结论,以及利用 Pod annotations 强制滚动更新以刷新配置的

gitblog_01099的博客 216

LVGL多线程编程避坑指南:从音乐播放器项目看UI与后台任务如何安全协作

本文深入探讨LVGL在多线程环境下的安全协作问题,以音乐播放器项目为例,解析UI与后台任务(如mplayer音频播放器)的典型冲突场景。提供全局互斥锁规范、任务队列异步处理等核心策略,并分享mplayer进程集成方案与进度条优化技巧,帮助开发者规避界面卡顿、内存损坏等常见问题。

weixin_42531494的博客 136

深入理解 Kubernetes 中的探针

k8s探针

阿常呓语的专栏 1154

手机VPN的连接方法分享

6、返回到VPN页面,可以看到刚刚新添加的VPN,点击开启VPN后面的开关。5、在打开的添加VPN的页面中输入VPN的信息后点击右上角的“保存”按钮。7、待VPN开关开启后,可以看到添加的VPN正在连接的提示信息了。2、在打开的小米手机设置页面中点击“更多连接方式”的菜单项。3、然后在打开的更多连接方式页面中点击VPN的菜单项。4、在打开的VPN设置页面中点击“添加VPN”的按钮。1、首先在手机屏幕左右的滑动,找到手机的设置图标。

惠惠软件 3万+

蓝牙调试抓包工具--nRF Connect移动端 使用详细总结

摘要: nRF Connect移动端是一款功能全面的蓝牙低功耗(BLE)调试工具,支持设备扫描、多设备连接、服务/特征值查看及数据读写操作。核心功能包括实时数据通信(读取/写入/通知)、设备固件更新(DFU)以及高级工具如自动化测试和信号分析。兼容Android 4.3+和iOS设备,适用于开发调试(如ESP32/nRF52)、设备管理和数据分析。需注意设备兼容性问题(如旧安卓设备可能需关闭连续扫描),并确保数据类型匹配。配套工具链包括nRF Toolbox和nRF Connect SDK,是BLE开发的必

AIoT深度探索者 | 嵌入式系统架构师 深耕物联网(IoT)与人工智能(AI)融合技术,聚焦​​边缘计算、图像开发、低功耗通信协议​​,致力于智能硬件,关注我获取最新技术文章信息与海量资源~ 2402

Kubernetes Secret完全指南:从创建到挂载的实战详解

在云原生与容器编排体系中,配置管理和敏感信息保护是每个运维与开发人员都必须掌握的基础技能。Kubernetes通过ConfigMap与Secret两类资源实现了配置与密钥的分离管理,其中Secret专门负责存储数据库密码、API Token、TLS私钥等敏感数据。与许多人的直觉不同,Secret的base64编码只是一种传输格式,并非真正的加密,其安全边界取决于集群的访问控制与Etcd加密策略。创建Secret有命令式、声明式文件、从现有文件生成等多种方式,而注入Pod时既可以选择Volume文件挂载,也可

weixin_34162228的博客 346

嵌入式系统开发笔记96:将STM32CubeIDE设置为中文

本文介绍将STM32CubeIDE设置为中文的方法。

snmplink的博客 8553

KubeVela daemon 组件类型详解:以 DaemonSet 方式部署节点级守护进程

本文是一份围绕 KubeVela 内置 `daemon` 组件类型的实战指南。`daemon` 组件将应用抽象为 Kubernetes DaemonSet 工作负载,适合在集群每个节点上运行日志采集、节点监控等守护进程。通过阅读本文,你将掌握 `daemon` 组件的完整参数体系、五类卷挂载方式、常用 trait 组合技巧,以及其 CUE 模板底层的渲染与健康检查逻辑,并能够基于文中的 node-

gitblog_00603的博客 873

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

Kubernetes Secret可选性真相:不是Secret设optional,而是Pod用Secret时设

在Kubernetes中,Secret本身并无'可选'属性,'optional'是Pod资源在引用Secret时声明的容错机制,属于使用侧而非定义侧的技术概念。其核心原理在于:envFrom.secretRef.optional控制Secret资源级存在性,volumeMounts.subPath.optional则实现单文件级细粒度容错。这种设计赋予了工作负载对敏感配置缺失的启动韧性,技术价值体现在提升灰度发布、多环境部署及灾备切换的稳定性。典型应用场景包括TLS证书按需挂载、数据库凭证动态注入、以及Im

weixin_32175665的博客 260

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

Kubernetes ConfigMap 详解:从 kubectl 创建到 Pod 注入与热更新实践(kubernetes-handbook)

本文以 kubernetes-handbook 开源仓库中 [concepts/configmap.md](https://link.gitcode.com/i/19c6b4111bc968819e55ce566bd5738f) 为核心骨架,系统讲解 Kubernetes ConfigMap 的设计定位、三种创建方式(目录、文件、字面值)、三种 Pod 注入方式(环境变量、命令行参数、数据卷),并

gitblog_01181的博客 851

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

Kubernetes数据卷Volume和数据卷分类(emptyDir、nfs、hostPath、ConfigMap)详解

Kubernetes数据卷Volume和数据卷分类(emptyDir、nfs、hostPath、ConfigMap)详解

大数据开发、JAVA开发、人工智能AI 1571

Kubernetes ConfigMap完全指南:4种创建方式与3种挂载使用实战

从镜像与配置耦合的经典痛点切入,引出Kubernetes中专门用于配置管理的ConfigMap资源对象。它通过键值对形式将配置从镜像中剥离,使应用镜像保持纯净且配置可独立变更。文章系统梳理ConfigMap的四种创建方式(字面值、单文件、目录导入、YAML声明式),并详解环境变量注入、命令行参数引用、卷挂载三种主流使用姿态及其热更新特性。结合Pod调度失败、目录覆盖、敏感数据误用等实战高频坑,帮助开发者在真实集群环境中安全高效地管理配置。并以Nginx配置热更新为例演示完整流程,为后续Secret等存储类资

weixin_33785108的博客 370

Kubernetes Secret配置管理:挂载、注入与私有仓库认证实战

在Kubernetes集群运维中,配置管理是保障应用稳定运行的基础,而敏感信息的处理尤为关键。Secret作为K8s中存储密码、Token和证书的核心对象,与ConfigMap的定位差异不仅在于数据是否加密,更涉及访问控制、更新机制等深层原理。通过卷挂载将Secret映射为容器内文件,或利用环境变量注入将键值对传入运行时,是两种最常见的消费方式,但路径映射、subPath更新失效、环境变量命名非法等细节常成为线上事故的导火索。同时,私有镜像仓库的认证离不开docker-registry类型Secret的正确

weixin_34059951的博客 387

【Atlas】Atlas 是否支持 Docker 或 Kubernetes 部署?

本文介绍了Apache Atlas 2.4.0在Docker和Kubernetes环境下的生产级部署方案。主要内容包括: 问题背景:通过一个OOMKilled事故案例,揭示了Atlas容器化部署的常见陷阱和挑战 原理解析: 分析了Atlas官方对云原生的支持现状 详细阐述了Atlas在容器环境下的核心挑战:无状态/有状态服务分离、资源隔离配置、多阶段健康检查 提供了完整的生产级部署方案: 优化Dockerfile构建 Kubernetes ConfigMap配置 详细的Deployment配置(包括资源限制

九师兄 432

Kubernetes核心概念与生产环境实践指南

容器编排技术是现代云原生架构的核心基础设施,其核心原理是通过声明式API管理分布式系统的期望状态。Kubernetes作为该领域的标准实现,采用控制平面与数据平面分离的架构设计,通过Pod、Deployment、Service等抽象实现工作负载管理。在生产环境中,合理的探针配置(如readinessProbe和livenessProbe)和存储方案(如PersistentVolume)是保障服务稳定性的关键。本文深入解析Kubernetes的控制器模式、服务发现机制和配置管理方案,并结合StatefulSe

weixin_33892359的博客 432
上一篇: springboot service如何动态读取外部配置文件
下一篇: k8s - Volume 简介和HostPath的使用
nvd11
博客等级 码龄18年 2119粉丝 685原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

nvd11

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值
⌂ 换网址