From 3d12d3406be98c7e067657c6d82797583ad259a6 Mon Sep 17 00:00:00 2001 From: Yaron Dayagi Date: Thu, 19 Jun 2025 18:21:19 +0300 Subject: [PATCH] multiple clusters FLPATH-2424 https://issues.redhat.com/browse/FLPATH-2424 Signed-off-by: Yaron Dayagi --- workflows/patch-k8s-resource/README.md | 11 +++-------- workflows/patch-k8s-resource/application.properties | 6 +++--- .../patch-k8s-resource/patch-k8s-resource.sw.yaml | 2 ++ 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/workflows/patch-k8s-resource/README.md b/workflows/patch-k8s-resource/README.md index 21f14beb..b2ad8b10 100644 --- a/workflows/patch-k8s-resource/README.md +++ b/workflows/patch-k8s-resource/README.md @@ -2,18 +2,13 @@ This workflow is a component in the solution provided by the Optimizations plugin and the Optimizer app. It is not meant to be consumed by humans only by apps. However, it can be executed via the Orchestrator plugin just as any other workflow. The workflow patches workload resources such as deployments and statefulsets. The input for the workflow is taken from Red Hat Insights's OpenShift Optimizations Recommendations. Each recommendation specifies a certain container to be patched. ## Prerequisite -* Credentials for accessing the OCP cluster. +* Credentials for accessing the OCP clusters. Each cluster has a URL and a token. ## Workflow diagram ![Path K8S resource workflow diagram](https://github.com/rhdhorchestrator/serverless-workflows/blob/main/workflows/patch-k8s-resource/patch-k8s-resource.svg?raw=true) ## Workflow application configuration -Application properties can be initialized from environment variables before running the application: - -| Environment variable | Description | Mandatory | Default value | -|-----------------------|-------------|-----------|---------------| -| `OCP_URL` | The OpensShift API Server URL | ✅ | | -| `OCP_TOKEN`| The OpensShift API Server Token | ✅ | | +The workflow needs the URL and token for accessing the cluster that is being optimized. The input variable `clusterName` determines the set of properties that the workflow will use. The file `application.properties` contains an example for a cluster called `mycluster`. This set of properties will be used when the input variable `clusterName` contains the value `mycluster`. ## Deploying in OCP with OSL -If you have OSL (OpenShift Serverless Logic, a.k.a SonataFlow) operator installed, you can use the [manifests](./manifests) folder for deploying the workflow. Create the resources in the OSL namespace (usually sonataflow-infra). The application configuration is in the first file. \ No newline at end of file +If you have OSL (OpenShift Serverless Logic, a.k.a SonataFlow) operator installed, you can use the [manifests](./manifests) folder for deploying the workflow. Create the resources in the OSL namespace (usually sonataflow-infra). The application configuration is in the first file. diff --git a/workflows/patch-k8s-resource/application.properties b/workflows/patch-k8s-resource/application.properties index 904a9586..8ff2edc0 100644 --- a/workflows/patch-k8s-resource/application.properties +++ b/workflows/patch-k8s-resource/application.properties @@ -1,5 +1,5 @@ -quarkus.rest-client.patch_k8s_resource_yaml.url=${OCP_URL} -quarkus.openapi-generator.patch_k8s_resource_yaml.auth.BearerToken.bearer-token=${OCP_TOKEN} +quarkus.rest-client."patch_k8s_resource_yaml.mycluster".url=${MYCLUSTER_URL} +quarkus.openapi-generator.patch_k8s_resource_yaml.mycluster.auth.BearerToken.bearer-token=${MYCLUSTER_TOKEN} quarkus.tls.trust-all=true quarkus.kubernetes-client.trust-certs=true @@ -8,4 +8,4 @@ quarkus.kubernetes-client.trust-certs=true # Possible values: OFF, FATAL, ERROR, WARN, INFO, DEBUG, ALL. # and see https://quarkus.io/guides/logging for documentation quarkus.log.category."org.apache.http".level=INFO -quarkus.log.level=INFO \ No newline at end of file +quarkus.log.level=INFO diff --git a/workflows/patch-k8s-resource/patch-k8s-resource.sw.yaml b/workflows/patch-k8s-resource/patch-k8s-resource.sw.yaml index 64fb7322..d433ac23 100644 --- a/workflows/patch-k8s-resource/patch-k8s-resource.sw.yaml +++ b/workflows/patch-k8s-resource/patch-k8s-resource.sw.yaml @@ -11,6 +11,8 @@ functions: operation: sysout - name: patch operation: "specs/patch-k8s-resource.yaml#patchResource" + metadata: + configKey: ".clusterName" states: - name: SetApiVersion type: switch