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

Add an option for CNI shim to create and configure the pod interface #824

Merged
merged 1 commit into from Sep 17, 2019

Conversation

winsopc
Copy link
Contributor

@winsopc winsopc commented Sep 5, 2019

Currently we use client/server design to create and configure the pod
interface. The client being the ovn-k8s-cni-overlay and server
being the ovnkube-node container. The ovnkube-node creates and
configures the pod interface. This requires It to be running with
SYS_ADMIN capability and this is undesirable.

To make ovnkube-node to run with least capabilities as possible, the idea
is to create and configure the pod interface in the client itself (i.e., in
ovn-k8s-cni-overlay running on the host). In this approach, the deployer
explicity asks for unpriivelged ovnkube-node using a CLI option. The
server returns to client all the pod interface information (ip, mac, gateway,
MTU, ingresss, egress bandwidth, and so on). The client then creates
and sets up the pod interface.

Signed-off-by: Zhen Wang zhewang@nvidia.com

@girishmg
Copy link
Member

girishmg commented Sep 9, 2019

@dcbw @danwinship PTAL

@danwinship
Copy link
Contributor

ovn-kubernetes has way too many modes. Is there any reason to not just always do it this way?

@girishmg
Copy link
Member

girishmg commented Sep 9, 2019

@danwinship it was implemented using a knob for two reasons.

  1. In the last community call, I got the impression that we might need to keep the current default
    behavior as it works out of the box (see bullet (2) below). Furthermore, I also got the
    impression that Redhat wants everything to be containerized and that it doesn't want to run
    anything on the host (see bullet (2) below).

  2. This implementation requires that the ovs-* utilities are available on the host so that the
    ovn-k8s-cni-overlay binary in the host can add one end of the VETH pair to br-int bridge.
    In everything needs to be containerized model, this will not work. In our case, we run
    ovs-vswitchd and ovsdb-server on the host directly. As a result, ovs-* utilities are easily
    available.

@dcbw dcbw changed the title Add an option for host to create and configure the pod interface Add an option for CNI shim to create and configure the pod interface Sep 10, 2019
@dcbw
Copy link
Contributor

dcbw commented Sep 10, 2019

@danwinship if we also ran OVS on the host, then we could use this mode too :( And this is mostly what we do in openshift-sdn except that we do the OVS operation inside our container because that's where our ovs-vsctl lives.

I guess we could switch to this mode if we map our ovs-vsctl binary and the vsctl socket onto the host's filesystem and call it from there?

@girishmg
Copy link
Member

@dcbw @danwinship PTAL. This doesn't use the cniShimConfig.json file anymore, so it is very simple now.

@danwinship
Copy link
Contributor

danwinship commented Sep 13, 2019

Hm... it seems like if we split setupInterface out of ConfigureInterface then we could do this just like we do in openshift-sdn and not need a configuration option; the CNI plugin would call setupInterface and do the privileged netlink operations, and then it would pass the request on to the daemon, which would run the rest of ConfigureInterface to do the OVS operations. And then everyone wins. 🎉 🕺

@girishmg
Copy link
Member

Hm... it seems like if we split setupInterface out of ConfigureInterface then we could do this just like we do in openshift-sdn and not need a configuration option; the CNI plugin would call setupInterface and do the privileged netlink operations, and then it would pass the request on to the daemon, which would run the rest of ConfigureInterface to do the OVS operations. And then everyone wins. 🎉 🕺

Except that the CNI plugin doesn't have any K8s credentials and OVN DB endpoint information. So,
it cannot do setupInterface. To do whatever you are saying, we will need to do to and fro communication between CNI plugin and the CNI server.

  1. CNI plugin to server to get pod interface info
  2. CNI plugin does setupinterface and calls the server
  3. Server configures the interface and returns the result in json
  4. CNI plugin prints the results.

@danwinship
Copy link
Contributor

ah... ok

Copy link
Contributor

@danwinship danwinship left a comment

Choose a reason for hiding this comment

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

mostly looks good then

@@ -71,6 +71,9 @@ var (

// NbctlDaemon enables ovn-nbctl to run in daemon mode
NbctlDaemonMode bool

// PrivilegedMode needs ovnkube-node container to run with SYS_ADMIN capability by default.
PrivilegedMode = true
Copy link
Contributor

Choose a reason for hiding this comment

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

If this was UnprivilegedMode instead then it would match the config flag, and wouldn't need to be initialized here, and could be set directly from the cli.BoolFlag declaration below rather than needing separate code in ovnkube.go.

As for the comment, assuming you go with UnprivilegedMode:

// UnprivilegedMode allows ovnkube-node to run without SYS_ADMIN capability, by performing interface setup in the CNI plugin

(except don't you mean NET_ADMIN anyway?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for reviewing it.
I have updated the code.

IPAddress: ipAddress,
GatewayIP: gatewayIP,
Ingress: ingress,
Egress: egress}
Copy link
Contributor

Choose a reason for hiding this comment

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

style nit: put the } on the next line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

},
}

podIntfaceInfo := &PodIntfaceInfo{
Copy link
Contributor

Choose a reason for hiding this comment

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

"Intface" is weird... Usually people abbreviate "interface" to "iface", but you could also just not abbreviate it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

Currently we use client/server design to create and configure the pod
interface. The client being the ovn-k8s-cni-overlay and server
being the ovnkube-node container. The ovnkube-node creates and
configures the pod interface. This requires It to be running with
SYS_ADMIN capability and this is undesirable.

To make ovnkube-node to run with least capabilities as possible, the idea
is to create and configure the pod interface in the client itself (i.e., in
ovn-k8s-cni-overlay running on the host). In this approach, the deployer
explicity asks for unpriivelged ovnkube-node using a CLI option. The
server returns to client all the pod interface information (ip, mac, gateway,
MTU, ingresss, egress bandwidth, and so on). The client then creates
and sets up the pod interface.

Signed-off-by: Zhen Wang <zhewang@nvidia.com>
@winsopc
Copy link
Contributor Author

winsopc commented Sep 15, 2019

@danwinship Please review my latest code, thanks!

@danwinship
Copy link
Contributor

lgtm

@girishmg girishmg merged commit 8133024 into ovn-org:master Sep 17, 2019
@winsopc winsopc deleted the sdn231 branch September 17, 2019 20:11
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

4 participants