Kubernetes之Volume的hostPath挂载

Volume的hostPath挂载

挂载示例:

kind: Deployment
apiVersion: apps/v1
metadata:
  name: emcanalyser-dispatch
  namespace: ztbiz-frassessment
  labels:
    app: emcanalyser-dispatch
  annotations:
    deployment.kubernetes.io/revision: '26'
    kubesphere.io/description: emcanalyser-dispatch
    kubesphere.io/maxSurgePod: '2'
    kubesphere.io/minAvailablePod: '1'
spec:
  replicas: 1
  selector:
    matchLabels:
      app: emcanalyser-dispatch
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: emcanalyser-dispatch
      annotations:
        kubesphere.io/containerSecrets: ''
        kubesphere.io/restartedAt: '2021-04-28T17:04:42.190Z'
        logging.kubesphere.io/logsidecar-config: '{}'
    spec:
      volumes:
        - name: volume-0n4jhp
          configMap:
            name: frassessment-config
            defaultMode: 420

        # volume-emc-data 定义主机内路径 #    
        - name: volume-emc-data
          hostPath:
            path: /data/emc-data
            type: DirectoryOrCreate
        #################################

      containers:
        - name: container-2b1k4t
          image: '192.168.1.1:80/frassessment/emcanalyserdispatch:1.0'
          ports:
            - name: http-80
              containerPort: 80
              protocol: TCP
          resources: {}
          volumeMounts:
            - name: volume-0n4jhp
              mountPath: /app/appsettings.json
              subPath: appsettings.json

            # volume-emc-data 定义pod内路径 #       
            - name: volume-emc-data
              readOnly: true
              mountPath: /app/emcfile
            #################################  

          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: Always
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      dnsPolicy: ClusterFirst
      serviceAccountName: default
      serviceAccount: default
      securityContext: {}
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
              - matchExpressions:
                  - key: node-role.frassessment.io/worker
                    operator: In
                    values:
                      - calculate
      schedulerName: default-scheduler
      tolerations:
        - key: frassessment.io/calculate
          operator: Exists
          effect: NoExecute
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 25%
      maxSurge: 25%
  revisionHistoryLimit: 10
  progressDeadlineSeconds: 600

留下评论