apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
  labels:
    app: web
spec:
  replicas: 3
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 0
      maxSurge: 100%
  selector:
    matchLabels:
      app: web
  template:
    metadata:
      labels:
        app: web
    spec:
      volumes:
      - name: app
        emptyDir: {}
      initContainers:
      - name: init-web
        image: busybox:latest
        command: ['sh', '-c', 'wget -O- https://bit.ly/otus-k8s-index-gen | sh']
        env:
          - name: POD_NAMESPACE
            valueFrom:
              fieldRef:
                fieldPath: metadata.namespace
        volumeMounts:
        - name: app
          mountPath: /app
      containers:
      - name: web
        image: sergetol/nginx:1.20.2-alpine
        ports:
        - containerPort: 8000
        livenessProbe:
          initialDelaySeconds: 10
          periodSeconds: 5
          timeoutSeconds: 5
          successThreshold: 1
          failureThreshold: 3
          tcpSocket:
            port: 8000
        readinessProbe:
          initialDelaySeconds: 1
          periodSeconds: 5
          timeoutSeconds: 5
          successThreshold: 1
          failureThreshold: 3
          httpGet:
            port: 8000
            path: /index.html
        volumeMounts:
        - name: app
          mountPath: /app
