-
Notifications
You must be signed in to change notification settings - Fork 531
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
Add health check support for Keycloak container #7122
Conversation
This commit introduces new constants for health checks, including an environment variable (`KC_HEALTH_ENABLED`), a health check container port (9000), and a health endpoint name (`health`). The `AddKeycloak` method is updated to incorporate a health check endpoint and set the health check environment variable to "true" for the Keycloak resource.
Updated `AddKeycloakWithDefaultsAddsAnnotationMetadata` to filter `EndpointAnnotation` by name for "http" and "health", adding assertions for the "health" endpoint. Modified `VerifyManifest` to use a specific image reference and added the `KC_HEALTH_ENABLED` environment variable, along with updating the `bindings` section to include the "health" binding.
tests/Aspire.Hosting.Keycloak.Tests/KeycloakResourceBuilderTests.cs
Outdated
Show resolved
Hide resolved
@DamianEdwards can you review? |
src/Aspire.Hosting.Keycloak/KeycloakResourceBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Hosting.Keycloak/KeycloakResourceBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Hosting.Keycloak/KeycloakResourceBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Hosting.Keycloak/KeycloakResourceBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Hosting.Keycloak/KeycloakResourceBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Hosting.Keycloak/KeycloakResourceBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
@@ -59,10 +62,13 @@ public static IResourceBuilder<KeycloakResource> AddKeycloak( | |||
.WithImageRegistry(KeycloakContainerImageTags.Registry) | |||
.WithImageTag(KeycloakContainerImageTags.Tag) | |||
.WithHttpEndpoint(port: port, targetPort: DefaultContainerPort) | |||
.WithHttpEndpoint(targetPort: HealthCheckContainerPort, name: HealthEndpointName) |
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.
Consider adding the management interface port as an optional parameter too (like port
) so it can be easily changed by the caller. If it's set then we'd need to set the KC_HTTP_MANAGEMENT_PORT
environment variable too.
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.
Wouldn't that mean that we should also support KC_HTTP_PORT
?
But maybe we could add a managementPort
parameter with the same semantics of the port
parameter, without messing with target ports.
Would it be feasible to determine the target ports based on the existence or not of KC_HTTP_PORT
and KC_HTTP_MANAGEMENT_PORT
?
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.
But maybe we could add a managementPort parameter with the same semantics of the port parameter, without messing with target ports.
Yeah this is what I think I meant 😄 Just let the user specify a different management port which we'll assign to the proxy port. Target port will stay the same always (unless user manually edits the added the endpoint, which of course they can still do).
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.
Added with tests!
Co-authored-by: Damian Edwards <[email protected]>
Co-authored-by: Damian Edwards <[email protected]>
Co-authored-by: Damian Edwards <[email protected]>
Co-authored-by: Damian Edwards <[email protected]>
- Retained `HealthCheckEnvVarName` constant; changed type of `ManagementInterfaceContainerPort` to `int` for clarity. - Introduced `defaultEndpointName` and `managementEndpointName` variables in tests to replace hardcoded strings for improved readability. - Updated JSON structure in `VerifyManifest` to change key from "health" to "management" to align with new naming conventions.
1aea6ec
to
c874176
Compare
Description
This PR introduces new constants for health checks, including an environment variable (
KC_HEALTH_ENABLED
), a health check container port (9000), and a health endpoint name (health
). TheAddKeycloak
method is updated to incorporate a health check endpoint and set the health check environment variable to "true" for the Keycloak resource.Fixes #6113
/cc @davidfowl @DamianEdwards
Checklist
<remarks />
and<code />
elements on your triple slash comments?breaking-change
template):doc-idea
template):