apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: web
        image: gryaznovart186/nginx-status
        resources:
          limits:
            memory: "128Mi"
            cpu: "500m"
        ports:
          - containerPort: 8000
        livenessProbe:
          tcpSocket:
            port: 8000
        volumeMounts:
          - mountPath: /app
            name: web
          - mountPath: /var/cache/nginx
            name: cache
          - mountPath: /run
            name: pid
          - mountPath: /var/log/nginx
            name: logs
      - name: exporter
        image: "nginx/nginx-prometheus-exporter:0.9.0"
        env:
        - name: SCRAPE_URI
          value: http://127.0.0.1:8000/basic_status
        resources:
          limits:
            memory: "128Mi"
            cpu: "500m"
        ports:
          - containerPort: 9113
      initContainers:
      - name: init
        image: busybox:1.33.1
        command: ['sh', '-c', 'wget -O- https://tinyurl.com/otus-k8s-intro | sh']
        volumeMounts:
          - mountPath: /app
            name: web
      volumes:
        - name: web
          emptyDir: {}
        - name: logs
          emptyDir: {}
        - name: cache
          emptyDir: {}
        - name: pid
          emptyDir: {}
      securityContext:
        runAsUser: 1001
