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

Updating NW Policy to have notebook pod connect to DSP APIServer #556

Closed
wants to merge 1 commit into from
Closed

Conversation

DharmitD
Copy link
Member

@DharmitD DharmitD commented Jan 24, 2024

The issue resolved by this Pull Request:

Resolves RHOAIENG-1689

Description of your changes:

Updating the DSPA network policy to have notebook pod connect to DSP APIServer, so that the notebook pods could connect to the DSP API Server without OAuth token interference.

Testing instructions

Deploy DSPO and a DSPA instance based on these changes.

Checklist

  • The commits are squashed in a cohesive manner and have meaningful messages.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work

Copy link
Contributor

openshift-ci bot commented Jan 24, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from dharmitd. For more information see the Kubernetes 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

@dsp-developers
Copy link
Contributor

Change to PR detected. A new PR build was completed.
A new image has been built to help with testing out this PR: quay.io/opendatahub/data-science-pipelines-operator:pr-556

@@ -64,6 +64,12 @@ spec:
matchLabels:
app: ds-pipeline-metadata-writer-{{.Name}}
component: data-science-pipelines
- podSelector:
matchLabels:
opendatahub.io/dashboard: 'true'
Copy link
Contributor

Choose a reason for hiding this comment

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

Posting here for posterity. Before he posted the PR, I asked Dharmit, Is this the label that @harshad16 recommended to use?

Turns out this is currently the only static, reliable label on every notebook pod. However, I don't like that it's named "dashboard" and I'm not sure if it will always stay there. And I believe @DharmitD has opened a Jira to ask for a better label (is that right @DharmitD )?

So I wonder if we'd be better off somehow templating the label name we're matching as well, to make it less brittle.

What do others think?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this is the only static label on notebook pods currently, here's the task we've created requesting for an exclusive static label for notebooks: opendatahub-io/notebooks#387

I agree that "dashboard" name on the label doesn't sound right, but I'm out of ideas on how we could template our network policy to grab the notebook pod name label, or any other dynamic notebook labels. @harshad16 or anyone else might have some ideas?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nah, there's no way that we could template in a dynamic notebook label at DSPA creation time, which is when the NetworkPolicy gets inserted. A possible option would be to have something on the notebook side ("notebook controller"? I don't know the architecture over there) be the thing that lays down a NetworkPolicy update at notebook pod creation time.

On a separate topic ... how secure is it to allow something to bypass our oauth proxy with a simple label (granted, the pod being labeled has to be in the correct namespace too...) ?

Copy link
Member

Choose a reason for hiding this comment

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

Here is my chain of thought:
Based on the discussion to which I was invited, it was just been asked which labels are currently available on the workbench that is standard across all workbenches.
Currently, opendatahub.io/dashboard: 'true' is the only label that is added to all workbenches.

Going forward, we would have to create a label that exclusively attaches to all the workbenches.
that being said: pointing out, we have the requirement, that existing notebooks are not to be hindered,
so our logic of applying a new label would only apply to new workbenches or restarted ones, not to the existing Notebook in the cluster.
Based on this, if we would like to address all workbenches, then the current label is the only option, if that's not the case, we can create a new label for new workbenches.

Copy link
Contributor

Choose a reason for hiding this comment

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

makes sense. I'd still rather have a new label, and maybe we can say something like "you need to recreate your notebook if you want to be able to seamlessly connect to DSP"

Copy link
Member Author

Choose a reason for hiding this comment

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

makes sense. I'd still rather have a new label
+1

Copy link
Contributor

Choose a reason for hiding this comment

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

ok so since we know the label will change, I'm looking for another opinion on whether we should leave it as a hardcoded string here, or if we should template. I'm personally ok with the hardcode, but I'm worried that I'm not thinking through upgrade scenarios.

@gregsheremeta
Copy link
Contributor

gregsheremeta commented Jan 25, 2024

mostly lgtm at this point, but I want someone who knows more about NetworkPolicy and overall kubernetes security to review this. I want to know if there are any risks to bypassing oauth this way. Could an attacker easily bypass DSP authentication by adding a label to the attacking pod? (I suppose if someone has privileges to set a label on a pod in the namespace, they could probably directly access the DSP pod anyway?)

@gregsheremeta
Copy link
Contributor

@strangiato wouldn't mind your opinion on this. You seem knowledgeable about stuff like this.

@DharmitD DharmitD closed this by deleting the head repository Jan 29, 2024
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.

5 participants