-
Notifications
You must be signed in to change notification settings - Fork 348
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
Add OAuth Proxy to UI when on OpenShift #100
Conversation
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 Report
@@ 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
Continue to review full report at Codecov.
|
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.
Great job. Haven't tried it out - will do after next round of review.
Name: OAuthProxyAccountNameFor(jaeger), | ||
Namespace: jaeger.Namespace, | ||
Annotations: map[string]string{ | ||
"serviceaccounts.openshift.io/oauth-redirectreference.primary": getOAuthRedirectReference(jaeger), |
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.
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?
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.
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).
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.
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) |
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.
Same comment as above - move to a platform specific SPI?
pkg/inject/oauth-proxy.go
Outdated
|
||
// 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 { |
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.
Shouldn't this also check for platform? All-in-one and production controllers don't check for platform before calling.
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.
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) { |
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.
May need to be updated if platform=openshift check added.
pkg/service/query.go
Outdated
@@ -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), |
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.
As mentioned above, it would be good if things like this could be moved into a platform specific SPI.
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.
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.
6c61685
to
afaa92b
Compare
Signed-off-by: Juraci Paixão Kröhling <[email protected]>
Signed-off-by: Juraci Paixão Kröhling <[email protected]>
Signed-off-by: Juraci Paixão Kröhling <[email protected]>
Signed-off-by: Juraci Paixão Kröhling <[email protected]>
eda6ffc
to
c329960
Compare
Refactoring to support a platform SPI will be handled in a separate PR. |
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.
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)
Closes #89.
Signed-off-by: Juraci Paixão Kröhling [email protected]