apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
  labels:
    deployment: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        volumeMounts:
          - mountPath: /etc/nginx/nginx.conf
            subPath: nginx.conf 
            readOnly: true
            name: nginx-conf
          - mountPath: /var/www/html/index.html
            subPath: index.html 
            readOnly: true
            name: nginx-index
        readinessProbe:
            httpGet:
              path: /basic_status
              port: 8080
        livenessProbe:
            tcpSocket:
              port: 8080
        ports:
          - containerPort: 8080
            name: http
      - name: nginx-exporter
        image: nginx/nginx-prometheus-exporter:0.9.0
        args: ['-nginx.scrape-uri', 'http://localhost:8080/basic_status']
        ports:
          - containerPort: 9113
            name: metrics
      volumes:
      - name: nginx-conf
        configMap:
          name: nginx-conf
      - name: nginx-index
        configMap:
          name: nginx-index
