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

2.0: Protobuf / gRPC: how to pass network configuration to plugins? #887

Open
squeed opened this issue Mar 22, 2022 · 1 comment
Open

2.0: Protobuf / gRPC: how to pass network configuration to plugins? #887

squeed opened this issue Mar 22, 2022 · 1 comment
Labels

Comments

@squeed
Copy link
Member

squeed commented Mar 22, 2022

Assuming we move forward with daemonization (#821), then we will have to write a protobuf schema for the CNI protocol. This tpresents a few awkward edges around network configuration.

The gist of the issue is this:

  1. A "network" and a "configuration" are the same thing
  2. The same plugin can be used by multiple "networks"
    2.1. The same plugin can be used in different networks in the same container.
  3. A network configuration contains arbitrary, plugin-specific rich data.

So, we need some way to ergonomically pass, to a plugin, a network configuration. This configuration is user-defined but plugin specific.

Options

  1. Embed json in protobuf
  2. The protobuf any type, which supports embedding arbitrary protobuf messages.
  3. ???
@squeed squeed added the CNI 2.0 label Mar 22, 2022
@squeed squeed changed the title 2.0: Protobuf / gRPC: how to pass arbitrary data? 2.0: Protobuf / gRPC: how to pass network configuration to plugins? Mar 23, 2022
@robberphex
Copy link

In CNI 2.0, we provide gRPC/Protobuf definition, so I think use protobuf any type is nature.

Example network configuration could be like:

{
  "cniVersion": "1.0.0",
  "name": "dbnet",
  "plugins": [
    {
      "type": "bridge",
      "bridge": "cni0",
      "extra": [
        {
          // **plugin specific parameters for nerdctl**
          "@type": "type.googleapis.com/helloworld.NerdctlNetworkConfig",
          "NerdctlID": 112233,
          "NerdctlLabels": {
            "bob": "11"
          }
        },
        {
          // **plugin specific parameters for bridge**
          "@type": "type.googleapis.com/k8s.cni.cncf.io/v1.0.0.BridgeNetworkConfig",
          "configKey": "configValue"
        }
      ],
      "ipam": {
        "type": "host-local",
        // ipam specific
        "subnet": "10.1.0.0/16",
        "gateway": "10.1.0.1",
        "routes": [
          {
            "dst": "0.0.0.0/0"
          }
        ]
      },
      "dns": {
        "nameservers": [
          "10.1.0.1"
        ]
      }
    },
    {
      "type": "tuning",
      "capabilities": {
        "mac": true
      },
      "sysctl": {
        "net.core.somaxconn": "500"
      }
    },
    {
      "type": "portmap",
      "capabilities": {
        "portMappings": true
      }
    }
  ]
}

And protobuf any type can be converted to json.

I submitted a pr, #874 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants