Skip to main content
Version: Next

Workload

A Workload defines the runtime specification for a Component in OpenChoreo, including container configurations, network endpoints, and connections to other services. It represents the actual deployment characteristics of a component, specifying what containers to run, what ports to expose, and what dependencies to inject. Workloads are created automatically by build processes or can be defined manually for pre-built images.

API Version

openchoreo.dev/v1alpha1

Resource Definition

Metadata

Workloads are namespace-scoped resources that must be created within an Organization's namespace and belong to a Component through the owner field.

apiVersion: openchoreo.dev/v1alpha1
kind: Workload
metadata:
name: <workload-name>
namespace: <org-namespace> # Organization namespace

Spec Fields

FieldTypeRequiredDefaultDescription
ownerWorkloadOwnerYes-Ownership information linking the workload to a project and component
containersmap[string]ContainerYes-Container specifications keyed by container name. Must have at least one container with the key "main"
endpointsmap[string]WorkloadEndpointNoNetwork endpoints for port exposure keyed by endpoint name
connectionsmap[string]WorkloadConnectionNoConnections to internal/external resources keyed by connection name

WorkloadOwner

FieldTypeRequiredDefaultDescription
projectNamestringYes-Name of the project that owns this workload (min: 1)
componentNamestringYes-Name of the component that owns this workload (min: 1)

Container

FieldTypeRequiredDefaultDescription
imagestringYes-OCI image to run (digest or tag, min: 1)
command[]stringNo[]Container entrypoint
args[]stringNo[]Arguments for the entrypoint
env[EnvVar]No[]Environment variables

EnvVar

FieldTypeRequiredDefaultDescription
keystringYes-Environment variable name
valuestringYes-Environment variable value

WorkloadEndpoint

FieldTypeRequiredDefaultDescription
typeEndpointTypeYes-Protocol/technology of the endpoint
portint32Yes-Port number for the endpoint (1-65535)
schemaSchemaNo-Optional API definition for the endpoint

EndpointType

ValueDescription
HTTPStandard HTTP endpoint
RESTRESTful API endpoint
gRPCgRPC service endpoint
GraphQLGraphQL API endpoint
WebsocketWebSocket endpoint
TCPRaw TCP endpoint
UDPUDP endpoint

Schema

FieldTypeRequiredDefaultDescription
contentstringNo""Schema content (API definition)

WorkloadConnection

FieldTypeRequiredDefaultDescription
typestringYes-Type of connection (currently only "api" supported)
paramsmap[string]stringNoConnection configuration parameters (depends on connection type)
injectWorkloadConnectionInjectYes-Defines how connection details are injected (currently only env vars)

WorkloadConnectionInject

FieldTypeRequiredDefaultDescription
env[WorkloadConnectionEnvVar]Yes-Environment variables to inject

WorkloadConnectionEnvVar

FieldTypeRequiredDefaultDescription
namestringYes-Environment variable name
valuestringYes-Template value using connection properties (e.g., {{ .url }})

Examples

Basic Service Workload

apiVersion: openchoreo.dev/v1alpha1
kind: Workload
metadata:
name: customer-service-workload
namespace: default
spec:
owner:
projectName: my-project
componentName: customer-service
containers:
main:
image: myregistry/customer-service:v1.0.0
env:
- key: LOG_LEVEL
value: info
endpoints:
http:
type: REST
port: 8080
metrics:
type: HTTP
port: 9090

Workload with Connections

apiVersion: openchoreo.dev/v1alpha1
kind: Workload
metadata:
name: order-service-workload
namespace: default
spec:
owner:
projectName: my-project
componentName: order-service
containers:
main:
image: myregistry/order-service:v2.1.0
command: [ "/app/server" ]
args: [ "--config", "/etc/config.yaml" ]
endpoints:
api:
type: REST
port: 8080
schema:
content: |
openapi: 3.0.0
info:
title: Order API
version: 1.0.0
connections:
database:
type: api
params:
service: postgres-db
inject:
env:
- name: DATABASE_URL
value: "{{ .url }}"
- name: DB_HOST
value: "{{ .host }}"
- name: DB_PORT
value: "{{ .port }}"

Annotations

Workloads support the following annotations:

AnnotationDescription
openchoreo.dev/display-nameHuman-readable name for UI display
openchoreo.dev/descriptionDetailed description of the workload
  • Component - Components that own workloads
  • Service - Service resources that reference workloads
  • WebApplication - WebApplication resources that reference workloads
  • ScheduledTask - ScheduledTask resources that reference workloads
  • Build - Build jobs that create workloads