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

Enable connectivity to the host network for egress firewall matching pods #2506

Conversation

alexanderConstantinescu
Copy link
Collaborator

Egress firewall matching pods didn't currently have any connectivity to
the host network when a "deny 0.0.0.0" rule is created. That type of a
rule blocked access to all cluster nodes. This was not in-line with the
expectation of how the feature was working for people coming from
openshift-sdn. They thus needed to explicitly allow all node IPs if they
required pods to access the Kube API service, for example. That is not
optimal though as if nodes leave / join the cluster, the rules need to
be updated by the admin. We now have documentation specifically
mentioning that we don't support this, so I am not sure we want this:
openshift/openshift-docs#35311 but this patch
was pretty straightforward to code, so we can discuss it on the PR.
Note: anyone using ovn-kubernetes before this patch (and setting up
specific allow rules for the nodes) should not be impacted negatively by
this patch...but they will have a duplicate ACL for every node they've
explicitly allowed

/assign @JacobTanenbaum @trozet

- What this PR does and why is it needed

- Special notes for reviewers

- How to verify it

- Description for the changelog

@coveralls
Copy link

coveralls commented Sep 21, 2021

Coverage Status

Coverage decreased (-0.08%) to 50.595% when pulling 58aaf64 on alexanderConstantinescu:egress-firewall-host-network into c69080a on ovn-org:master.

@dcbw
Copy link
Contributor

dcbw commented Sep 29, 2021

/lgtm

@alexanderConstantinescu
Copy link
Collaborator Author

Actually hold this, it seems I included a bunch of changes to go.sum, need to clean that up

@alexanderConstantinescu
Copy link
Collaborator Author

We can remove the hold, I've rebased now.

@dcbw
Copy link
Contributor

dcbw commented Oct 18, 2021

@alexanderConstantinescu should we wait on this one til we land the libovsdb bits for routers?

@alexanderConstantinescu
Copy link
Collaborator Author

@alexanderConstantinescu should we wait on this one til we land the libovsdb bits for routers?

No, because we'll need to backport this to earlier versions. But you reminded me that this PR is not good enough, I will need to add a second commit which will not be backported and which will contain the libovsdb implementation - as I did on: #2580

@alexanderConstantinescu
Copy link
Collaborator Author

@dcbw : this patch is now updated and ready. It holds one "legacy" commit using ovn-nbctl, which is intended for backports and a "normal" commit to be used going forward. Both pass the build individually (locally at least)

@alexanderConstantinescu alexanderConstantinescu force-pushed the egress-firewall-host-network branch 2 times, most recently from d42b742 to 2821020 Compare November 1, 2021 11:30
go-controller/pkg/ovn/ovn.go Show resolved Hide resolved
@@ -60,6 +60,7 @@ const (
DefaultDenyPriority = 1000

// priority of logical router policies on the OVNClusterRouter
DefaultEgressFirewallPriority = "10001"
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure this name is suitable. Shouldn't it be like MaxEgressFirewallPriority? Also the EgressFirewallStartPriority should have a comment above it maybe describing that egress firewall priority's are decremented (I forget exactly how this works).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK, I will add some comments.

test/e2e/e2e.go Outdated Show resolved Hide resolved
go-controller/pkg/ovn/egressfirewall_test.go Outdated Show resolved Hide resolved
@trozet
Copy link
Contributor

trozet commented Jan 12, 2022

@alexanderConstantinescu can you rebase/revive this PR please?

…atching pods

This is a legacy commit using ovn-nbctl for the implementation. This is
done as to be able to have the commit backported

Egress firewall matching pods didn't currently have any connectivity to
the host network when a "deny 0.0.0.0" rule is created. That type of a
rule blocked access to all cluster nodes. This was not in-line with the
expectation of how the feature was working for people coming from
openshift-sdn. They thus needed to explicitly allow all node IPs if they
required pods to access the Kube API service, for example. That is not
optimal though as if nodes leave / join the cluster, the rules need to
be updated by the admin. We now have documentation specifically
mentioning that we don't support this, so I am not sure we want this:
openshift/openshift-docs#35311 but this patch
was pretty straightforward to code, so we can discuss it on the PR.
Note: anyone using ovn-kubernetes before this patch (and setting up
specific allow rules for the nodes) should not be impacted negatively by
this patch...but they will have a duplicate ACL for every node they've
explicitly allowed

Signed-off-by: Alexander Constantinescu <aconstan@redhat.com>
…pods

Egress firewall matching pods didn't currently have any connectivity to
the host network when a "deny 0.0.0.0" rule is created. That type of a
rule blocked access to all cluster nodes. This was not in-line with the
expectation of how the feature was working for people coming from
openshift-sdn. They thus needed to explicitly allow all node IPs if they
required pods to access the Kube API service, for example. That is not
optimal though as if nodes leave / join the cluster, the rules need to
be updated by the admin. We now have documentation specifically
mentioning that we don't support this, so I am not sure we want this:
openshift/openshift-docs#35311 but this patch
was pretty straightforward to code, so we can discuss it on the PR.
Note: anyone using ovn-kubernetes before this patch (and setting up
specific allow rules for the nodes) should not be impacted negatively by
this patch...but they will have a duplicate ACL for every node they've
explicitly allowed

Signed-off-by: Alexander Constantinescu <aconstan@redhat.com>
@@ -80,6 +82,66 @@ func newEgressFirewallRule(rawEgressFirewallRule egressfirewallapi.EgressFirewal
return efr, nil
}

func (oc *Controller) addNodeForEgressFirewall(node *v1.Node) error {
v4Addr, v6Addr := getNodeInternalAddrs(node)
Copy link
Contributor

Choose a reason for hiding this comment

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

// getNodeInternalAddrs returns the first IPv4 and/or IPv6 InternalIP defined
// for the node. On certain cloud providers (AWS) the egress IP will be added to
// the list of node IPs as an InternalIP address, we don't want to create the
// default allow logical router policies for that IP. Node IPs are ordered,
// meaning the egress IP will never be first in this list.
func getNodeInternalAddrs(node *v1.Node) (net.IP, net.IP) {

I wonder if we should get all ip addresses on the node, using the the k8s.ovn.org/host-addresses annotation? That would allow access to any IP that lives on a node.

@trozet
Copy link
Contributor

trozet commented Feb 15, 2022

Closing in favor of #2786

@trozet trozet closed this Feb 15, 2022
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.

None yet

6 participants