Kubernetes Manifest (traefik-log-dashboard discussion #32)

:speech_balloon: GitHub discussion traefik-log-dashboard #32 in Show and tell, started by fhptech on GitHub

We are running Traefik as part of our Kubernetes deployment (vSphere with Tanzu) and recently deployed the log dashboard to monitor the access logs. Thought I would share this manifest as a POC reference for others or if you wanted to use it as a template for inclusion as another installation option. Excuse any mistakes in the manifest and the use of multiple containers per deployment which goes against standard Kubernetes practices as it was slapped together quickly just to get operational. It includes publishing the frontend via Traefik IngressRoutes

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app.kubernetes.io/part-of: traefik-log-dashboard
  name: traefik-log-dashboard
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/part-of: traefik-log-dashboard
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app.kubernetes.io/part-of: traefik-log-dashboard
    spec:
      containers:
      - image: ghcr.io/hhftechnology/traefik-log-dashboard-backend:latest
        imagePullPolicy: Always
        name: traefik-log-dashboard-backend
        env:
          - name: NODE_ENV
            value: production
          - name: PORT
            value: "3001"
          - name: TRAEFIK_LOG_FILE
            value: /logs/traefik
        volumeMounts:
          - name: traefik-logs
            mountPath: /logs/traefik
      - image: ghcr.io/hhftechnology/traefik-log-dashboard-frontend:latest
        imagePullPolicy: Always …

---
💬 Join in here or [on GitHub](https://github.com/hhftechnology/traefik-log-dashboard/discussions/32).
<!-- hhf-forum-sync -->

hhftechnology commented on GitHub:

@​fhptech https://forum.hhf.technology/t/deploying-a-traefik-log-dashboard-on-kubernetes-with-ingressroute-by-fhptech/

jakelooker commented on GitHub:

Thank you for sharing this, it was a good help in configuring my setup in K8s. Here’s my deployment/server using OTLP. I tried to get GRPC working but it failed, I had to use the http endpoint.

traefik-dashboard-deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    io.kompose.service: traefik-dashboard
  name: traefik-dashboard
  namespace: networking
  annotations:
    keel.sh/policy: force
    keel.sh/trigger: poll
    keel.sh/pollSchedule: "@​daily"
spec:
  replicas: 1
  selector:
    matchLabels:
      io.kompose.service: traefik-dashboard
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        io.kompose.service: traefik-dashboard
    spec:
      initContainers:
        - image: alpine:latest
          name: maxmind-db
          env:
          - name: MAXMIND_LICENSE_KEY
            value: "redacted"
          volumeMounts:
            - mountPath: /data
              name: maxmind
          command:
          - /bin/sh
          args:
          - -c
          - |
            cd /data &&
            if [ ! -f GeoLite2-City.mmdb ] || [ $(find . -name 'GeoLite2-City.mmdb' -mtime +7) ]; then
              apk add --no-cache wget tar &&
              echo 'Downloading/updating MaxMind GeoLite2-City database...' &&
              wget --inet4-only -O GeoLite2-City.tar.gz "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=${MAXMIND_LICENSE_KEY}&suffix=tar.gz" &&
              tar -xzf GeoLite2-City.tar.gz --strip-components=1 --wildcards '*/GeoLite2-City.mmdb' &&
              rm -f GeoLite2-City.tar.gz &&
              echo 'MaxMind database updated successfully'
            else
              echo 'MaxMind database is up to date'
            fi
      restartPolicy: Always
      containers:
        - image: hhftechnology/traefik-log-dashboard-backend:latest
          name: backend
          env:
          - name: NODE_ENV
            value: production
          - name: PORT
            value: "3001"
          - name: OTLP_ENABLED
            value: "true"
          - name: OTLP_GRPC_PORT
            value: "4317"
          - name: USE_MAXMIND
            value: "true"
          - name: MAXMIND_DB_PATH
            value: "/maxmind/GeoLite2-City.mmdb"
          - name: MAXMIND_FALLBACK_ONLINE
            value: "true"
          ports:
            - containerPort: 3001
            - containerPort: 4317
          volumeMounts:
            - mountPath: /maxmind
              readOnly: true
              name: maxmind
          resources: {}
        - image: hhftechnology/traefik-log-dashboard-frontend:latest
          name: frontend
          env:
          - name: NODE_ENV
            value: production
          - name: BACKEND_PORT
            value: "3001"
          - name: "BACKEND_SERVICE"
            value: localhost
          ports:
            - containerPort: 80
          resources: {}
      volumes:
        - name: maxmind
          persistentVolumeClaim: …