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

Create NPEP-127 for external ingress endpoints #128

Closed
wants to merge 1 commit into from

Conversation

npinaeva
Copy link
Member

An attempt to collect use cases for external ingress endpoints.
Reviews and more examples are welcome.

Tracking issue #127

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 20, 2023
@netlify
Copy link

netlify bot commented Jul 20, 2023

Deploy Preview for kubernetes-sigs-network-policy-api ready!

Name Link
🔨 Latest commit 4e8beea
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-network-policy-api/deploys/652026ff29284800086db35b
😎 Deploy Preview https://deploy-preview-128--kubernetes-sigs-network-policy-api.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 20, 2023
Copy link
Member

@astoycos astoycos left a comment

Choose a reason for hiding this comment

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

I think we still have some thinking to do on this one. It seems like we're going after a pretty broad set of use cases, some of which may not be as important.

The default-deny user story resonates with me, however for the others (concerning pods as the "selected entities" not Nodes) I generally feel like having a pod exposed to the "outside world" is a rare case. i.e even with all the mentioned ingress APIs there's usually a cluster -entity which routes/load balances or directs external traffic do destination pods, which we can already block traffic from today.

Lastly we need to think carefully about having a NPEP which references multi-cluster scenarios...as I think the scope could quickly explode.

npep/npep-127.md Outdated Show resolved Hide resolved
npep/npep-127.md Outdated
Comment on lines 34 to 38
- zero trust policy: As a cluster administrator I want to set up default deny all ingress policy as a BANP.

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- zero trust policy: As a cluster administrator I want to set up default deny all ingress policy as a BANP.
- zero trust policy: As a cluster administrator I want to set up default deny all ingress guardrails with a BANP.

Copy link
Member Author

Choose a reason for hiding this comment

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

I am trying to distinguish ANP vs BANP policies with the word "default", because BANP is just the default overridable policy, and I am not sure is guardrails word makes this semantics any more obvious, wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, I don't think we actually ever used the word "guardrails" in a consistent way

npep/npep-127.md Outdated
get to the cluster workloads. This should apply not only to the connections coming from the other cluster workloads, but to
all incoming connections.

- block well-known ports: As a cluster administrator I want to block all ingress traffic on specific ports.
Copy link
Member

Choose a reason for hiding this comment

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

Will/should this apply to well-known ports on Pods AND nodes?

Copy link
Member Author

Choose a reason for hiding this comment

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

If you are talking about subjects, then only pods, since (B)ANP only applies to non-host network pods (what we call cluster workload)?
from the peer side, this should apply to any ingress traffic, from pods, nodes, external endpoints, and anything else that can reach pods

npep/npep-127.md Outdated
compromised, it will not be able to affect other worker nodes. To do so, I want to create a cluster-wide policy to
deny ingress connections from some of the cluster nodes. I may also need to explicitly allow access from the control plane nodes.

- inter-cluster communication: As a cluster manager for multiple clusters I want to make sure ingress connections
Copy link
Member

Choose a reason for hiding this comment

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

Hrm so on this one I think it's not really important to isolate this user story to "ingress connections are only allowed from a pre-defined set of related clusters". More specifically, if we're planning on identifying foreign clusters by networkCIDR there's no way to distinguish between a "foreign cluster" and just a plain old "external client" right?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah right, I think inter-cluster part should go to the example

npep/npep-127.md Outdated
have limited access to the management cluster workloads by selecting management cluster workloads I want to protect
and a set of allowed subnets for the corresponding hosted clusters.

- external services: As a cluster manager I want to make sure ingress connections from a pre-defined set of external endpoints
Copy link
Member

Choose a reason for hiding this comment

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

This is broad "pre-defined set of external endpoints" what's defined as an external endpoint? can it be ANY IP?

Also this is the first time I see "can't be denied by the namespace owners" can you add a note somewhere that all the other user stories are explicitly non-overridable by namespace owners?

Copy link
Member Author

Choose a reason for hiding this comment

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

not sure what is the best place to clarify this, but I refer to external endpoints in this NPEP as anything outside the cluster. So I would say any IP, unless you see any problem with that?


* Implement ingress traffic control from external destinations (outside the cluster)

## Non-Goals
Copy link
Member

Choose a reason for hiding this comment

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

Determining the non-goals here is going to be really important... I think we need to narrow this NPEP down

Copy link
Member Author

Choose a reason for hiding this comment

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

that would be nice, but I just don't have any ideas on what to put here for now. I hoped that something will be outlined in the discussion here, if you have any ideas for non-goals, please lmk :)

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: npinaeva
Once this PR has been reviewed and has the lgtm label, please assign astoycos for approval. 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

Copy link
Member Author

@npinaeva npinaeva left a comment

Choose a reason for hiding this comment

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

thanks a lot for a review @astoycos !

npep/npep-127.md Outdated
get to the cluster workloads. This should apply not only to the connections coming from the other cluster workloads, but to
all incoming connections.

- block well-known ports: As a cluster administrator I want to block all ingress traffic on specific ports.
Copy link
Member Author

Choose a reason for hiding this comment

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

If you are talking about subjects, then only pods, since (B)ANP only applies to non-host network pods (what we call cluster workload)?
from the peer side, this should apply to any ingress traffic, from pods, nodes, external endpoints, and anything else that can reach pods

npep/npep-127.md Outdated
compromised, it will not be able to affect other worker nodes. To do so, I want to create a cluster-wide policy to
deny ingress connections from some of the cluster nodes. I may also need to explicitly allow access from the control plane nodes.

- inter-cluster communication: As a cluster manager for multiple clusters I want to make sure ingress connections
Copy link
Member Author

Choose a reason for hiding this comment

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

yeah right, I think inter-cluster part should go to the example

npep/npep-127.md Outdated
have limited access to the management cluster workloads by selecting management cluster workloads I want to protect
and a set of allowed subnets for the corresponding hosted clusters.

- external services: As a cluster manager I want to make sure ingress connections from a pre-defined set of external endpoints
Copy link
Member Author

Choose a reason for hiding this comment

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

not sure what is the best place to clarify this, but I refer to external endpoints in this NPEP as anything outside the cluster. So I would say any IP, unless you see any problem with that?

npep/npep-127.md Outdated Show resolved Hide resolved
npep/npep-127.md Outdated Show resolved Hide resolved
npep/npep-127.md Outdated
Comment on lines 49 to 54
- compromised node protection: As a cluster administrator I want to make sure a compromised node can't send traffic to the
cluster workloads scheduled on the other nodes.

Example: my cluster has a set of nodes with very sensitive workloads, I want to make sure that if a worker node A is
compromised, it will not be able to affect other worker nodes. To do so, I want to create a cluster-wide policy to
deny ingress connections from some of the cluster nodes. I may also need to explicitly allow access from the control plane nodes.
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm... so are there pods on the compromised node? Can't the attacker forge connections from pod IPs rather than the node IP? Or is it assumed that that will be blocked as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

this user story considers that all pods from the same namespace are on the same node, and that inter-namespace communication is also denied. I omitted it since we already have the means to implement this part with namespace selectors (and potentially tenancy is you label namespace with nodes), but maybe it makes sense to add these details

it is applied to the cluster workloads, and should provide the required level of security regardless of how/if a cluster workload
is exposed to the outer world.

### Use cases
Copy link
Contributor

Choose a reason for hiding this comment

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

So all of these are pretty vague about what kind of cluster ingress they're talking about, but there are a lot of different kinds, and some are harder to deal with than others, so I think it's important that our user stories explain what sorts of ingress activity it is that the admin cares about. (Even if it turns out that we declare some of these ingress types to be Non-Goals, it's good to be able to see clearly what sort of user stories we decided we can't solve right now.)

eg:

  • direct delivery to hostNetwork pod
  • pod HostPort
  • direct delivery to pod-network pod IP (for network plugins that support that)
  • service NodePort (with Cluster or Local externalTrafficPolicy)
  • service ExternalIP (with Cluster or Local externalTrafficPolicy)
  • service LoadBalancer IP (with Cluster or Local externalTrafficPolicy)
  • direct delivery to service ClusterIP (for network plugins that support that)
  • Ingress/Gateway (which generally resolves to one of the above, but exactly which one is implementation-dependent).

Copy link
Member Author

Choose a reason for hiding this comment

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

I considered the way traffic reaches the pod to be not important in this context (meaning it should work in all situations), but now I think it may be useful to differentiate, e.g. in case some plugins can't implement CIDR-based filtering for some options. Or how do you think we should use this list in this context?

Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO let's just start really really simple. Just keep simple specific use cases that are not implementation specific, for me I want to be able to create policies for ingress (southbound traffic) for when pods are accessed using external traffic policy = local load balancer by an external client. Here the srcIP is that of the clientIP and I want to say whether this connection should be served by my pod
BUT
as soon as I re-read what I wrote above ^ :P that defies my definition of "service" because ofc that pod is supposed to serve all clients right? :) because its exposed as a service to the outside world?
AGAIN
I might wanna only allow a subset of clients to talk to this service so adding policies in a way to protect my backend pods..

Copy link
Contributor

Choose a reason for hiding this comment

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

direct delivery to hostNetwork pod
pod HostPort

^ these seem very rare on cloud env's as use cases, can't think of any BUT on BMs can be useful but then again mostly the bastion or jump host or whatever you put on the same subnet and put accessible routes to is an entity you are consciously choosing to allow.. why would we want to block that...

Even if it turns out that we declare some of these ingress types to be Non-Goals, it's good to be able to see clearly what sort of user stories we decided we can't solve right now.)

right ^ good idea so that when we get asked why the current cidr and node peers are only egress.. we can just look at the non-goals section of this NPEP.

Copy link
Contributor

@danwinship danwinship Apr 4, 2024

Choose a reason for hiding this comment

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

I considered the way traffic reaches the pod to be not important in this context (meaning it should work in all situations)

I mean, ideally, yes, certainly. But in practice that is impossible, because the network policy implementation is normally completely separate from cloud LBs and Gateway mechanisms, and has no power over them or even any insight into how they work. Cluster ingress, as currently defined, is a very leaky abstraction.

We talked about this a little at KubeCon Paris and Shane mentioned https://github.com/kubernetes-sigs/gateway-api/blob/main/geps/gep-735/index.md which is a (Declined) GEP about doing policy-ish stuff in Gateway Routes. It is likely that for some user stories, providing a non-ANP policy API inside Gateway API is likely to work better than trying to implement ANP policy against arbitrary Gateway mechanisms. There was talk about doing a "GEPNPEP"...

(This is somewhat related to the problem of pod-to-cloud-LB-to-whatever traffic discussed in #203, and one thing that could potentially help to solve both would be to come up with a "bigger" model of "Kubernetes Networking" that makes the cloud network and gateways more legible to the network policy implementation. In theory, this could be part of KNI, though it is not something currently being discussed.)

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 22, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle rotten
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Feb 21, 2024
@astoycos
Copy link
Member

/remove-lifecycle rotten
/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Feb 21, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 3, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle rotten
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Aug 2, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Reopen this PR with /reopen
  • Mark this PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

@k8s-ci-robot
Copy link
Contributor

@k8s-triage-robot: Closed this PR.

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Reopen this PR with /reopen
  • Mark this PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@npinaeva
Copy link
Member Author

/reopen

@k8s-ci-robot
Copy link
Contributor

@npinaeva: Failed to re-open PR: state cannot be changed. The npep-ingress branch was force-pushed or recreated.

In response to this:

/reopen

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants