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

integrate konflux-ui with namespace-lister #5297

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

filariow
Copy link
Member

Signed-off-by: Francesco Ilario [email protected]

Copy link

openshift-ci bot commented Jan 16, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@filariow filariow force-pushed the integrate-namespace-lister-ui branch from b9960bb to 79c08ab Compare January 16, 2025 14:09
@filariow
Copy link
Member Author

/hold

@filariow filariow marked this pull request as ready for review January 16, 2025 14:15
@filariow filariow requested a review from gbenhaim January 16, 2025 14:16
rewrite ^/(.*)/$ /$1 permanent;
proxy_pass https://kubernetes.default.svc;
if ($request_method = GET) {
proxy_pass http://namespace-lister.namespace-lister.svc.cluster.local:8080;
Copy link
Member

Choose a reason for hiding this comment

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

please use https. certificates for namespace-lister can be generated using openshift https://docs.openshift.com/container-platform/4.15/security/certificates/service-serving-certificate.html

# namespace-lister endpoint
rewrite ^/(.*)/$ /$1 permanent;
proxy_pass https://kubernetes.default.svc;
if ($request_method = GET) {
Copy link
Member

Choose a reason for hiding this comment

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

it's discouraged to use "if" in location blocks. can we use map instead?

@@ -161,6 +161,24 @@ http {
include /mnt/nginx-generated-config/bearer.conf;
}

location ~* /api/v1/namespaces(/?)$ {
Copy link
Member

Choose a reason for hiding this comment

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

the ui prefixes requests to the k8s api with /api/k8s/

include /mnt/nginx-generated-config/bearer.conf;

# namespace-lister endpoint
rewrite ^/(.*)/$ /$1 permanent;
Copy link
Member

Choose a reason for hiding this comment

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

we should use break instead of permanent. we want to reverse proxy not redirect.

@filariow filariow requested a review from gbenhaim January 16, 2025 15:35
Copy link
Contributor

@sadlerap sadlerap left a comment

Choose a reason for hiding this comment

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

lgtm, please fix merge conflicts

@filariow
Copy link
Member Author

@sadlerap thanks for merging the conflicts

Copy link

openshift-ci bot commented Jan 16, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: filariow, sadlerap
Once this PR has been reviewed and has the lgtm label, please assign ksprinkl for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sadlerap
Copy link
Contributor

/retest

Signed-off-by: Francesco Ilario <[email protected]>
Signed-off-by: Francesco Ilario <[email protected]>
@filariow filariow force-pushed the integrate-namespace-lister-ui branch from 7c062c9 to 539b099 Compare January 16, 2025 17:31
@@ -3,11 +3,13 @@ kind: Service
metadata:
name: namespace-lister
namespace: namespace-lister
annotations:
service.beta.openshift.io/serving-cert-secret-name: namespace-lister-tls
Copy link
Member

Choose a reason for hiding this comment

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

I would expect to see a change to namespace-lister deployment as well for mounting the tls certificates.

Copy link
Member Author

Choose a reason for hiding this comment

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

namespace-lister is not supporting TLS at the moment. let's move this to a future PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've filed konflux-ci/namespace-lister#29 to enable it in namespace-lister.

@@ -161,6 +161,25 @@ http {
include /mnt/nginx-generated-config/bearer.conf;
}

location ~* /api/k8s/api/v1/namespaces(/?)$ {
Copy link
Member

Choose a reason for hiding this comment

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

I think this can be simplified by dropping the regex expression. wdyt?

Copy link
Member Author

Choose a reason for hiding this comment

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

IIUC, If we remove this regex this will become the path every namespaced request will take, e.g. api/v1/namespaces/my-ns/pods will be processed by this rule

Copy link
Contributor

Choose a reason for hiding this comment

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

Correct. We only want to match on requests for namespace resources, i.e. when the path is /api/k8s/api/v1/namespaces or /api/k8s/api/v1/namespaces/.

If I'm understanding nginx's docs correctly, we could set it up like this and have it work:

Suggested change
location ~* /api/k8s/api/v1/namespaces(/?)$ {
location = /api/k8s/api/v1/namespaces/ {

This would match the path we want, both with and without the trailing slash. However, this has slightly different behavior than what we currently have: nginx will issue a 301 permanent redirect from /api/k8s/api/v1/namespaces to /api/k8s/api/v1/namespaces/, which I'm not sure I'm a fan of. To me, the regex is clearer in its intent.

Also, if we do decide to use regex matching here, we should probably do case-sensitive matching:

Suggested change
location ~* /api/k8s/api/v1/namespaces(/?)$ {
location ~ /api/k8s/api/v1/namespaces(/?)$ {

Signed-off-by: Francesco Ilario <[email protected]>
@filariow filariow force-pushed the integrate-namespace-lister-ui branch from a062b59 to 38ff1ef Compare January 16, 2025 18:38
Signed-off-by: Francesco Ilario <[email protected]>
Signed-off-by: Francesco Ilario <[email protected]>
Copy link
Contributor

@sadlerap sadlerap left a comment

Choose a reason for hiding this comment

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

Looks okay, but there's a merge conflict that can't be resolved from github's web interface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants