8000 Render the operator Helm chart's resources and scheduling from values by DrFaust92 · Pull Request #55561 · keycloak/keycloak · GitHub
[go: up one dir, main page]

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

Filter by extension

Filter by extension


Conversations
8000 Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/operator-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,25 @@ jobs:
ns=$(echo "$out" | yq -N 'select(.kind == "ClusterRoleBinding") | .subjects[] | select(.kind == "ServiceAccount") | .namespace' | sort -u)
if [ "$ns" != "custom-namespace" ]; then echo "expected subject namespace custom-namespace, got: $ns"; exit 1; fi

- name: helm template — resources and scheduling values
run: |
set -euo pipefail
out=$(helm template kc-op operator/target/helm/kubernetes/keycloak-operator-helm \
--set operator.resources.limits.cpu=null \
--set operator.nodeSelector.pool=ops \
--set 'operator.tolerations[0].key=dedicated' \
--set 'operator.tolerations[0].operator=Exists' \
--set 'operator.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].weight=100' \
--set 'operator.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.topologyKey=kubernetes.io/hostname')
spec=$(echo "$out" | yq -N 'select(.kind == "Deployment") | .spec.template.spec')
# A request or limit set to null is dropped (no empty `cpu:` key); the others keep their defaults.
test "$(yq '.containers[0].resources.limits | has("cpu")' <<<"$spec")" = "false"
test "$(yq '.containers[0].resources.limits.memory' <<<"$spec")" != "null"
test "$(yq '.nodeSelector.pool' <<<"$spec")" = "ops"
test "$(yq '.nodeSelector."kubernetes.io/os"' <<<"$spec")" = "linux"
test "$(yq '.tolerations[0].key' <<<"$spec")" = "dedicated"
test "$(yq '.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].weight' <<<"$spec")" = "100"

- name: helm template — crds.enabled=false
run: |
set -euo pipefail
Expand Down
5 changes: 4 additions & 1 deletion docs/guides/operator/installation.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,10 @@ Common values you may want to override:
| Value | Description
| `operator.image` | Operator image reference. Defaults to the image published for this release.
| `operator.resources.limits.cpu` / `operator.resources.limits.memory` | Container CPU/memory limits.
| `operator.resources.requests.cpu` / `operator.resources.requests.memory` | Container CPU/memory requests.
| `operator.resources.requests.cpu` / `operator.resources.requests.memory` | Container CPU/memory requests. Set one to `null` to remove it, for example `--set operator.resources.limits.cpu=null`.
| `operator.affinity` | Affinity for the Operator pod. Defaults to `{}`.
| `operator.nodeSelector` | Node selector for the Operator pod. Defaults to `kubernetes.io/os: linux`.
| `operator.tolerations` | Tolerations for the Operator pod. Not set by default.
| `crds.enabled` | Whether to install the CRDs as part of this release. Defaults to `true`.
|===

Expand Down
11 changes: 11 additions & 0 deletions operator/src/main/kubernetes/kubernetes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,14 @@ roleRef:
subjects:
- kind: ServiceAccount
name: keycloak-operator
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: keycloak-operator
spec:
template:
spec:
affinity: {}
nodeSelector:
kubernetes.io/os: linux
21 changes: 21 additions & 0 deletions operator/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,24 @@ quarkus.helm.values."crds.enabled".property=@.crds.enabled
quarkus.helm.values."crds.enabled".value-as-bool=true
quarkus.helm.values."crds.enabled".description=Install the Keycloak Operator CRDs as part of this Helm release. Disable to manage CRDs out-of-band.
# Chart files are generated under target/ (target/helm/...) as part of the build.

# Render whole objects from values so users can set or drop individual fields.
quarkus.helm.expressions.0.path=(kind == Deployment).spec.template.spec.containers.resources
quarkus.helm.expressions.0.expression={{- toYaml .Values.operator.resources | nindent 12 }}
quarkus.helm.values."affinity".paths=(kind == Deployment).spec.template.spec.affinity
quarkus.helm.values."affinity".description=Affinity for the operator pod.
quarkus.helm.values-schema.properties."affinity".name=operator.affinity
quarkus.helm.values-schema.properties."affinity".type=object
quarkus.helm.values-schema.properties."affinity".description=Affinity for the operator pod.
quarkus.helm.expressions.1.path=(kind == Deployment).spec.template.spec.affinity
quarkus.helm.expressions.1.expression={{- toYaml .Values.operator.affinity | nindent 8 }}{{- with .Values.operator.tolerations }}{{- "tolerations:" | nindent 6 }}{{- toYaml . | nindent 8 }}{{- end }}
quarkus.helm.values-schema.properties."tolerations".name=operator.tolerations
quarkus.helm.values-schema.properties."tolerations".type=array
quarkus.helm.values-schema.properties."tolerations".description=Tolerations for the operator pod.
quarkus.helm.values."nodeSelector".paths=(kind == Deployment).spec.template.spec.nodeSelector
quarkus.helm.values."nodeSelector".description=Node selector for the operator pod.
quarkus.helm.values-schema.properties."nodeSelector".name=operator.nodeSelector
quarkus.helm.values-schema.properties."nodeSelector".type=object
quarkus.helm.values-schema.properties."nodeSelector".description=Node selector for the operator pod.
quarkus.helm.expressions.2.path=(kind == Deployment).spec.template.spec.nodeSelector
quarkus.helm.expressions.2.expression={{- toYaml .Values.operator.nodeSelector | nindent 8 }}
0