Repository navigation
Description
Before reporting an issue
- I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.
Area
operator
Describe the bug
On the latest v26.2.5 of keycloak-k8s-resources, operator and RedHat Build of Keycloak Server. Keycloak-Operator rolling updates are not working as expected. When spec.update.strategy=auto, the operator fails with error: keycloak-update-job is invalid, and when spec.update.strategy=Explicit, the operator will always replace the pod; rolling update is not observed.
Version
26.2.5
Regression
- The issue is a regression
Expected behavior
- When Keycloak's CRD has
spec.update.strategy=auto, the operator should automatically determine the best strategy to deploy a new update of the Keycloak server, and default toRecreateOnImageChangeif the checks fail. - When Keycloak's CRD has
spec.update.strategy=Explicit, the operator should deploy a new update of the Keycloak server by rolling deployment, whenspec.update.revisionmatches the previous update.
Actual behavior
When Keycloak's CRD has spec.update.strategy=auto:
Operator throw the following error:
Caused by: io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: PATCH at: https://172.20.0.1:443/apis/batch/v1/namespaces/identity/jobs/keycloak-update-job?fieldManager=keycloakcontroller&force=true. Message: Job.batch "keycloak-update-job" is invalid: │
│ spec.template.spec.initContainers[0].lifecycle: Forbidden: may not be set for init containers without restartPolicy=Always. Received status: Status(apiVersion=v1, code=422, details=StatusDetails(causes=[StatusCause(field=spec.template.spec.initContainers[0].lifecycle, mess │
│ age=Forbidden: may not be set for init containers without restartPolicy=Always, reason=FieldValueForbidden, additionalProperties={})], group=batch, kind=Job, name=keycloak-update-job, retryAfterSeconds=null, uid=null, additionalProperties={}), kind=Status, message=Job.batch │
│ "keycloak-update-job" is invalid: spec.template.spec.initContainers[0].lifecycle: Forbidden: may not be set for init containers without restartPolicy=Always, metadata=ListMeta(_continue=null, remainingItemCount=null, resourceVersion=null, selfLink=null, additionalPropertie │
│ s={}), reason=Invalid, status=Failure, additionalProperties={}).When the error is thrown, the operator will not deploy a new version of the Keycloak Server Pod until spec.update is removed or the strategy is changed.
When Keycloak's CRD has spec.update.strategy=Explicit
The operator will always deploy a new Keycloak Server Pod by replacing it - no rolling update is ever observed.
How to Reproduce?
Deploy keycloak-k8s-resources: v26.2.5 as usual and start updating the Keycloak Server image property with new tags.
Anything else?
System Details:
keyclaok-operator version: v26.2.5
RedHat Build of Keycloak: v26.2.5
keycloak-k8s-resources: v26.2.5
AWS EKS Automode - Kubernetes: v1.32
Activity
shawkins commentedon Jun 10, 2025
Can you clarify this? The expected behavior is simply that the statefulset is updated, then Kubernetes handles the rollout - which will seqentially replace the pods. How many keycloak instances are set in the CR? What do you mean by replacing?
shawkins commentedon Jun 10, 2025
To clarify this situation - are you explcitly setting the lifecycle in the unsupported podTemplate or is that happening by some other mechanism?
kneufeld-pbp commentedon Jun 10, 2025
No, not intentionally.
We have been testing between 1 and 3 instances and are currently set to one.
When the update strategy is set to Explicit, the pods terminated and replaced, with no rolling deployment, whether the instances are 1, 2, or 3.
When the update strategy is set to Auto, the operator errors with
And the StatefulSet does not appear to be updating., until strategy is changed or update is removed.
This is my Keycloak file:
This is the generated StatefulSet
4 remaining items
keycloak-github-bot commentedon Jun 10, 2025
Due to the amount of issues reported by the community we are not able to prioritise resolving this issue at the moment.
If you are affected by this issue, upvote it by adding a 👍 to the description. We would also welcome a contribution to fix the issue.
fix: removing lifecylce in initContainers