kubernetes挂载文件时避免覆盖容器中此目录下其他文件【subPath参数】


1.subPath参数

作用:防止挂载文件覆盖挂载目录中其他文件

2.模板

apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: '5'
  creationTimestamp: '2020-05-21T05:26:23Z'
  generation: 5
  labels:
    app: test-volume
  name: test-volume
  namespace: dev-es
  resourceVersion: '7177160'
  selfLink: /apis/apps/v1/namespaces/dev-es/deployments/test-volume
  uid: 7ff65899-cf6a-4ed9-a61f-ba0687e873f2
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: test-volume
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: test-volume
    spec:
      containers:
        - env:
            - name: PKG_RELEASE
              value: 1~buster
          image: 'registry-vpc.cn-beijing.aliyuncs.com/wx-k8s/nginx:v4'
          imagePullPolicy: Always
          name: test-volume
          ports:
            - containerPort: 80
              protocol: TCP
          resources:
            limits:
              cpu: 500m
              memory: 128Mi
            requests:
              cpu: 10m
              memory: 128Mi
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          volumeMounts:
            - mountPath: /etc/nginx/conf.d/dev-server-pem.pem  name: volume-1590038841993
              subPath: dev-server-pem.pem             - mountPath: /etc/nginx/conf.d/dev-server-key.key  name: volume-1590038728849 subPath: dev-server-key.key - mountPath: /etc/localtime  name: volume-localtime
      dnsPolicy: ClusterFirst
      imagePullSecrets:
        - name: pull-image
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
      volumes:
        - configMap: defaultMode: 420 name: dev-server-key name: volume-1590038728849
        - configMap: defaultMode: 420 name: dev-server-pem name: volume-1590038841993
        - hostPath: path: /etc/localtime type: '' name: volume-localtime
status:
  availableReplicas: 1
  conditions:
    - lastTransitionTime: '2020-05-21T05:26:25Z'
      lastUpdateTime: '2020-05-21T05:26:25Z'
      message: Deployment has minimum availability.
      reason: MinimumReplicasAvailable
      status: 'True'
      type: Available
    - lastTransitionTime: '2020-05-21T05:26:23Z'
      lastUpdateTime: '2020-05-21T05:43:16Z'
      message: ReplicaSet "test-volume-54b44447d" has successfully progressed.
      reason: NewReplicaSetAvailable
      status: 'True'
      type: Progressing
  observedGeneration: 5
  readyReplicas: 1
  replicas: 1
  updatedReplicas: 1

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM