Repository navigation
operator bootstrap admin handling #30711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,6 +47,7 @@ | |
| import org.keycloak.operator.crds.v2alpha1.deployment.Keycloak; | ||
| import org.keycloak.operator.crds.v2alpha1.deployment.KeycloakStatus; | ||
| import org.keycloak.operator.crds.v2alpha1.deployment.KeycloakStatusAggregator; | ||
| import org.keycloak.operator.crds.v2alpha1.deployment.spec.BootstrapAdminSpec; | ||
| import org.keycloak.operator.crds.v2alpha1.deployment.spec.HostnameSpec; | ||
| import org.keycloak.operator.crds.v2alpha1.deployment.spec.HostnameSpecBuilder; | ||
|
|
||
|
|
@@ -61,7 +62,7 @@ | |
| @ControllerConfiguration( | ||
| dependents = { | ||
| @Dependent(type = KeycloakDeploymentDependentResource.class), | ||
| @Dependent(type = KeycloakAdminSecretDependentResource.class), | ||
| @Dependent(type = KeycloakAdminSecretDependentResource.class, reconcilePrecondition = KeycloakAdminSecretDependentResource.EnabledCondition.class), | ||
| @Dependent(type = KeycloakIngressDependentResource.class, reconcilePrecondition = KeycloakIngressDependentResource.EnabledCondition.class), | ||
| @Dependent(type = KeycloakServiceDependentResource.class, useEventSourceWithName = "serviceSource"), | ||
| @Dependent(type = KeycloakDiscoveryServiceDependentResource.class, useEventSourceWithName = "serviceSource") | ||
|
|
@@ -104,6 +105,7 @@ public UpdateControl<Keycloak> reconcile(Keycloak kc, Context<Keycloak> context) | |
|
|
||
| Log.debugf("--- Reconciling Keycloak: %s in namespace: %s", kcName, namespace); | ||
|
|
||
| // TODO - these modifications to the resource belong in a webhook because dependents run first | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this essentially an Operator SDK bug? We're not doing anything special here...
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @vmuzikar I don't think it's a bug, just how the operator sdk works by default.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then how are we supposed to update spec?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can update it here, but not in a way that will cause a race condition. The pr initially didn't assume a default in the deployment dependent logic which lead to the initial creation of the statefulset without bootstrap env variables. It's not a hard reqirement for this feature that the spec is populated with the defaults.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I see. Thanks for clarifying! |
||
| boolean modifiedSpec = false; | ||
| if (kc.getSpec().getInstances() == null) { | ||
| // explicitly set defaults - and let another reconciliation happen | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| package org.keycloak.operator.crds.v2alpha1.deployment.spec; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonInclude; | ||
| import com.fasterxml.jackson.annotation.JsonPropertyDescription; | ||
|
|
||
| import io.sundr.builder.annotations.Buildable; | ||
|
|
||
| @JsonInclude(JsonInclude.Include.NON_NULL) | ||
| @Buildable(editableEnabled = false, builderPackage = "io.fabric8.kubernetes.api.builder") | ||
| public class BootstrapAdminSpec { | ||
|
|
||
| public static class User { | ||
| @JsonPropertyDescription("Name of the Secret that contains the username and password keys") | ||
| private String secret; | ||
|
|
||
| public String getSecret() { | ||
| return secret; | ||
| } | ||
|
|
||
| public void setSecret(String secret) { | ||
| this.secret = secret; | ||
| } | ||
| } | ||
|
|
||
| public static class Service { | ||
| @JsonPropertyDescription("Name of the Secret that contains the client-id and client-secret keys") | ||
| private String secret; | ||
|
|
||
| public String getSecret() { | ||
| return secret; | ||
| } | ||
|
|
||
| public void setSecret(String secret) { | ||
| this.secret = secret; | ||
| } | ||
|
|
||
| } | ||
|
|
||
| //private Integer expiration; | ||
| @JsonPropertyDescription("Configures the bootstrap admin user") | ||
| private User user; | ||
| @JsonPropertyDescription("Configures the bootstrap admin service account") | ||
| private Service service; | ||
|
|
||
| /*public Integer getExpiration() { | ||
| return expiration; | ||
| } | ||
|
|
||
| public void setExpiration(Integer expiration) { | ||
| this.expiration = expiration; | ||
| }*/ | ||
|
|
||
| public User getUser() { | ||
| return user; | ||
| } | ||
|
|
||
| public void setUser(User user) { | ||
| this.user = user; | ||
| } | ||
|
|
||
| public Service getService() { | ||
| return service; | ||
| } | ||
|
|
||
| public void setService(Service service) { | ||
| this.service = service; | ||
| } | ||
|
|
||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be also good to add a link here to the Admin Bootstrapping guide (once it's merged).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, we can wait for #31039 to be merged first