OpsLevel Runner is the Kubernetes based job processor for OpsLevel
| Name | Type | Description |
|---|---|---|
| opslevel_runner_jobs_duration | histogram |
The duration of jobs in seconds. |
| opslevel_runner_jobs_finished | counter |
The count of jobs that finished processing by outcome status. |
| opslevel_runner_jobs_processing | gauge |
The current number of active jobs being processed. |
| opslevel_runner_jobs_started | counter |
The count of jobs that started processing. |
Testing a job
OPSLEVEL_API_TOKEN=XXXXX go run main.go test -f job.yaml
cat << EOF | OPSLEVEL_API_TOKEN=XXXXX go run main.go test -f -
id: "1"
image: alpine/curl
commands:
- export TEST=100
- echo "::set-outcome-var hello-world=42"
- sleep 2
- echo $TEST
- echo $Secret
- echo $NotSecret
- /opslevel/check.sh
variables:
- key: Secret
value: "World!"
sensitive: true
- key: NotSecret
value: "World!"
sensitive: false
files:
- name: check.sh
contents: |
#! /bin/bash
echo "Hello from inside the script!"
echo "Secrets are still ${Secret}"
sleep 2
EOFRunning
# Production
OPSLEVEL_API_TOKEN=XXXXX go run main.go run
# Staging
OPSLEVEL_API_TOKEN=XXXXX go run main.go run --api-url=https://api.opslevel-staging.com/graphql --app-url=https://app.opslevel-staging.comDownload the latest release from the Releases page for your architecture.
Extract it to a directory of your choice, mark it as executable and move it to something on your path
chmod +x ./opslevel-runner
mv ./opslevel-runner /usr/local/bin/opslevel-runner
For OSX you'll probably need to remove the quarantine bit:
sudo xattr -r -d com.apple.quarantine /usr/local/bin/opslevel-runner
At this point you can run the OpsLevel Runner with OpsLevel by following the instructions in that repository.
To build, ensure you have go installed
brew install go
Then init and update the submodules (if you clone with --recurse-submodules you can skip this step)
git submodule init && git submodule update
Then run go build in src to build in the local directory, you can also use -o <PATH> to put the file in a target location of your choice.
cd src
go build
The dev environment uses kind (Kubernetes in Docker/Podman), Faktory as job queue, and Task as task runner.
- Go (
brew install go) - Task (
brew install go-task) - Docker or Podman
task setup # install Faktory + workspace deps
task run # start Faktory + workers (creates kind cluster automatically)The run task instantiates the kind cluster if it doesn't exist then starts
goreman which supervises 4 concurrent
processes defined in src/Procfile:
| Process | Description |
|---|---|
faktory |
Starts the Faktory work server (job queue) |
runner |
hot-reloads opslevel-runner run --mode=faktory --queues=runner through watchexec |
image-builder |
Watches Go sources and Dockerfile with watchexec; rebuilds the helper container image and reloads it into kind on change |
Note:
--mode faktorydoes haveopslevel-runnerpoll Faktory for runner jobs and launches them as pods in the kind cluster
Scripts source .env.local (gitignored) to set local environment overrides
before creating or connecting to the kind cluster. e.g.: to reuse a k8s cluster
from a specific KUBECONFIG file
# .env.local
# Point at a dedicated kubeconfig to keep localdev contexts isolated.
export KUBECONFIG=${HOME}/.kube/opslevel.localdev.yamlbin/kind-env.shloads this file, falling back to~/.kube/configwhenKUBECONFIGis unset.- The kind cluster name defaults to
opslevel-runner.
Podman is preferred; Docker is used as fallback. Handled in bin/kind-env.sh.
Build and load the runner helper image into kind:
task build-helper-imageThis cross-compiles the Go binary for linux, builds the container image from
Dockerfile, and loads it into the kind cluster. The image is only rebuilt
when source checksums change.
task stop-kind # clean orphaned job pods and stop the cluster