apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: diary
    role: web
  name: diary-web
  namespace: blog
spec:
  replicas: 1
  selector:
    matchLabels:
      app: diary
      role: web
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: diary
        role: web
    spec:
      initContainers:
      - image: ubuntu
        imagePullPolicy: Always
        command:
          - bash
          - -c
          - "cp -r /src/* /dst/"
        name: init-worker
        volumeMounts:
        - mountPath: /src
          name: public
        - mountPath: /dst
          name: tmp
      containers:
      - image: ubuntu
        imagePullPolicy: Always
        command:
          - bash
          - -c
          - "while true; do cp -r /src/* /dst/ ; sleep 10; done"
        name: worker
        volumeMounts:
        - mountPath: /src
          name: public
        - mountPath: /dst
          name: tmp
      - image: nginx
        imagePullPolicy: Always
        name: server
        volumeMounts:
        - mountPath: /usr/share/nginx/html
          name: tmp
        - mountPath: /etc/nginx/conf.d
          name: config
      volumes:
      - name: tmp
        emptyDir: {}
      - name: public
        persistentVolumeClaim:
          claimName: diary-assets
      - name: config
        configMap:
          name: diary-nginx
