-
Notifications
You must be signed in to change notification settings - Fork 3
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
[DOM-47678] Add Keycloak service account token support for image builds #101
Conversation
8ba7ab6
to
10a4895
Compare
// cfg.Scopes... | ||
jwt, err := kc.LoginClient(buildCtx, c.keycloakCfg.ClientID, c.keycloakCfg.ClientSecret, c.keycloakCfg.Realm) | ||
if err != nil { | ||
log.Error(err, fmt.Sprintf("Failed to acquire Keycloak credentials %s", c.keycloakCfg.ClientID)) |
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.
maybe this should fail the build?
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.
If the build requested it and it's not available, that would makes sense to me... just want to understand what the retry process looks like. I assume client is fully responsible for owning that process.
a81653b
to
344b48e
Compare
- Exposes config in values.yaml for chart, then inject into the equivalent secret values for the operator
- Temporary import to prevent removal
344b48e
to
245af02
Compare
3043408
to
a704e39
Compare
- When configured to inject service account tokens into the build, pass a build arg to the Docker build as SERVICE_TOKEN=<JWT>. This allows builds to contact additional services in the cluster using a specific service account identity. The value is consumed by adding to the Dockerfile: ARG SERVICE_TOKEN
- If Keycloak configuration is disabled, but the incoming CR request asked for Keycloak token injection, then error / exit the build
a704e39
to
76f3d90
Compare
@@ -409,6 +409,19 @@ func (suite *GenericImageBuilderTestSuite) TestImageBuilding() { | |||
assert.Equalf(t, ib.Status.Phase, hephv1.PhaseSucceeded, "failed build with message %q", ib.Status.Conditions[0].Message) | |||
}) | |||
|
|||
suite.T().Run("token_injection", func(t *testing.T) { |
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.
Note - this test doesn't run as part of PRs :(
return ctrl.Result{}, c.phase.SetFailed(ctx, obj, fmt.Errorf("keycloak token acquire failed: %w", err)) | ||
} | ||
|
||
obj.Spec.BuildArgs = append(obj.Spec.BuildArgs, fmt.Sprintf("%s=%s", hephv1.ServiceTokenArgName, jwt.AccessToken)) |
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.
Exposing as a build arg is a bad way to do this as sensitive values may find their way into logs or image metadata
Going to close this as we've decided to move forward with the approach in #106 instead |
Described in https://docs.google.com/document/d/1LXl0aUKAZk9jpnKKGZZxrw3VFRxjAdLqa2WZriSj6Fc/edit as
Add Keycloak token acquisition support to Hephaestus
Image is consumable at https://github.com/dominodatalab/hephaestus/pkgs/container/hephaestus/103580396?tag=pr-101
Testing in a real deploy via cli invocation like
And a
dev-values.yaml
config likeInside of Domino, there is an environment defined like:
FROM
set todocker.io/library/alpine:latest
Initial implementation verification
Build succeeded at https://mldemo4507.train-sandbox.domino.tech/environments/64920eb0bb2e9b737895a5b6/revisions/649396a7bb2e9b737895a5f5/build/649396a7bb2e9b737895a5f7/logs
After updating CRD with
EnableServiceAccountTokenInjection
field defaulting to falseWithout client updates
I triggered another build without updating any code to verify that the new field is optional and defaults to false at https://mldemo4507.train-sandbox.domino.tech/environments/64920eb0bb2e9b737895a5b6/revisions/6493a50ebb2e9b737895a5f8/build/6493a50ebb2e9b737895a5fa/logs
The build completed successfully and did not inject the token as a build-arg
Submitting a CR that sets the value
EnableServiceAccountTokenInjection
** TBD **