Advanced
Sandbox limits, splitting the manifest across files, the Kubernetes escape hatch and importing from Score.
sandbox
sandbox: { ttl: 2h, max_ttl: 24h, agent_exec: true }All optional; those are the defaults. ttl is how long a sandbox lives from creation. parity sandbox extend adds time up to max_ttl. agent_exec: false stops sandbox tokens from using parity exec. Parity's own limits cap these: a manifest can make its sandboxes stricter, never looser.
include: splitting the file
# parity.yaml
version: 1
project: shop
include:
- apps/storefront/parity.yaml
- apps/billing/parity.yaml
managed:
db: { type: postgres }# apps/billing/parity.yaml
services:
billing:
build: . # apps/billing
depends_on: [db] # defined in parity.yamlSplit the manifest so each team owns a file, as with Compose's include.
includelists files relative to the file that lists it. Any file may include others. No globs, absolute paths or paths outside the root's directory.- Only the root sets
version,project,sandboxandkubernetes. Other files addmanaged,services,jobs,env_groups,externalsandenvironments. - Each name is defined in one file; a second definition is an error naming both. References work across files.
- Paths in a file (
build: .,develop.watchpaths) resolve from that file's directory. - A file's
environmentschanges only what it, or a file it includes, defines. The root may change anything. parity checkcites problems asfile:line, shows each entry's file, and warns about anyparity.yamlor*.parity.yamlthat nothing includes.parity check --mergedprints the merged manifest, which is whatparity upsends.
kubernetes: the escape hatch
When a field doesn't cover what you need, you can patch a service's Kubernetes Deployment or add Kubernetes objects to the sandbox.
services:
api:
kubernetes:
patch: # nginx writes temp files to /var/cache/nginx
spec:
template:
spec:
volumes: [{ name: cache, emptyDir: {} }]
containers: [{ name: api, volumeMounts: [{ name: cache, mountPath: /var/cache/nginx }] }]
kubernetes:
objects:
- { apiVersion: v1, kind: ConfigMap, metadata: { name: extra }, data: { a: "1" } }patchis a strategic merge patch on the service's Deployment. It may set the Deployment'sspec, labels and annotations.objectsmay be a ConfigMap, Secret, Service (ClusterIP), Deployment, StatefulSet, Job, CronJob, PodDisruptionBudget, cert-managerCertificate(withissuerRef: { name: parity-ca, kind: Issuer }), or KEDAScaledObjectorTriggerAuthentication. Each is named and has no namespace.- A
ScaledObjectscales a service on a queue, for example a worker from 0 when a Redis list fills.scaleTargetRefnames a service,maxReplicaCountis required and at most 10. Triggers areredisandpostgresqlon the sandbox's own managed entries (address: "cache:6379",host: db), pluscron,cpuandmemory. Credentials come from the target's env (passwordFromEnv: PGPASSWORD), or from aTriggerAuthenticationwhosesecretTargetRefreads a Secret ofobjectsintopasswordorusername. - Security rules still apply. Containers run non-root without extra privileges. Host access, privileged containers, added capabilities, service account tokens, network policies and cluster-wide objects are refused. So are probes and lifecycle hooks with a
host, finalizers and owner references, and annotations starting withexternal-dns.alpha.kubernetes.io/,cloud.google.com/,networking.gke.io/orcluster-autoscaler.kubernetes.io/.
Importing from Score
parity import score <dir> writes a parity.yaml from Score workload files. Each workload becomes a service, postgres, redis and s3 resources become managed entries, route becomes expose, and ${resources.db.host} becomes ${db.host}. Add jobs, builds, auth and email afterwards. What doesn't map is printed.