Skip to content
This repository was archived by the owner on Jul 25, 2019. It is now read-only.

[DO NOT MERGE] Convert OpenShift SDN to a CNI plugin - #320

Closed
dcbw wants to merge 4 commits into
openshift:masterfrom
dcbw:cni-plugin
Closed

dcbw wants to merge 4 commits into
openshift:masterfrom
dcbw:cni-plugin

Conversation

@dcbw

@dcbw dcbw commented Jun 10, 2016

Copy link
Copy Markdown
Contributor

Based off @danwinship's plugin reorg branch, so start with the "Use CNI for IPAM instead of docker" commit. Not quite ready for merge yet, but I'd love feedback on the approach, especially the pod info server parts.

cc @pravisankar @rajatchopra @smarterclayton

bridge=$1
mtu=$2

DOCKER_NETWORK_OPTIONS="-b=${bridge} --mtu=${mtu}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This causes docker to set the correct MTU on the veths. You need to add that functionality somewhere else if docker isn't going to do it any more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It gets done by the CNI plugin now:

    err = ns.WithNetNSPath(args.Netns, func(hostNS ns.NetNS) error {
        hostVeth, contVeth, err = ip.SetupVeth(interfaceName, int(netInfo.MTU), hostNS)
        if err != nil {
            return fmt.Errorf("Failed to create container veth: %v", err)
        }

@dcbw

dcbw commented Jun 15, 2016

Copy link
Copy Markdown
Contributor Author

@danwinship PTAL, thanks!

Comment thread plugins/osdn/podinfoserver.go Outdated
}

router.NotFoundHandler = http.HandlerFunc(http.NotFound)
router.Methods("GET").Path("/network").HandlerFunc(s.getNetwork)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am really uncomfortable about creating a new API here (which is what this is) and also not happy to see a new set of API definitions that don't overlap with our existing objects being created. I need to dive into this more and understand the tradeoffs, but like to see a quick writeup of what options you considered and why you chose this approach.

One question I was surprised by - why does the CNI interface not pass enough information down to the network plugin to make a decision there?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@smarterclayton I would not consider the podinfoserver new API; it's private IPC between the openshift-sdn CNI plugin, and the openshift-sdn node plugin. It is not intended to be public in any way, and we would reserve the right to change it at any time.

The options:

  • root-only private unix domain socket: advantages include a very small amount of well-understood code doing very specific things, which closely follows other examples like Docker's API server and client pattern. Authentication and security are protected by simple, common Unix mechanisms like filesystem permissions, and we could additionally protect it through peer credentials if we wanted to. The private API exposed by this socket is small and easily extendable if/when the SDN plugin needs to extend it, but we do not expect or support any other consumers of this API than openshift-sdn.
  • talk to api-server: this would require a larger amount of code in the CNI plugin to create Kube and OpenShift clients and find/read the Pod, VNID, HostSubnet, and other objects the CNI plugin requires. The openshift-sdn node process already has this information because it must track it for other reasons. Furthermore, this would require passing authentication information into the CNI plugin, including any certificates required and the apiserver IP address/hostname.

One question I was surprised by - why does the CNI interface not pass enough information down to the network plugin to make a decision there?

CNI can only pass information that kubelet has; that will soon be extended to pass the PodSpec via containernetworking/cni#247. But that doesn't help openshift-sdn specific stuff like the HostSubnet and the VNID, which still need to be read out-of-band from CNI.

@smarterclayton smarterclayton Jun 22, 2016 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Talked this over with Jordan and David. I think from a security perspective I can live with an API and a unix domain socket. Some things that need to change / happen in order to merge it:

  1. The handlers and structs sent back and forth need to be more strictly versioned and handled. I.e., the path needs to be prefixed with a version /v1/ and the objects should be in a versioned API package sdn/localserver/api/v1 package and well documented
  2. I want to nuke the watches from the SDN server component - it should use a kube client that is passed in (by the openshift node process) to make calls to the server, and potentially add an LRU cache (access control is going to be strictly enforced, much more so in the future)
  3. I would recommend factoring your plugin as an http.Handler that is going to be instantiated by the node code (not directly used from inside openshift-sdn) for now
  4. Use the existing Kube RESTClient client instead of inventing your own - that handles rate limiting, etc
  5. We'll have to sort through the unix domain socket and how it interacts with packaging, but at least for step 1 we are still going to run openshift node with both kubelet and SDN plugin (turned on) - the node process will boot the server, and the expectation the SDN sub binary will run inside of the node container.
  6. We'll deal with splitting into a separate binary later.

@smarterclayton

Copy link
Copy Markdown
Contributor

Do you guys have a design doc / writeup / proposal to cover this work?

@dcbw

dcbw commented Jun 16, 2016

Copy link
Copy Markdown
Contributor Author

Do you guys have a design doc / writeup / proposal to cover this work?

Yes, I'll mail you a link.

Dan Williams added 2 commits June 24, 2016 17:38
Leave docker configuration alone.  Instead, let docker do whatever it
wants to do, then pull the interface out of the docker bridge, clear
the docker assigned addresses and routes, and allocate an address
with the CNI 'host-local' plugin from the node subnet.

NOTE: this breaks HostPort functionality for two reasons; first because
not restarting docker exposes issues like docker #16816 and second because
nothing yet replaces the iptables rules docker adds.
We won't need it in there soon, once the plugin moves to CNI.
@dcbw

dcbw commented Jun 24, 2016

Copy link
Copy Markdown
Contributor Author

@smarterclayton after prototyping using the kube/openshift clients in the CNI plugin and discussing with @danwinship, I've decided to drop the podinfo server for now. We may need it in the future if things become more complicated or contacting the apiserver becomes a performance issue.

I agree with your points (2) and (4) in #320 (comment); the other points are moot with the latest commits. We'll work on making those changes.

In the mean time, PTAL and let me know what you think. Thanks!

@dcbw

dcbw commented Jun 28, 2016

Copy link
Copy Markdown
Contributor Author

@smarterclayton any thoughts on this approach? One issue with not having communication between the CNI plugin and the openshift node process is that it somewhat complicates hostport/containerport redirect functionality (eg, like docker's "-p host:container" functionality) since the long-lived node process doesn't know when pods start/stop since the CNI plugin is now using its own k/os clients.

There's obviously a race between when the CNI plugin creates the
infra container and when openshift-node gets the apiserver update
of the PodIP.  But something has to keep the host port open to
ensure nothing else tries to use it.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants