---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
  namespace: default
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 0
      maxSurge: 100%
  template:
    metadata:
      labels:
        app: web
    spec:
      nodeSelector:
        node-role.kubernetes.io/node: ""
      tolerations:
        - key: "node-role.kubernetes.io/prod"
          operator: "Equal"
          value: "node"
          effect: "NoSchedule"
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: app
                operator: In
                values:
                - web
            topologyKey: "kubernetes.io/hostname"
      containers:
      - name: web
        image: chudinanton/nginx-otus:v.0.0.3
        livenessProbe:
          tcpSocket:
            port: 8000
        readinessProbe:
          httpGet:
            path: /index.html
            port: 8000
        volumeMounts:
          - name: app
            mountPath: /app
        resources:
          requests:
            cpu: 1000m
            memory: 512Mi
          limits:
            cpu: 1000m
            memory: 512Mi
      initContainers:
      - name: init-web
        image: busybox:latest
        command: ['sh', '-c', 'wget -O- https://tinyurl.com/otus-k8s-intro | sh']
        volumeMounts:
        - name: app
          mountPath: /app
      volumes:
      - name: app
        emptyDir: {}

