1、如下yaml文件

apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "7"
  generation: 7
  labels:
    k8s-app: busybox
    qcloud-app: busybox
  managedFields:
  - apiVersion: apps/v1
    manager: tke-apiserver
    operation: Update
  - apiVersion: apps/v1
    manager: kube-controller-manager
    operation: Update
  name: busybox
  namespace: default
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      k8s-app: busybox
      qcloud-app: busybox
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        k8s-app: busybox
        qcloud-app: busybox
    spec:
      containers:
      - args:
        - -c
        - sleep 30000;
        command:
        - /bin/sh
        env:
        - name: MY_POD_NAME
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: metadata.name
        image: busybox:latest
        imagePullPolicy: Always
        lifecycle:
          postStart:
            exec:
              command:
              - /bin/sh
              - -c
              - mkdir  -p /tmp/${MY_POD_NAME}
        name: busybox
        resources:
          limits:
            cpu: 500m
            memory: 400Mi
          requests:
            cpu: 250m
            memory: 256Mi
        securityContext:
          privileged: false
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /var/log/pods
          name: logdir
          subPathExpr: $(MY_POD_NAME)
      dnsPolicy: ClusterFirst
      imagePullSecrets:
      - name: qcloudregistrykey
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
      volumes:
      - hostPath:
          path: /logs
          type: DirectoryOrCreate
        name: logdir
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐