-
Notifications
You must be signed in to change notification settings - Fork 649
Add health check support for Keycloak container #7122
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 3 commits
b4c775e
cd15831
8f5b2d0
8d68ae4
8a9e05b
b4f542a
c219e7d
c874176
086e02e
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 |
---|---|---|
|
@@ -14,7 +14,10 @@ public static class KeycloakResourceBuilderExtensions | |
{ | ||
private const string AdminEnvVarName = "KEYCLOAK_ADMIN"; | ||
private const string AdminPasswordEnvVarName = "KEYCLOAK_ADMIN_PASSWORD"; | ||
private const string HealthCheckEnvVarName = "KC_HEALTH_ENABLED"; | ||
private const int DefaultContainerPort = 8080; | ||
private const int HealthCheckContainerPort = 9000; | ||
paulomorgado marked this conversation as resolved.
Show resolved
Hide resolved
DamianEdwards marked this conversation as resolved.
Show resolved
Hide resolved
|
||
private const string HealthEndpointName = "health"; | ||
paulomorgado marked this conversation as resolved.
Show resolved
Hide resolved
|
||
private const string RealmImportDirectory = "/opt/keycloak/data/import"; | ||
|
||
/// <summary> | ||
|
@@ -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) | ||
paulomorgado marked this conversation as resolved.
Show resolved
Hide resolved
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. Consider adding the management interface port as an optional parameter too (like 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. Wouldn't that mean that we should also support But maybe we could add a Would it be feasible to determine the target ports based on the existence or not of 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.
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 commentThe reason will be displayed to describe this comment to others. Learn more. Added with tests! |
||
.WithHttpHealthCheck(endpointName: HealthEndpointName, path: "/health/ready") | ||
paulomorgado marked this conversation as resolved.
Show resolved
Hide resolved
|
||
.WithEnvironment(context => | ||
{ | ||
context.EnvironmentVariables[AdminEnvVarName] = resource.AdminReference; | ||
context.EnvironmentVariables[AdminPasswordEnvVarName] = resource.AdminPasswordParameter; | ||
context.EnvironmentVariables[HealthCheckEnvVarName] = "true"; | ||
}); | ||
|
||
if (builder.ExecutionContext.IsRunMode) | ||
|
Uh oh!
There was an error while loading. Please reload this page.