apiVersion: apps/v1
kind: Deployment
metadata:
  name: promtail
  labels:
    name: promtail
  namespace: monitoring
spec:
  replicas: 1
  selector:
    matchLabels:
      name: promtail
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        name: promtail
    spec:
      containers:
        - name: random-logger
          image: chentex/random-logger
          volumeMounts:
            - name: shared-logs
              mountPath: /home/slog
        - name: promtail
          image: grafana/promtail:latest
          resources:
            limits:
              cpu: 3
              memory: 4Gi
            requests:
              cpu: 2
              memory: 2Gi
          args:
            - "-client.url=http://10.0.2.15:32215/api/prom/push"
            - "-config.file=/etc/promtail/promtail.yml"
          env:
            - name: HOSTNAME
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
          ports:
            - containerPort: 3200
              name: http-metrics
          volumeMounts:
            - mountPath: /etc/promtail
              name: promtail
            - name: shared-logs
              mountPath: /home/slog
      volumes:
        - name: promtail
          configMap:
            name: promtail
        - name: shared-logs
          emptyDir: {}
      restartPolicy: Always
