apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
  labels:
    app: web
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 0
      maxSurge: 1
  template:
    metadata:
      labels:
        app: web
    spec:
      initContainers:
        - name: init
          image: busybox:1.32.0
          command: ['sh', '-c', 'wget -O- https://tinyurl.com/otus-k8s-intro | sh']
          volumeMounts:
            - name: web-volume
              mountPath: /app
      containers:
        - name: web
          image: nginx:latest
          readinessProbe:
            httpGet:
              path: /index.html
              port: 80
          livenessProbe:
            tcpSocket:
              port: 80
          ports:
            - name: web
              containerPort: 80
          volumeMounts:
            - name: web-volume
              mountPath: /app
            - name: nginx-config
              mountPath: /etc/nginx/conf.d
          resources:
            limits:
              cpu: "150"
              memory: "200Mi"
        - name: nginx-exporter
          image: nginx/nginx-prometheus-exporter
          args: ['-nginx.scrape-uri', 'http://localhost:80/basic_status']
          ports:
            - name: metrics
              containerPort: 9113
          resources:
            limits:
              cpu: "150"
              memory: "200Mi"
      volumes:
        - name: web-volume
          emptyDir: {}
        - name: nginx-config
          configMap:
            name: nginx-config