A custom agent built on the eclipse-cfm/cfm framework. It connects to a NATS
message broker, listens for orchestration tasks of type user-info-activity, fetches a random user from a dummy
REST endpoint, and publishes the selected user as output on the activity context.
Note that his is just for demonstration purposes and does have any practical use or value!
Perform the following steps in sequence, assuming you have JAD up and running:
docker build -t userinfoagent:latest .
kind load docker-image userinfoagent:latest --name jad
kubectl apply -f agent.userinfo.yamlThen execute all POST requests in the Bruno collection in sequence.
The agent is structured around three layers:
cmd/server/main.go— entry point. Starts the agent and blocks until a shutdown signal (SIGTERM/SIGINT) is received.launcher/launcher.go— wires up the CFM NATS agent with its configuration, resolves dependencies (HTTP client), and hands control to the framework.activity/activity.go— implements the business logic. OnProcessDeploy, it calls the configured remote URL, parses the JSON response as a list ofUserobjects, picks one at random, and stores it asselectedUserin the activity output.ProcessDisposeis a no-op.model/types.go— defines theUser,Address, andCompanystructs that map the remote API response.
The agent registers itself on NATS under the service name cfm.agent.hello-world and handles activities of type
user-info-activity. The default remote URL is https://jsonplaceholder.typicode.com/users.
The agent reads its configuration from a file named agent.userinfo.env (YAML) mounted at /etc/appname/ in
Kubernetes. The following keys are supported:
| Key | Description | Example |
|---|---|---|
uri |
NATS server URI | nats://localhost:4222 |
bucket |
NATS JetStream bucket name | cfm-bucket |
stream |
NATS JetStream stream name | cfm-stream |
agent.remote.url |
URL of the REST endpoint that returns a user list | https://jsonplaceholder.typicode.com/users |
The Dockerfile uses a two-stage build: a Go builder stage compiles the binary, and a distroless runtime image runs it.
docker build -t userinfoagent:latest .To verify that the image was created:
docker images userinfoagentThe file agent.userinfo.yaml contains a Deployment and a ConfigMap for the edc-v namespace. This namespace was
already created by JAD.
Prerequisites:
- The
edc-vnamespace exists in the cluster. - A
telemetry-configConfigMap is already present in the namespace (created by JAD). - A NATS instance is reachable at
nats.edc-v.svc.cluster.local:4222. - The image
userinfoagent:latestis available to the cluster (e.g. loaded into a local registry orminikube).
Loading the image into a local cluster (KinD example):
kind load docker-image userinfoagent:latest --name jadApply the manifest:
kubectl apply -f agent.userinfo.yamlVerify the deployment:
kubectl -n edc-v get pods -l app=user-info-agent
kubectl -n edc-v logs -l app=user-info-agentThe bruno/ directory contains a Bruno API collection to interact with the CFM process
manager (pmBaseUrl).
-
Register the activity definition — tells the process manager that
user-info-activityexists:POST {{pmBaseUrl}}/api/v1alpha1/activity-definitionsUse the request in
bruno/Create custom activity definition.yml. -
Update the orchestration definition — defines a deployment pipeline that includes
user-info-agentas the final step after onboarding:POST {{pmBaseUrl}}/api/v1alpha1/orchestration-definitionsUse the request in
bruno/Create Orchestration Definition.yml. Please note that since the API endpoint overwrites the existing orchestration definition, the new orchestration definition must also include all other activities! -
Inspect registered definitions via the GET requests in
Get All Activity Definitions.ymlandGet All Orchestration Definitions.yml.