Exec
Executes a Bash (Linux) or PowerShell (Windows) script. The check passes when the script exits with 0.
See Image Variants for a list of installed applications
exec.yamlapiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: exec-pass
spec:
schedule: "@every 5m"
exec:
- name: exec-pass-check
description: "exec dummy check"
script: |
echo "hello"
test:
expr: 'results.stdout == "hello"'
| Field | Description | Scheme |
|---|---|---|
name* | Name of the check, must be unique within the canary |
|
script* | Script can be a inline script or a path to a script that needs to be executed. On windows executed via Powershell and in darwin and Linux executed using bash | |
artifacts | Specify what files/folders generated by the script needs to be archived | |
checkout | Specify git repository to mount to the exec process | |
connections | Set up connections for the script | |
env | Setup environment variables that are accessible to the exec process | |
dependsOn | Checks that must complete before this check runs |
|
description | Description for the check |
|
display | Expression to change the formatting of the display | |
icon | Icon for overwriting default icon on the dashboard | |
labels | Labels for check |
|
markFailOnEmpty | If a transformation or datasource returns empty results, the check should fail |
|
metrics | Metrics to export from | |
namespace | Namespace to insert the check result into when it differs from the canary namespace |
|
relationships | Relationships that link check results to components or configs | Relationship |
test | Evaluate whether a check is healthy | |
transform | Transform data from a check into multiple individual checks | |
transformDeleteStrategy | Status to apply to transformed checks when the source check no longer returns them |
|
Shell Language
Use a shebang (#!) line as the first line of script to choose a different shell. The base image includes python, bash, and pwsh.
Exec with an Environment Variables
exec_artifact.yamlapiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: exec-env
spec:
schedule: "@every 5m"
exec:
- name: exec-env
description: "exec with env"
script: |
echo -n ${FL_HELLO} ${FL_WORLD}
env:
- name: FL_HELLO
value: "hello"
- name: FL_WORLD
value: "world"
test:
expr: 'results.stdout == "hello world"'
Exec Connections
Exec connections provide credentials and context for CLI tools used by your scripts.
| Field | Description | Type | Required |
|---|---|---|---|
aws | AWS connection | AWSConnection | |
azure | Azure connection | AzureConnection | |
eksPodIdentity | Use EKS Pod Identity credentials | boolean | |
fromConfigItem | Load connection details from a config item | string | |
gcp | GCP connection | GCPConnection | |
kubernetes | Kubernetes connection | KubernetesConnection | |
opensearch | OpenSearch connection | OpensearchConnection | |
serviceAccount | Use the pod service account credentials | boolean |
Exec with a Connection
exec_artifact.yamlapiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: aws-exec
labels:
"Expected-Fail": "true"
spec:
schedule: "@every 5m"
exec:
- name: aws-exec-check
description: "exec s3 list"
script: aws s3 ls | head -n 1
connections:
aws:
connection: connection://AWS/flanksource
test:
expr: results.stdout == '2023-05-25 11:49:22 cf-templates-3ci8g0qv95rq-eu-west-1'
Artifact
| Field | Description | Type | Required |
|---|---|---|---|
path | Path, glob, /dev/stdout, or /dev/stderr. | string | true |
See artifacts
Exec with an Artifact
exec_artifact.yamlapiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: exec-artifact
spec:
schedule: "@every 5m"
exec:
- name: exec-pass-with-artifact
description: "exec dummy check"
script: |
mkdir -p /tmp/exec-results &&
echo "hello" > /tmp/exec-results/hello && echo "world" > /tmp/exec-results/world && echo "random" > /tmp/random-text && echo "to stdout"
artifacts:
- path: /tmp/exec-results/*
- path: /tmp/random-text
- path: /dev/stdout
Git Checkout
Exec with Checkout
exec_artifact.yamlapiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: exec-checkout
spec:
schedule: "@every 5m"
exec:
- name: exec-checkout
description: "exec with git"
script: |
cat go.mod | head -n 1
checkout:
url: github.com/flanksource/duty
test:
expr: 'results.stdout == "module github.com/flanksource/duty"'
| Field | Description | Scheme |
|---|---|---|
branch | Git branch to check out |
|
certificate | ||
connection | The connection url to use, mutually exclusive with | |
depth | Clone depth |
|
destination | Deprecated. Destination path for the checkout. If left empty, the SHA-256 hash of the URL is used as the directory name. |
|
password | ||
type | Git checkout type |
|
url | If |
|
username |