Files
cozystack/packages/system/keycloak-operator/Makefile
T
Yan Bondarenko b74029cb39 fix(keycloak): apply keycloak-operator CRD updates on upgrade
keycloak-operator ships its CRDs in the chart's crds/ directory and its
PackageSource sets no upgradeCRDs policy, so helm-controller never
replaces them. A cluster installed before v1.2.0 therefore runs the
v1.32.0 operator against the v1.25.0 CRDs, whose ClusterKeycloakRealm
schema has no spec.sessions, spec.login or spec.organizationsEnabled.
The apiserver drops those fields from the realm keycloak-configure
renders, so the operator never applies the session limits the platform
sets. On a v1.6.4 cluster in that state Keycloak also rejected the
dashboard client with HTTP 400, and replacing the CRDs from the chart
by hand, with an operator restart, cleared it.

The v1.32.0 CRDs are not purely additive. They drop the realm,
targetRealm and keycloakOwner fields that v1.25.0 marked deprecated and
require realmRef and keycloakRef instead. Every Keycloak object the
platform renders already uses the refs, and each CRD keeps its single
version, so replacing them loses nothing the platform relies on.

helm-controller applies the policy only when it upgrades the release,
and it runs an upgrade only when the release artifact or its values
change, which a PackageSource edit does not do. The package test added
here also changes the keycloak-operator artifact, so the replace runs
on the upgrade that ships this change even where nothing else in the
package changes. The test itself pins the realm fields
keycloak-configure sets against the CRD the chart ships.

Assisted-by: LLM
Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
2026-10-18 23:11:02 +03:00

27 lines
883 B
Makefile

export NAME=keycloak-operator
export NAMESPACE=cozy-keycloak
include ../../../hack/common-envs.mk
include ../../../hack/package.mk
test:
helm unittest .
image:
docker buildx build images/keycloak-operator \
$(call image-tags,keycloak-operator,v$(COZYSTACK_VERSION)) \
$(call cache-args,keycloak-operator) \
--metadata-file images/keycloak-operator.json \
$(BUILDX_ARGS)
REPOSITORY="$(REGISTRY)/keycloak-operator" \
yq -i '.keycloak-operator.image.repository = strenv(REPOSITORY)' values.yaml
TAG="$(IMAGE_TAG)@$$(yq e '."containerimage.digest"' images/keycloak-operator.json -r)" \
yq -i '.keycloak-operator.image.tag = strenv(TAG)' values.yaml
rm -f images/keycloak-operator.json
update:
rm -rf charts
helm repo add epamedp https://epam.github.io/edp-helm-charts/stable
helm repo update epamedp
helm pull epamedp/keycloak-operator --untar --untardir charts