Skip to content

Commit

Permalink
daemon / cni: move to Cell, watch for changes
Browse files Browse the repository at this point in the history
Refactor the CNI controller to use the Hive / Cell mechanism. This means
simplifying the underlying controller and making it run immediately,
rather than waiting for the Daemon to start. This mirrors the existing
behavior of the postStart hook, which will be going away.

The controller now also watches the CNI configuration directory and
reconciles whenever a file has changed; this is needed because some
chaining modes (e.g. AWS) need to wait until the aws-cni plugin installs
its own CNI configuration file. We then want to install our chained
plugin ASAP.

Previously, we would just loop until the configuration was created, but
that is fragile. Rather, set up an fsnotify and watch for changes that
way. This has the advantage of re-generating the chained configuration should
the underlying network change.

Signed-off-by: Casey Callendrello <cdc@isovalent.com>
  • Loading branch information
squeed committed Apr 5, 2023
1 parent 5a864cb commit 1254bf4
Show file tree
Hide file tree
Showing 17 changed files with 573 additions and 459 deletions.
4 changes: 3 additions & 1 deletion Documentation/cmdref/cilium-agent.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Documentation/cmdref/cilium-agent_hive.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Documentation/cmdref/cilium-agent_hive_dot-graph.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Documentation/installation/cni-chaining-portmap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ Deploy Cilium release via Helm:
You can combine the ``cni.chainingMode=portmap`` option with any of
the other installation guides.

As Cilium is deployed as a DaemonSet, it will write a new CNI configuration
``05-cilium.conflist`` and remove the standard ``05-cilium.conf``. The new
As Cilium is deployed as a DaemonSet, it will write a new CNI configuration. The new
configuration now enables HostPort. Any new pod scheduled is now able to make
use of the HostPort functionality.

Expand Down
3 changes: 3 additions & 0 deletions daemon/cmd/cells.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package cmd

import (
"github.com/cilium/cilium/daemon/cmd/cni"
"github.com/cilium/cilium/pkg/auth"
"github.com/cilium/cilium/pkg/bgpv1"
"github.com/cilium/cilium/pkg/crypto/certificatemanager"
Expand Down Expand Up @@ -51,6 +52,8 @@ var (
// Provides Clientset, API for accessing Kubernetes objects.
k8sClient.Cell,

cni.Cell,

// Provide option.Config via hive so cells can depend on the agent config.
cell.Provide(func() *option.DaemonConfig { return option.Config }),
)
Expand Down

0 comments on commit 1254bf4

Please sign in to comment.