SeqCli from jobs in Kubernetes

We use seq to view our logs. The hosting is done in Kubernetes. For management we tried jobs with the seqcli container. This works great if you mount the SeqCli.json config file.

First we tried the environment variables as described in the documentation. (https://docs.datalust.co/docs/command-line-client) We couldn’t get it to work. Then we found the SeqCli.json config file – now we have all rainbows and unicorns.

The job below sets the license for seq. When we get the new license, we create a new job to apply it.

apiVersion: batch/v1
kind: Job
metadata:
  name: licensejob2024
spec:
  template:
    spec:
      containers:
      - name: seqcli
        image: datalust/seqcli:latest
        args: 
        - "license"
        - "apply"
        - "--certificate=/mnt/license/seq_license_2024.txt"
        volumeMounts:
          - name: seqcli-json
            mountPath: /root/SeqCli.json
            subPath: SeqCli.json
          - name: license
            mountPath: /mnt/license
      volumes:
        - name: seqcli-json
          secret:
            secretName: seqcli
        - name: license
          configMap:
            name: seqlicense
      restartPolicy: Never
  backoffLimit: 4

The SeqCli.json is in a secret as it contains the api key. The data looks like this.

{
    "connection": {
      "serverUrl": "http://seq.logging.svc.cluster.local",
      "apiKey": "Secret-Api-Key"
    },
    "output": {
      "disableColor": false,
      "forceColor": false
    },
    "profiles": {}
}

πŸ¦„ 🌈

Unknown's avatar

About erictummers

Working in a DevOps team is the best thing that happened to me. I like challenges and sharing the solutions with others. On my blog I’ll mostly post about my work, but expect an occasional home project, productivity tip and tooling review.
This entry was posted in Tooling and tagged , . Bookmark the permalink.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.