Workloads

Web Service

Simple web service (backend or frontend).

Component:WebService

Examples

01

Example 1

import { WebService } from '@r8s/recipes'

export default <WebService name="api" image="myapp/api:v1" port={3000} env={{ LOG_LEVEL: 'info' }} />
02

Example 2

import { WebService } from '@r8s/recipes'

export default (
  <WebService
    name="api"
    image="myapp/api:v1"
    env={{ LOG_LEVEL: 'info' }}
    secrets={{ DATABASE_URL: 'app-secrets', API_KEY: 'app-secrets' }}
  />
)
03

Example 3

import { WebService } from '@r8s/recipes'

export default (
  <WebService
    name="api"
    image="myapp/api:v1"
    env={{ LOG_LEVEL: 'info' }}
    vault={{ DATABASE_URL: { mount: 'kv', path: 'db/credentials' } }}
  />
)

Props

namestringRequired

Resource name

namespacestringOptional

Kubernetes namespace (defaults to 'default')

imagestringRequired

Container image (e.g., 'myapp/api:v1.2.3')

portnumberOptional

Container port the app listens on (defaults to 3000)

replicasnumberOptional

Number of pod replicas (defaults to 2)

probes{ liveness?: ProbeSpec | null, readiness?: ProbeSpec | null, startup?: ProbeSpec | null }Optional

Probe overrides. Default probes are httpGet /health (liveness) and /ready (readiness) on the container port. Override when the app exposes different endpoints (e.g. { liveness: { path: '/healthz' }, readiness: { tcp: true } }). Set both to null to disable.

envRecordOptional

Plain environment variables (non-sensitive)

secretsRecordOptional

Secrets from Kubernetes Secrets — safe by default

vaultRecordOptional

Secrets from Vault — creates VaultStaticSecret objects

commandstring[]Optional

Container command override (e.g. a worker entrypoint). Defaults to the image's entrypoint

argsstring[]Optional

Container args appended to the command

rawEnvEnvVar[]Optional

Raw env vars for advanced use cases

resources{ requests?: { cpu?: string, memory?: string }, limits?: { cpu?: string, memory?: string } }Optional

CPU and memory requests/limits for the app container

securityContextRecordOptional

Container securityContext (runAsNonRoot, capabilities, …)

podSecurityContextRecordOptional

Pod-level securityContext

tolerationsRecord[]Optional

Pod tolerations (e.g. faster eviction on node failure: { key: 'node.kubernetes.io/unreachable', effect: 'NoExecute', tolerationSeconds: 60 })

topologySpreadConstraintsRecord[]Optional

Pod topologySpreadConstraints (spread replicas across nodes)

strategy'Recreate' | 'RollingUpdate' | { type: string, rollingUpdate?: { maxUnavailable?: string | number, maxSurge?: string | number } }Optional

Deployment update strategy — 'Recreate' for RWO-volume/migration apps

volumes({ name: string } & Record<string, unknown>)[]Optional

Pod volumes — combine with volumeMounts (e.g. PVCs, emptyDirs, ConfigMaps)

volumeMounts{ name: string, mountPath: string, readOnly?: boolean, subPath?: string }[]Optional

Volume mounts for the app container

initContainers({ name: string; image: string } & Record<string, unknown>)[]Optional

Init containers run before the app starts (chown, schema setup, font installation, …). Pass-through shape: name/image required, the rest follows the Kubernetes container spec.

lifecycleRecordOptional

Container lifecycle hooks (e.g. { preStop: { exec: { command: [...] } } })

imagePullPolicy'Always' | 'IfNotPresent' | 'Never'Optional

Image pull policy (defaults to 'Always')

imagePullSecretsstring[]Optional

Names of Secrets used to pull private registry images