Skip to content

Commit

Permalink
feat(Keycloak): add support for custom image and image pull secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
kosmoz authored and pmig committed Nov 21, 2023
1 parent 72bf5ea commit 7539954
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
9 changes: 9 additions & 0 deletions deploy/crd/keycloaks.glasskube.eu-v1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ spec:
x-kubernetes-int-or-string: true
type: object
type: object
image:
type: string
imagePullSecrets:
items:
properties:
name:
type: string
type: object
type: array
version:
pattern: \d+\.\d+\.\d+
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ internal val Keycloak.genericResourceName get() = "${Keycloak.APP_NAME}-${metada
internal val Keycloak.backupBucketName get() = "$genericResourceName-backup"
internal val Keycloak.ingressTlsCertName get() = "$genericResourceName-tls"
internal val Keycloak.discoveryServiceName get() = "$genericResourceName-discovery"
internal val Keycloak.appImage get() = "quay.io/keycloak/${Keycloak.APP_NAME}:${spec.version}"
internal val Keycloak.appImage get() = spec.image ?: "quay.io/keycloak/${Keycloak.APP_NAME}:${spec.version}"
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import eu.glasskube.operator.validation.Patterns.SEMVER
import io.fabric8.generator.annotation.Nullable
import io.fabric8.generator.annotation.Pattern
import io.fabric8.generator.annotation.Required
import io.fabric8.kubernetes.api.model.LocalObjectReference
import io.fabric8.kubernetes.api.model.Quantity
import io.fabric8.kubernetes.api.model.ResourceRequirements

Expand All @@ -16,6 +17,8 @@ data class KeycloakSpec(
val host: String,
val management: ManagementSpec = ManagementSpec(),
val resources: ResourceRequirements = defaultResourceRequirements,
val image: String?,
val imagePullSecrets: List<LocalObjectReference>?,
@field:Pattern(SEMVER)
val version: String = "21.1.2",
@field:Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import eu.glasskube.operator.apps.keycloak.discoveryServiceName
import eu.glasskube.operator.apps.keycloak.genericResourceName
import eu.glasskube.operator.apps.keycloak.resourceLabelSelector
import eu.glasskube.operator.apps.keycloak.resourceLabels
import io.fabric8.kubernetes.api.model.LocalObjectReference
import io.fabric8.kubernetes.api.model.apps.Deployment
import io.javaoperatorsdk.operator.api.reconciler.Context
import io.javaoperatorsdk.operator.processing.dependent.kubernetes.CRUDKubernetesDependentResource
Expand Down Expand Up @@ -67,7 +68,7 @@ class KeycloakDeployment : CRUDKubernetesDependentResource<Deployment, Keycloak>
"KC_HOSTNAME_STRICT_BACKCHANNEL" to "false",
"KC_HTTP_ENABLED" to "true",
"KC_HTTP_PORT" to "8080",
"KC_PROXY" to "passthrough",
"KC_PROXY" to "edge",
"KEYCLOAK_ADMIN" to "root",
"KEYCLOAK_ADMIN_PASSWORD" to "glasskube-operator",
"jgroups.dns.query" to primary.discoveryServiceName
Expand Down Expand Up @@ -101,6 +102,7 @@ class KeycloakDeployment : CRUDKubernetesDependentResource<Deployment, Keycloak>
}
}
)
imagePullSecrets = primary.spec.imagePullSecrets?.map { LocalObjectReference(it.name) }
}
}
}
Expand Down

0 comments on commit 7539954

Please sign in to comment.