# Example for the Adapter patterns, which transform custom metrics
# stored on the file system into a Prometheus conformant export
# on port 9889
apiVersion: v1
kind: Pod
metadata:
  name: random-generator
  labels:
    app: random-generator
spec:
  containers:
  # ------------------------------------------------
  # Main application
  - image: k8spatterns/random-generator:1.0
    name: main
    env:
    # The log file that we want to export
    - name: LOG_FILE
      value: /logs/random.log
    ports:
    # Application running on port 8080
    - containerPort: 8080
      protocol: TCP
    volumeMounts:
    - mountPath: /logs
      name: log-volume
  # ------------------------------------------------
  # Prometheus adapter
  - image: k8spatterns/random-generator-exporter
    name: adapter
    env:
    # Logfile  to pick up by exporter script
    - name: LOG_FILE
      value: /logs/random.log
    ports:
    # Expose prometheus metrics via that port
    - containerPort: 9889
      protocol: TCP
    # Mount shared volume for accessing the logs
    volumeMounts:
    - mountPath: /logs
      name: log-volume
  volumes:
  # New empty directory volume for sharing the log file between container
  - name: log-volume
    emptyDir: {}
