Skip to main content
Version: v0.17.x

Workload

A Workload defines the runtime specification for a Component in OpenChoreo, including container configuration, network endpoints, and connections to other services. It represents the actual deployment characteristics of a component, specifying the container 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 and belong to a Component through the owner field.

apiVersion: openchoreo.dev/v1alpha1
kind: Workload
metadata:
name: <workload-name>
namespace: <namespace> # Namespace for grouping workloads

Spec Fields​

FieldTypeRequiredDefaultDescription
ownerWorkloadOwnerYes-Ownership information linking the workload to a project and component
containerContainerYes-Container specification for the workload
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
files[File]No[]File configurations and secrets

EnvVar​

FieldTypeRequiredDefaultDescription
keystringYes-Environment variable name
valuestringNo-Environment variable value (required if secretRef is not set)
secretRefsecretRefNo-Reference to a secret key (required if value is not set)

File​

FieldTypeRequiredDefaultDescription
keystringYes-File name
mountPathstringYes-Path where the file should be mounted
valuestringNo-File content (required if secretRef is not set)
secretRefsecretRefNo-Reference to a secret key (required if value is not set)

secretRef​

FieldTypeRequiredDefaultDescription
namestringYes-Name of the secret
keystringYes-Key within the secret

WorkloadEndpoint​

FieldTypeRequiredDefaultDescription
typeEndpointTypeYes-Protocol/technology of the endpoint
portint32Yes-Port number exposed by the endpoint (1-65535)
targetPortint32NoportTarget port on the container (1-65535), defaults to port if not set
visibility[]EndpointVisibilityNo[]Additional visibility scopes beyond the implicit project visibility
displayNamestringNo-Human-readable name for the endpoint
basePathstringNo-Base path of the API exposed via the endpoint
schemaSchemaNo-Optional API schema definition for the endpoint

Visibility Behavior:

  • Every endpoint automatically gets project visibility (accessible within the same project and environment)
  • The visibility array adds additional scopes beyond the implicit project access
  • Multiple visibility levels can be specified to create routes on different gateways

EndpointVisibility​

ValueDescription
projectAccessible only within the same project and environment (implicit for all endpoints)
namespaceAccessible across all projects in the same namespace and environment
internalAccessible across all namespaces in the deployment (intranet)
externalAccessible from outside the deployment, including public internet

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
container:
image: myregistry/customer-service:v1.0.0
env:
- key: LOG_LEVEL
value: info
endpoints:
http:
type: REST
port: 8080
visibility: ["external"]
basePath: "/api/v1"
displayName: "Customer REST API"
metrics:
type: HTTP
port: 9090
targetPort: 9090

Workload with Environment Variables and Files​

apiVersion: openchoreo.dev/v1alpha1
kind: Workload
metadata:
name: secure-service-workload
namespace: default
spec:
owner:
projectName: my-project
componentName: secure-service
container:
image: myregistry/secure-service:v1.0.0
env:
- key: LOG_LEVEL
value: info
- key: GIT_PAT
secretRef:
name: git-secrets
key: pat
files:
- key: ssl.pem
mountPath: /tmp
secretRef:
name: certificates
key: privateKey
- key: application.toml
mountPath: /tmp
value: |
schema_generation:
enable: true
endpoints:
api:
type: REST
port: 8080
visibility: ["external"]
basePath: "/api"
apiVersion: openchoreo.dev/v1alpha1
kind: Workload
metadata:
name: order-service-workload
namespace: default
spec:
owner:
projectName: my-project
componentName: order-service
container:
image: myregistry/order-service:v2.1.0
command: [ "/app/server" ]
args: [ "--config", "/etc/config.yaml" ]
endpoints:
api:
type: REST
port: 8080
visibility: ["external"]
basePath: "/orders"
displayName: "Order Management API"
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