Technology Stack:
- Knative
- Quarkus
Quarkus REST application that mirrors the Node.js workshop service. It loads src/main/resources/data/greetings.json, reads the COUNTRY_CODE environment variable (default EN), and exposes a single GET / endpoint returning:
{
"code": "EN",
"message": "Hello World"
}If the configured country code is unknown, the endpoint responds with 404 and { "error": "Unknown country code '<CODE>'" }.
- Start Quarkus dev mode:
./mvnw quarkus:dev- Override the greeting before launching dev mode (value is upper-cased automatically):
COUNTRY_CODE=FR ./mvnw quarkus:dev- Quarkus listens on
http://localhost:8080by default, or usePORT=<value>to override. Test the endpoint:
curl http://localhost:8080/- Run the tests:
./mvnw testSelect the option that is most appropriate:
Build a container image using the provided multi-stage Dockerfile (replace <REGISTRY>/<REPOSITORY> with your registry path):
IMAGE=<REGISTRY>/<REPOSITORY>/hello-country-service:latest
podman build -t "$IMAGE" .
# or: docker build -t "$IMAGE" .
podman push "$IMAGE"
# or: docker push "$IMAGE"The resulting image runs on UBI OpenJDK 21 and exposes port 8080.
oc project <NAMESPACE>
REGISTRY=$(oc registry info)
podman login -u "$(oc whoami)" -p "$(oc whoami -t)" "$REGISTRY"
IMAGE=${REGISTRY}/<NAMESPACE>/hello-country-service:latest
podman build -t "$IMAGE" .
podman push "$IMAGE"# Point to the project that should own the image
oc project <NAMESPACE>
# Create a Docker strategy BuildConfig (run once)
oc new-build --strategy=docker --binary --name hello-country-service
# Start a build using the local working tree and stream logs
oc start-build hello-country-service --from-dir=. --follow
# Verify the resulting image stream tag
oc get is hello-country-service -n <NAMESPACE>The successful build publishes the image at:
image-registry.openshift-image-registry.svc:5000/<NAMESPACE>/hello-country-service:latest
- Update
knative-service.yamlwith your image reference (for OpenShift local registry, setyour-namespaceaccordingly), then apply it:
oc apply -f knative-service.yaml -n <NAMESPACE>- Knative injects a
PORTenvironment variable automatically; do not set one in the manifest. Override the greeting viaCOUNTRY_CODE.
Or, using the Knative CLI without modifying the YAML:
IMAGE=image-registry.openshift-image-registry.svc:5000/<NAMESPACE>/hello-country-service:latest
kn service apply hello-country-service \
--image "$IMAGE" \
--env COUNTRY_CODE=EN- Retrieve the URL:
kn service describe hello-country-service -o url- Test the service once it is ready:
curl "$(kn service describe hello-country-service -o url)"- To update the greeting later, patch the service:
kn service update hello-country-service --env COUNTRY_CODE=FR