Skip to main content
Version: v1.4.0-m.1 (pre-release)

Workload Descriptor

When a CI workflow builds your code, it produces a Workload CR that OpenChoreo deploys. By default, the build creates a minimal Workload with just the container image. To define endpoints, environment variables, dependencies, and configuration files, add a workload descriptor to your source repository. The workload descriptor is a YAML file as defined below.

The descriptor is not the Workload CR

The workload descriptor is a YAML file. The workload CR is produced from it

Descriptor Format​

Place a workload.yaml file in your application directory (the path specified by repository.appPath in your Component's workflow parameters):

# workload.yaml
apiVersion: openchoreo.dev/v1alpha1

metadata:
name: reading-list-service

endpoints:
- name: reading-list-api
visibility:
- external
port: 8080
type: HTTP
basePath: /api
schemaFile: docs/openapi.yaml

configurations:
env:
- name: LOG_LEVEL
value: info
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: db-credentials
key: password
files:
- name: app.json
mountPath: /etc/config
value: |
{"feature_flags": {"new_feature": true}}
- name: tls.conf
mountPath: /etc/app
valueFrom:
path: configs/tls.conf

dependencies:
endpoints:
- component: postgres-db
name: api
visibility: project
envBindings:
host: DB_HOST
port: DB_PORT
resources:
- ref: reading-list-postgres
envBindings:
host: PG_HOST
port: PG_PORT
username: PG_USER
password: PG_PASSWORD
database: PG_DATABASE

Fields​

metadata​

FieldRequiredDescription
nameYesName for the generated Workload CR

endpoints​

Define the network endpoints your service exposes. For what each visibility level means, see Endpoint Visibility.

FieldRequiredDescription
nameYesUnique name for the endpoint
portYesPort your application listens on
typeYesHTTP, gRPC, GraphQL, Websocket, TCP, or UDP
visibilityNoList of visibility levels: project, namespace, internal, external
targetPortNoContainer port to forward to (defaults to port)
basePathNoBase path prefix for the endpoint
displayNameNoHuman-readable name for the endpoint
schemaFileNoPath to schema file (OpenAPI, Protobuf, GraphQL), relative to the workload.yaml location

configurations​

configurations.env​

Environment variables injected into the container. Set either value or valueFrom, not both.

FieldRequiredDescription
nameYesEnvironment variable name
valueNoLiteral value (mutually exclusive with valueFrom)
valueFromNoReference to an external source (mutually exclusive with value)

valueFrom supports:

FieldDescription
valueFrom.secretKeyRef.nameName of the Kubernetes Secret
valueFrom.secretKeyRef.keyKey within the Secret
configurations.files​

Configuration files mounted into the container. Set exactly one of value or valueFrom.

FieldRequiredDescription
nameYesFile name (used as the file name within mountPath)
mountPathYesAbsolute directory path where the file is mounted
valueNoInline file content (mutually exclusive with valueFrom)
valueFromNoReference to an external source (mutually exclusive with value)

valueFrom supports path or secretKeyRef (not both):

FieldDescription
valueFrom.pathPath to a local file, resolved relative to the workload.yaml location
valueFrom.secretKeyRef.nameName of the Kubernetes Secret
valueFrom.secretKeyRef.keyKey within the Secret

valueFrom.path is read at build time and inlined into the generated CR. It is available for files only, not for environment variables.

dependencies​

Declare what your component consumes from the rest of the platform. Both kinds of dependency carry over to the generated Workload CR unchanged, so the full field reference is the same as for a hand-written Workload: Endpoint Dependencies and Resource Dependencies.

dependencies.endpoints​

Endpoints exposed by other components.

FieldRequiredDescription
componentYesName of the target component
nameYesName of the endpoint on the target component
visibilityYesVisibility scope (project or namespace)
projectNoTarget component's project (defaults to same project)
envBindingsYesMaps connection address components to environment variable names

envBindings fields:

FieldRequiredDescription
addressNoEnv var name for the full address (host:port/path)
hostNoEnv var name for the host
portNoEnv var name for the port
basePathNoEnv var name for the base path
dependencies.resources​

Outputs of a project-bound Resource, such as a database, queue or cache.

FieldRequiredDescription
refYesName of the target Resource, in the same project as your component
envBindingsNoMaps a ResourceType output name to a container environment variable name
fileBindingsNoMaps a ResourceType output name to a container mount path

At least one of envBindings or fileBindings is required.

File Placement​

The CI workflow looks for workload.yaml at the root of your appPath. For example, if your Component specifies appPath: "/service-go-greeter", place the descriptor at:

your-repo/
service-go-greeter/
workload.yaml ← descriptor file
Dockerfile
main.go
openapi.yaml ← referenced by schemaFile
configs/
tls.conf ← referenced by valueFrom.path

See Also​