Environment variables and configuration options for the Manetu PolicyEngine.
| Variable | Description | Default |
|---|---|---|
MPE_CLI_OPA_FLAGS | Additional OPA flags for lint/test | --v0-compatible |
| Variable | Description | Default |
|---|---|---|
MPE_LOG_LEVEL | Logging level (debug, info, warn, error) | info |
MPE_LOG_FORMATTER | Log format (json or text) | json |
MPE_LOG_REPORT_CALLER | Include caller info in logs | (not set) |
| Variable | Description | Default |
|---|---|---|
MPE_CONFIG_PATH | Path to config directory | . |
MPE_CONFIG_FILENAME | Config file name | mpe-config.yaml |
The optional mpe-config.yaml file provides additional configuration:
# Include all bundle references in audit logs
bundles:
includeall: true
# Unsafe built-ins to disallow from policy decisions.
opa:
unsafebuiltins: "http.send"
# Include environment context in AccessRecord metadata
audit:
env:
- name: service
type: env
value: SERVICE_NAME
- name: region
type: string
value: us-east-1
- name: pod
type: env
value: HOSTNAME
| Option | Type | Description |
|---|---|---|
bundles.includeall | boolean | Include all evaluated bundles in audit records |
opa.unsafebuiltins | string | Comma-separated list of unsafe OPA built-ins to exclude from policy evaluation |
audit.env | list | List of typed entries for AccessRecord metadata (supports env, string, k8s-label, k8s-annot) |
audit.k8s.podinfo | string | Path to Kubernetes Downward API podinfo directory (default: /etc/podinfo) |
The audit.env option allows you to include deployment context in every AccessRecord's metadata.env field. This is valuable for correlating decisions with specific deployments, pods, or regions.
Configuration Format:
Each entry in the audit.env list has three fields:
| Field | Description |
|---|---|
name | The key that will appear in the AccessRecord metadata |
type | How to resolve the value (see table below) |
value | Interpreted according to the type |
Supported Types:
| Type | Description |
|---|---|
env | Resolve value as an environment variable name |
string | Use value as a literal string |
k8s-label | Look up value in Kubernetes pod labels (via Downward API) |
k8s-annot | Look up value in Kubernetes pod annotations (via Downward API) |
Example:
audit:
env:
- name: service
type: env
value: MY_SERVICE_NAME
- name: environment
type: string
value: production
- name: region
type: env
value: AWS_REGION
- name: pod
type: env
value: HOSTNAME
If the environment variables are set as:
MY_SERVICE_NAME=api-gatewayAWS_REGION=us-east-1HOSTNAME=api-gw-7d9f8b6c4-x2m9kThe resulting AccessRecord metadata will include:
{
"metadata": {
"timestamp": "2024-01-15T10:30:00Z",
"id": "550e8400-e29b-41d4-a716-446655440000",
"env": {
"service": "api-gateway",
"environment": "production",
"region": "us-east-1",
"pod": "api-gw-7d9f8b6c4-x2m9k"
}
}
}
Kubernetes Downward API:
To use k8s-label or k8s-annot types, configure a Downward API volume mount in your pod spec:
volumes:
- name: podinfo
downwardAPI:
items:
- path: "labels"
fieldRef:
fieldPath: metadata.labels
- path: "annotations"
fieldRef:
fieldPath: metadata.annotations
volumeMounts:
- name: podinfo
mountPath: /etc/podinfo
Then reference labels or annotations in your config:
audit:
env:
- name: app
type: k8s-label
value: app.kubernetes.io/name
- name: revision
type: k8s-annot
value: deployment.kubernetes.io/revision
By default, the PolicyEngine reads Downward API files from /etc/podinfo. If your volume is mounted at a different path, configure it with audit.k8s.podinfo:
audit:
k8s:
podinfo: /custom/path/podinfo
Or via environment variable: MPE_AUDIT_K8S_PODINFO=/custom/path/podinfo
Notes:
k8s-label and k8s-annot entries resolve to empty stringsDefault OPA flags used by the CLI: --v0-compatible
Override via:
--opa-flags "--strict --v1-compatible"MPE_CLI_OPA_FLAGS="--strict"--no-opa-flags| Flag | Description |
|---|---|
--v0-compatible | Enable OPA v0 compatibility |
--v1-compatible | Enable OPA v1 compatibility |
--strict | Enable strict mode |
| Level | Description |
|---|---|
debug | Verbose debugging information |
info | General operational information |
warn | Warning messages |
error | Error messages only |
# Enable debug logging with text format
export MPE_LOG_LEVEL=.:debug
export MPE_LOG_FORMATTER=text
mpe serve -b domain.yml
# Production logging
export MPE_LOG_LEVEL=.:info
export MPE_LOG_FORMATTER=json
# Disable unsafe built-ins
# (don't set opa.unsafebuiltins in config)
# Run server
mpe serve -b domain.yml --port 9000
ENV MPE_LOG_LEVEL=.:info
ENV MPE_LOG_FORMATTER=json
apiVersion: v1
kind: ConfigMap
metadata:
name: mpe-config
data:
MPE_LOG_LEVEL: "info"
MPE_LOG_FORMATTER: "json"
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |