For the complete documentation index, see llms.txt. This page is also available as Markdown.

Core concepts

This section includes core concepts specific to a service resource

Ports

servicePorts declares the ports exposed by the Service. Each port requires a name and a numeric port.

spec:
  servicePorts:
    - name: postgres
      port: 5432

For TCP services, consumers can resolve the Service endpoint from the Service runtime metadata. For HTTP services, configure the container to listen on the declared port and add any ingress configuration supported by the runtime.

Replicas

replicas controls how many identical Service instances are maintained. Use more than one replica for stateless services that can handle traffic concurrently. Stateful services, such as a single Postgres instance, commonly run with replicas: 1.

spec:
  replicas: 1

High availability

highAvailabilityConfig defines how multiple replicas of the Worker are distributed across infrastructure boundaries such as hostnames, zones, or regions. This ensures that if one replica becomes unavailable due to an issue in a specific part of the infrastructure, the other replicas continue to operate independently.

spec:
  compute: karpenter-compute
  highAvailabilityConfig:
    mode: preferred
    # level: hostname
    level: zone
    # level: region
  resources:
    requests:
      cpu: 100m
      memory: 128Mi
    limits:
      cpu: 1000m
      memory: 1024Mi
  executionMode: runnable
  • level specifies the level across which replicas should be distributed, hostname, zone, or region , determining the intended placement separation. The actual distribution still depends on mode.

  • mode specifies how strictly that separation is applied. With mode: preferred, the system tries to place each replica on a different hostname, zone, or region as specified by level, but if not enough distinct units are available, it still proceeds and places replicas together. With mode: required, replicas are placed only if the separation defined by level can be exactly met — if not enough distinct hostnames, zones, or regions are available, the Worker fails.

Stateful Services

Set stateful: true when the Service needs stable identity or attached storage.

Stateful Services can use either inline disk storage or an existing Volume Resource:

  • Use disk when storage belongs to the Service lifecycle and can be deleted with the Service.

  • Use use.volumes when the data must persist independently of the Service.

Stack and stackSpec

stack selects the runtime stack. stackSpec contains stack-specific configuration. For the container stack, provide the container image, command, and arguments.

Projections

Use use.projection to project Secrets, environment variables, and files into the Service runtime. The following example reads POSTGRES_PASSWORD from a Secret and exposes it as an environment variable.

For projection syntax, template engines, data sources, and troubleshooting, see Projections.

Last updated

Was this helpful?