Skip to main content

Exec

Executes a bash (Linux) or powershell (Windows) script. The check is considered passing if the script exits with 0

Docker Image variants
exec.yaml
apiVersion: 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"'
FieldDescriptionScheme
name*

Name of the check, must be unique within the canary

string

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

[]Artifact

checkout

Specify git repository to mount to the exec process

[]GitCheckout

connections

Setup connections for the script (e.g.: aws credentials)

ExecConnection

env

Setup environment variables that are accessible to the exec process

[]EnvVar

description

Description for the check

string

display

Expression to change the formatting of the display

Expression

icon

Icon for overwriting default icon on the dashboard

Icon

labels

Labels for check

map[string]string

metrics

Metrics to export from

[]Metrics

test

Evaluate whether a check is healthy

Expression

transform

Transform data from a check into multiple individual checks

Expression

Exec with an Environment Variables
exec_artifact.yaml
apiVersion: 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 Connection

Exec connections allow you to specify credentials for a list of CLI tools that are needed by your scripts. Eg: You can specify the AWS connection name and the credential files along with the necessary environment variables are setup on the host running the script.

FieldDescriptionTypeRequired
awsAWS connectionAWSConnection
gcpGCP connectionGCPConnection
azureAzure connectionAzureConnection
Exec with a Connection
exec_artifact.yaml
apiVersion: 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

FieldDescriptionTypeRequired
pathPath or glob.stringtrue

See artifacts

Exec with an Artifact
exec_artifact.yaml
apiVersion: 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.yaml
apiVersion: 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"'
FieldDescriptionScheme
destination

Destination is the full path to where the contents of the URL should be downloaded to. If left empty, the sha256 hash of the URL is used as the dir name

connection

The connection url to use, mutually exclusive with username and password

Connection

url

If connection is specified and it also includes a url, this field will take precedence

string

certificate

EnvVar

username

EnvVar

password

EnvVar