Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions workflows/patch-k8s-resource/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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.
6 changes: 3 additions & 3 deletions workflows/patch-k8s-resource/application.properties
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
quarkus.log.level=INFO
2 changes: 2 additions & 0 deletions workflows/patch-k8s-resource/patch-k8s-resource.sw.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ functions:
operation: sysout
- name: patch
operation: "specs/patch-k8s-resource.yaml#patchResource"
metadata:
configKey: ".clusterName"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so the configKey metadata will be used to map the openapi spec URL to the right cluster, it's using the following pattern: quarkus.rest-client."<normalised_spec_file>.<configKey>".url am I right?

Is this documented anywhere in sonataflow/openapi generator docs?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to document so users know how to provide it

states:
- name: SetApiVersion
type: switch
Expand Down
Loading