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

Add OAuth Proxy to UI when on OpenShift #100

Merged

Conversation

jpkrohling
Copy link
Contributor

@jpkrohling jpkrohling commented Nov 8, 2018

Closes #89.

Signed-off-by: Juraci Paixão Kröhling juraci@kroehling.de

@jpkrohling
Copy link
Contributor Author

This change is Reviewable

@jpkrohling
Copy link
Contributor Author

jpkrohling commented Nov 8, 2018

This is currently blocked by openshift/oauth-proxy#95. Problem fixed in the latest commit.

Unit tests are passing, as well as end-to-end tests, which execute only on Kubernetes.

Manually testing this on OpenShift, I can see that all the objects are created as required, but I cannot login due to the issue listed above.

So, this is ready for an initial review but shouldn't be merged until the login issue is fixed.

@codecov
Copy link

codecov bot commented Nov 8, 2018

Codecov Report

Merging #100 into master will increase coverage by 0.05%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #100      +/-   ##
==========================================
+ Coverage   99.43%   99.48%   +0.05%     
==========================================
  Files          21       24       +3     
  Lines         879      967      +88     
==========================================
+ Hits          874      962      +88     
  Misses          5        5
Impacted Files Coverage Δ
pkg/account/oauth-proxy.go 100% <100%> (ø)
pkg/controller/production.go 100% <100%> (ø) ⬆️
pkg/controller/all-in-one.go 100% <100%> (ø) ⬆️
pkg/controller/controller.go 100% <100%> (ø) ⬆️
pkg/route/query.go 100% <100%> (ø) ⬆️
pkg/deployment/query.go 100% <100%> (ø) ⬆️
pkg/account/main.go 100% <100%> (ø)
pkg/inject/oauth-proxy.go 100% <100%> (ø)
pkg/service/query.go 100% <100%> (ø) ⬆️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 06ceca0...c329960. Read the comment docs.

@jpkrohling jpkrohling changed the title WIP - Add OAuth Proxy to UI when on OpenShift Add OAuth Proxy to UI when on OpenShift Nov 8, 2018
Copy link
Contributor

@objectiser objectiser left a comment

Choose a reason for hiding this comment

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

Great job. Haven't tried it out - will do after next round of review.

README.adoc Show resolved Hide resolved
deploy/examples/disable-oauth-proxy.yaml Outdated Show resolved Hide resolved
Name: OAuthProxyAccountNameFor(jaeger),
Namespace: jaeger.Namespace,
Annotations: map[string]string{
"serviceaccounts.openshift.io/oauth-redirectreference.primary": getOAuthRedirectReference(jaeger),
Copy link
Contributor

Choose a reason for hiding this comment

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

Just wondering if we can make this more modular, so uses the platform parameter to govern what should be added here, and generate an error if not supported on the platform?

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 started with that, but it felt weird to have if openshift all over the code base.

The idea behind the current approach is that we'd be deciding about the OAuth Proxy based on the enabled flag, and let the controller deal with setting the appropriate flag value based on the platform. The normalize operation will set it to false if not on OpenShift, and default to true if on OpenShift (leaving it as is if explicitly set).

Copy link
Contributor

Choose a reason for hiding this comment

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

Just thinking about future platforms - might be better to define the structure now to make it easier for other platforms to be added - as otherwise it could be quite messy to try to decouple the binary decisions between k8s and openshift at a later date.

}

func getOAuthRedirectReference(jaeger *v1alpha1.Jaeger) string {
return fmt.Sprintf(`{"kind":"OAuthRedirectReference","apiVersion":"v1","reference":{"kind":"Route","name":"%s"}}`, jaeger.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above - move to a platform specific SPI?

pkg/account/oauth_proxy_test.go Show resolved Hide resolved

// OAuthProxy injects an appropriate OpenShift proxy into the given deployment
func OAuthProxy(jaeger *v1alpha1.Jaeger, dep *appsv1.Deployment) *appsv1.Deployment {
if jaeger.Spec.Ingress.OAuthProxy == nil || !*jaeger.Spec.Ingress.OAuthProxy {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this also check for platform? All-in-one and production controllers don't check for platform before calling.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The normalize() operation will set the flag to false if the platform doesn't support the OAuth proxy. I should actually remove the reference to OpenShift from this godoc.

assert.Equal(t, "jaeger-query", dep.Spec.Template.Spec.Containers[0].Name)
}

func TestOAuthProxyContainerIsAdded(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

May need to be updated if platform=openshift check added.

pkg/inject/oauth-proxy_test.go Show resolved Hide resolved
@@ -22,6 +24,9 @@ func NewQueryService(jaeger *v1alpha1.Jaeger, selector map[string]string) *v1.Se
Name: GetNameForQueryService(jaeger),
Namespace: jaeger.Namespace,
Labels: selector,
Annotations: map[string]string{
"service.alpha.openshift.io/serving-cert-secret-name": GetTLSSecretNameForQueryService(jaeger),
Copy link
Contributor

Choose a reason for hiding this comment

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

As mentioned above, it would be good if things like this could be moved into a platform specific SPI.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I think this will be the only place outside of the inject package (and the normalize) that we have OpenShift-specific knowledge for the OAuth Proxy (the other feature being Routes vs. Ingresses). For now, I'll just add a check on the OAuth Proxy flag and wait for a second implementation before extracting a provider interface.

pkg/service/query_test.go Outdated Show resolved Hide resolved
@jpkrohling jpkrohling force-pushed the 89-Protect-ui-with-OAuth-Proxy branch from 6c61685 to afaa92b Compare November 9, 2018 13:32
Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
@jpkrohling jpkrohling force-pushed the 89-Protect-ui-with-OAuth-Proxy branch from eda6ffc to c329960 Compare November 9, 2018 15:25
@objectiser
Copy link
Contributor

Refactoring to support a platform SPI will be handled in a separate PR.

@jpkrohling jpkrohling mentioned this pull request Nov 9, 2018
Copy link
Contributor

@objectiser objectiser left a comment

Choose a reason for hiding this comment

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

Reviewed 5 of 20 files at r1, 17 of 18 files at r3.
Reviewable status: all files reviewed, 7 unresolved discussions (waiting on @jpkrohling and @objectiser)

@objectiser objectiser merged commit 3ddcd1f into jaegertracing:master Nov 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants