Skip to main content

Configuration Reference

Environment variables and configuration options for the Manetu PolicyEngine.

Environment Variables

CLI Environment Variables

VariableDescriptionDefault
MPE_CLI_OPA_FLAGSAdditional OPA flags for lint/test--v0-compatible

Logging Variables

VariableDescriptionDefault
MPE_LOG_LEVELLogging level (debug, info, warn, error)info
MPE_LOG_FORMATTERLog format (json or text)json
MPE_LOG_REPORT_CALLERInclude caller info in logs(not set)

PolicyEngine Variables

VariableDescriptionDefault
MPE_CONFIG_PATHPath to config directory.
MPE_CONFIG_FILENAMEConfig file namempe-config.yaml

Configuration File

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

Configuration Options

OptionTypeDescription
bundles.includeallbooleanInclude all evaluated bundles in audit records
opa.unsafebuiltinsstringComma-separated list of unsafe OPA built-ins to exclude from policy evaluation
audit.envlistList of typed entries for AccessRecord metadata (supports env, string, k8s-label, k8s-annot)
audit.k8s.podinfostringPath to Kubernetes Downward API podinfo directory (default: /etc/podinfo)

Audit Environment Configuration

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:

FieldDescription
nameThe key that will appear in the AccessRecord metadata
typeHow to resolve the value (see table below)
valueInterpreted according to the type

Supported Types:

TypeDescription
envResolve value as an environment variable name
stringUse value as a literal string
k8s-labelLook up value in Kubernetes pod labels (via Downward API)
k8s-annotLook 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-gateway
  • AWS_REGION=us-east-1
  • HOSTNAME=api-gw-7d9f8b6c4-x2m9k

The 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:

  • Values are resolved once at PolicyEngine startup and cached for performance
  • If an environment variable is not set, the value will be an empty string
  • If Kubernetes Downward API files are not available, k8s-label and k8s-annot entries resolve to empty strings
  • Entries with unknown types are skipped with a warning
  • Changes to values after startup will not be reflected until the PolicyEngine is restarted

OPA Flags

Default OPA flags used by the CLI: --v0-compatible

Override via:

  • Command line: --opa-flags "--strict --v1-compatible"
  • Environment: MPE_CLI_OPA_FLAGS="--strict"
  • Disable: --no-opa-flags

Common OPA Flags

FlagDescription
--v0-compatibleEnable OPA v0 compatibility
--v1-compatibleEnable OPA v1 compatibility
--strictEnable strict mode

Logging Configuration

Log Levels

LevelDescription
debugVerbose debugging information
infoGeneral operational information
warnWarning messages
errorError messages only

Example

# Enable debug logging with text format
export MPE_LOG_LEVEL=.:debug
export MPE_LOG_FORMATTER=text
mpe serve -b domain.yml

Production Configuration

# 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

Docker Configuration

ENV MPE_LOG_LEVEL=.:info
ENV MPE_LOG_FORMATTER=json

Kubernetes ConfigMap

apiVersion: v1
kind: ConfigMap
metadata:
name: mpe-config
data:
MPE_LOG_LEVEL: "info"
MPE_LOG_FORMATTER: "json"