Skip to content
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

Console Google SSO support in operator #6282

Merged
merged 5 commits into from
Sep 9, 2022

Conversation

pvsune
Copy link
Contributor

@pvsune pvsune commented Aug 31, 2022

Cover letter

Support Enterprise Google SSO in Console controller as described here.

Fixes #2760

Backport Required

  • not a bug fix
  • issue does not exist in previous branches
  • papercut/not impactful enough to backport
  • v22.2.x
  • v22.1.x
  • v21.11.x

UX changes

This PR introduces Enterprise fields configurable in the Console CR. Note that Enterprise fields are ignored by Console app if License is not set:

apiVersion: redpanda.vectorized.io/v1alpha1
kind: Console
metadata:
  name: test-console
  namespace: default
spec:
  ...
  login:
    enabled: true
    jwtSecretRef:
      name: "test-console-jwt"
      namespace: "default"
      key: "jwt" # jwt is default if not provided 
    google:
      enabled: true
      clientCredentialsRef:
        name: "test-console-google" # expects clientId, clientSecret in configmap key
        namespace: "default"
      directory:
        serviceAccountRef:
          name: test-console-google-sa # expects sa.json in configmap key
        targetPrincipal: [email protected]
  licenseRef:
    name: "test-console-license"
    namespace: "default"
    key: "license" # license is default if not provided 
  enterprise:
    rbac:
      enabled: true
      roleBindingsRef:
        name: "test-console-rbac" # expects rbac.yaml in configmap key

By design, referenced resources (i.e. ConfigMap Secret) are not watched because they are not owned by the controller. That means updating them requires a manual reload of the Console app (e.g. changes to RBAC file)

Release notes

Features

  • Introduces NamespaceNameRef type instead of using the full glory of corev1.ObjectReference
  • Introduce SecretKeyRef type to reference Secret objects
  • Add defaulting webhook for Console

Improvements

  • Use Redpanda wildcard certificate for Ingress since Console is exposed through https://console.<rp-subdomain>
  • Rename ClusterKeyRef to ClusterRef
  • Run Console kuttl tests in "console" namespace. I think there's no way to get the autogenerated kuttl namespace and we need to refer that in ClusterRef

@pvsune pvsune changed the base branch from dev to pvsune/rp-console September 1, 2022 05:18
@pvsune pvsune force-pushed the enterprise/pvsune/rp-console branch from 5ea26e4 to b1064da Compare September 1, 2022 05:20
@pvsune pvsune changed the base branch from pvsune/rp-console to dev September 1, 2022 05:20
@pvsune pvsune force-pushed the enterprise/pvsune/rp-console branch from b1064da to a2a5d19 Compare September 1, 2022 05:21
@pvsune pvsune changed the title Enterprise/pvsune/rp console Console Google SSO support in operator Sep 1, 2022
@pvsune pvsune force-pushed the enterprise/pvsune/rp-console branch 6 times, most recently from 5e83353 to 41fc799 Compare September 2, 2022 03:33
@pvsune pvsune marked this pull request as ready for review September 2, 2022 07:53
@pvsune pvsune requested a review from a team as a code owner September 2, 2022 07:53
Copy link
Contributor

@RafalKorepta RafalKorepta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good Job Left comments.

@@ -0,0 +1,43 @@
package v1alpha1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: commit message shouldn't have dot at the end.

wrong

operator: Support Google SSO Enterprise feature.

good

operator: Support Google SSO Enterprise feature

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commit lacks of more context like cover letter have. It could be easier for future ppl to read commit message instead of going to github to read the context.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I updated the commits

Comment on lines 11 to 25
// SecretKeyRef contains enough information to inspect or modify the referred Secret data
// REF https://pkg.go.dev/k8s.io/api/core/v1#ObjectReference
type SecretKeyRef struct {
Name string `json:"name"`
Namespace string `json:"namespace"`

// +optional
// Key in Secret data to get value from
Key string `json:"key,omitempty"`
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be more generic and works for config map too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can. But I'm thinking if it is better to have a static mount path for files referenced by configmaps (e.g. Google SA file will always be in /etc/console/enterprise/google/sa.json)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mount path is different thing from key path from configmap. As far as I saw Key is used to point the key inside secret.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we can do that. Although it feels a little off 😅 that the key is different from the mounted path. We already have validating/defaulting webhook for this though. If possible I'd like to keep this change simple 🙏

Comment on lines 145 to 151
loginConfig, err := cm.genLogin(ctx)
if err != nil {
return "", err
}
if loginConfig != nil {
consoleConfig.Login = *loginConfig
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The genLogin could return the real type, so that you would not need to support second if statement. I would return real type not pointer from genLogin

Suggested change
loginConfig, err := cm.genLogin(ctx)
if err != nil {
return "", err
}
if loginConfig != nil {
consoleConfig.Login = *loginConfig
}
consoleConfig.Login, err := cm.genLogin(ctx)
if err != nil {
return "", err
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

src/go/k8s/pkg/console/configmap.go Outdated Show resolved Hide resolved
Comment on lines 14 to 21
Name string `json:"name"`
Namespace string `json:"namespace"`

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add godoc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Key field has comment. This is pointed to a newline, do you mean for Namespace, Name?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No this comment points on lines 14-16 where Name and Namespace is not documented in openAPI spec when CRD is generated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Updated

@pvsune pvsune force-pushed the enterprise/pvsune/rp-console branch 5 times, most recently from c06ec16 to 61e7828 Compare September 5, 2022 12:32
Copy link
Contributor

@RafalKorepta RafalKorepta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if webhook is correctly implemented as it reverse the order how webhooks should be called

src/go/k8s/pkg/resources/ingress.go Outdated Show resolved Hide resolved
src/go/k8s/config/webhook/manifests.yaml Outdated Show resolved Hide resolved
src/go/k8s/pkg/console/configmap.go Outdated Show resolved Hide resolved
src/go/k8s/pkg/console/configmap.go Outdated Show resolved Hide resolved
src/go/k8s/webhooks/redpanda/console_webhook.go Outdated Show resolved Hide resolved
src/go/k8s/controllers/redpanda/console_controller_test.go Outdated Show resolved Hide resolved
src/go/k8s/controllers/redpanda/console_controller_test.go Outdated Show resolved Hide resolved
src/go/k8s/controllers/redpanda/console_controller_test.go Outdated Show resolved Hide resolved
src/go/k8s/controllers/redpanda/console_controller_test.go Outdated Show resolved Hide resolved
src/go/k8s/controllers/redpanda/console_controller_test.go Outdated Show resolved Hide resolved
Support adding SSO in Console using Google as provider
This feature requires license and is specified in the Console spec as a SecretKeyRef
REF https://docs.redpanda.com/docs/console/single-sign-on/identity-providers/google/
@pvsune pvsune force-pushed the enterprise/pvsune/rp-console branch from 5f06b0c to a827be5 Compare September 8, 2022 00:42
@pvsune pvsune force-pushed the enterprise/pvsune/rp-console branch 3 times, most recently from fbed6e7 to 3860214 Compare September 8, 2022 06:10
Creating a new certificate from cert-manager takes a long time and sometimes fail
Use existing Cluster certificate that has wildcard SANs since we are using "console.<rp-subdomain>"
- Add new mutating webhook that defaults fields for Console
- Refactor required keys used for validating/mutating to vars
…jectReference

- Rename ClusterKeyRef to ClusterRef
- Use the NamespaceNameRef for ClusterRef, Google SSO ClientCredentialsRef
- REF https://pkg.go.dev/k8s.io/api/core/v1#ObjectReference
…ttl tests.

Default namespace doesn't get cleaned up on succeeding tests
But no way to reference the auto-generated kuttl namespace in Console clusterKeyRef spec
@pvsune pvsune force-pushed the enterprise/pvsune/rp-console branch from 3860214 to 62be321 Compare September 8, 2022 06:25
@pvsune pvsune merged commit 385261a into redpanda-data:dev Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cannot build on ubuntu 20.04
3 participants