Merge pull request #1155 from kuramal/cni_plugin_conf_file_max_num
add cni plugin config file max num config
This commit is contained in:
commit
53c71e2b10
@ -149,6 +149,12 @@ The explanation and default value of each configuration item are as follows:
|
|||||||
# conf_dir is the directory in which the admin places a CNI conf.
|
# conf_dir is the directory in which the admin places a CNI conf.
|
||||||
conf_dir = "/etc/cni/net.d"
|
conf_dir = "/etc/cni/net.d"
|
||||||
|
|
||||||
|
# max_conf_num is the max number of CNI plugin config file will load
|
||||||
|
# By default, the containerd will load only 1 CRI plugin. If you want load multiple CRI plugins,
|
||||||
|
# set max_conf_num > 1. You should know exactly each CRI plugin do, whether they are compatible.
|
||||||
|
# max i<= 0 means no limit.
|
||||||
|
max_conf_num = 1
|
||||||
|
|
||||||
# conf_template is the file path of golang template used to generate
|
# conf_template is the file path of golang template used to generate
|
||||||
# cni config.
|
# cni config.
|
||||||
# If this is set, containerd will generate a cni config file from the
|
# If this is set, containerd will generate a cni config file from the
|
||||||
|
@ -71,6 +71,8 @@ type CniConfig struct {
|
|||||||
NetworkPluginBinDir string `toml:"bin_dir" json:"binDir"`
|
NetworkPluginBinDir string `toml:"bin_dir" json:"binDir"`
|
||||||
// NetworkPluginConfDir is the directory in which the admin places a CNI conf.
|
// NetworkPluginConfDir is the directory in which the admin places a CNI conf.
|
||||||
NetworkPluginConfDir string `toml:"conf_dir" json:"confDir"`
|
NetworkPluginConfDir string `toml:"conf_dir" json:"confDir"`
|
||||||
|
// NetworkPluginMaxConfNum is the max number of plugin config file will load
|
||||||
|
NetworkPluginMaxConfNum int `toml:"max_conf_num" json:"maxConfNum"`
|
||||||
// NetworkPluginConfTemplate is the file path of golang template used to generate
|
// NetworkPluginConfTemplate is the file path of golang template used to generate
|
||||||
// cni config.
|
// cni config.
|
||||||
// When it is set, containerd will get cidr from kubelet to replace {{.PodCIDR}} in
|
// When it is set, containerd will get cidr from kubelet to replace {{.PodCIDR}} in
|
||||||
@ -202,6 +204,7 @@ func DefaultConfig() PluginConfig {
|
|||||||
CniConfig: CniConfig{
|
CniConfig: CniConfig{
|
||||||
NetworkPluginBinDir: "/opt/cni/bin",
|
NetworkPluginBinDir: "/opt/cni/bin",
|
||||||
NetworkPluginConfDir: "/etc/cni/net.d",
|
NetworkPluginConfDir: "/etc/cni/net.d",
|
||||||
|
NetworkPluginMaxConfNum: 1,
|
||||||
NetworkPluginConfTemplate: "",
|
NetworkPluginConfTemplate: "",
|
||||||
},
|
},
|
||||||
ContainerdConfig: ContainerdConfig{
|
ContainerdConfig: ContainerdConfig{
|
||||||
|
@ -148,6 +148,7 @@ func NewCRIService(config criconfig.Config, client *containerd.Client) (CRIServi
|
|||||||
// of the default network interface as the pod IP.
|
// of the default network interface as the pod IP.
|
||||||
c.netPlugin, err = cni.New(cni.WithMinNetworkCount(networkAttachCount),
|
c.netPlugin, err = cni.New(cni.WithMinNetworkCount(networkAttachCount),
|
||||||
cni.WithPluginConfDir(config.NetworkPluginConfDir),
|
cni.WithPluginConfDir(config.NetworkPluginConfDir),
|
||||||
|
cni.WithPluginMaxConfNum(config.NetworkPluginMaxConfNum),
|
||||||
cni.WithPluginDir([]string{config.NetworkPluginBinDir}))
|
cni.WithPluginDir([]string{config.NetworkPluginBinDir}))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "failed to initialize cni")
|
return nil, errors.Wrap(err, "failed to initialize cni")
|
||||||
|
@ -5,7 +5,7 @@ github.com/containerd/console c12b1e7919c14469339a5d38f2f8ed9b64a9de23
|
|||||||
github.com/containerd/containerd 32e788a8be3ab4418265693d9e742c30495fdd4c
|
github.com/containerd/containerd 32e788a8be3ab4418265693d9e742c30495fdd4c
|
||||||
github.com/containerd/continuity bd77b46c8352f74eb12c85bdc01f4b90f69d66b4
|
github.com/containerd/continuity bd77b46c8352f74eb12c85bdc01f4b90f69d66b4
|
||||||
github.com/containerd/fifo 3d5202aec260678c48179c56f40e6f38a095738c
|
github.com/containerd/fifo 3d5202aec260678c48179c56f40e6f38a095738c
|
||||||
github.com/containerd/go-cni e1dc76fa62e1665cf5d85fd617c6191d66f0e72d
|
github.com/containerd/go-cni 22460c018b64cf8bf4151b3ff9c4d077e6a88cbf
|
||||||
github.com/containerd/go-runc 5a6d9f37cfa36b15efba46dc7ea349fa9b7143c3
|
github.com/containerd/go-runc 5a6d9f37cfa36b15efba46dc7ea349fa9b7143c3
|
||||||
github.com/containerd/ttrpc f02858b1457c5ca3aaec3a0803eb0d59f96e41d6
|
github.com/containerd/ttrpc f02858b1457c5ca3aaec3a0803eb0d59f96e41d6
|
||||||
github.com/containerd/typeurl a93fcdb778cd272c6e9b3028b2f42d813e785d40
|
github.com/containerd/typeurl a93fcdb778cd272c6e9b3028b2f42d813e785d40
|
||||||
|
23
vendor/github.com/containerd/go-cni/cni.go
generated
vendored
23
vendor/github.com/containerd/go-cni/cni.go
generated
vendored
@ -41,10 +41,11 @@ type CNI interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ConfigResult struct {
|
type ConfigResult struct {
|
||||||
PluginDirs []string
|
PluginDirs []string
|
||||||
PluginConfDir string
|
PluginConfDir string
|
||||||
Prefix string
|
PluginMaxConfNum int
|
||||||
Networks []*ConfNetwork
|
Prefix string
|
||||||
|
Networks []*ConfNetwork
|
||||||
}
|
}
|
||||||
|
|
||||||
type ConfNetwork struct {
|
type ConfNetwork struct {
|
||||||
@ -78,9 +79,10 @@ type libcni struct {
|
|||||||
func defaultCNIConfig() *libcni {
|
func defaultCNIConfig() *libcni {
|
||||||
return &libcni{
|
return &libcni{
|
||||||
config: config{
|
config: config{
|
||||||
pluginDirs: []string{DefaultCNIDir},
|
pluginDirs: []string{DefaultCNIDir},
|
||||||
pluginConfDir: DefaultNetDir,
|
pluginConfDir: DefaultNetDir,
|
||||||
prefix: DefaultPrefix,
|
pluginMaxConfNum: DefaultMaxConfNum,
|
||||||
|
prefix: DefaultPrefix,
|
||||||
},
|
},
|
||||||
cniConfig: &cnilibrary.CNIConfig{
|
cniConfig: &cnilibrary.CNIConfig{
|
||||||
Path: []string{DefaultCNIDir},
|
Path: []string{DefaultCNIDir},
|
||||||
@ -187,9 +189,10 @@ func (c *libcni) GetConfig() *ConfigResult {
|
|||||||
c.RLock()
|
c.RLock()
|
||||||
defer c.RUnlock()
|
defer c.RUnlock()
|
||||||
r := &ConfigResult{
|
r := &ConfigResult{
|
||||||
PluginDirs: c.config.pluginDirs,
|
PluginDirs: c.config.pluginDirs,
|
||||||
PluginConfDir: c.config.pluginConfDir,
|
PluginConfDir: c.config.pluginConfDir,
|
||||||
Prefix: c.config.prefix,
|
PluginMaxConfNum: c.config.pluginMaxConfNum,
|
||||||
|
Prefix: c.config.prefix,
|
||||||
}
|
}
|
||||||
for _, network := range c.networks {
|
for _, network := range c.networks {
|
||||||
conf := &NetworkConfList{
|
conf := &NetworkConfList{
|
||||||
|
11
vendor/github.com/containerd/go-cni/opts.go
generated
vendored
11
vendor/github.com/containerd/go-cni/opts.go
generated
vendored
@ -54,6 +54,15 @@ func WithPluginConfDir(dir string) CNIOpt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithPluginMaxConfNum can be used to configure the
|
||||||
|
// max cni plugin config file num.
|
||||||
|
func WithPluginMaxConfNum(max int) CNIOpt {
|
||||||
|
return func(c *libcni) error {
|
||||||
|
c.pluginMaxConfNum = max
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// WithMinNetworkCount can be used to configure the
|
// WithMinNetworkCount can be used to configure the
|
||||||
// minimum networks to be configured and initialized
|
// minimum networks to be configured and initialized
|
||||||
// for the status to report success. By default its 1.
|
// for the status to report success. By default its 1.
|
||||||
@ -159,7 +168,7 @@ func WithConfListFile(fileName string) CNIOpt {
|
|||||||
// the convention chosen is - the first network configuration in the sorted
|
// the convention chosen is - the first network configuration in the sorted
|
||||||
// list of network conf files as the default network.
|
// list of network conf files as the default network.
|
||||||
func WithDefaultConf(c *libcni) error {
|
func WithDefaultConf(c *libcni) error {
|
||||||
return loadFromConfDir(c, 1)
|
return loadFromConfDir(c, c.pluginMaxConfNum)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithAllConf can be used to detect all network config
|
// WithAllConf can be used to detect all network config
|
||||||
|
8
vendor/github.com/containerd/go-cni/types.go
generated
vendored
8
vendor/github.com/containerd/go-cni/types.go
generated
vendored
@ -20,14 +20,16 @@ const (
|
|||||||
CNIPluginName = "cni"
|
CNIPluginName = "cni"
|
||||||
DefaultNetDir = "/etc/cni/net.d"
|
DefaultNetDir = "/etc/cni/net.d"
|
||||||
DefaultCNIDir = "/opt/cni/bin"
|
DefaultCNIDir = "/opt/cni/bin"
|
||||||
|
DefaultMaxConfNum = 1
|
||||||
VendorCNIDirTemplate = "%s/opt/%s/bin"
|
VendorCNIDirTemplate = "%s/opt/%s/bin"
|
||||||
DefaultPrefix = "eth"
|
DefaultPrefix = "eth"
|
||||||
)
|
)
|
||||||
|
|
||||||
type config struct {
|
type config struct {
|
||||||
pluginDirs []string
|
pluginDirs []string
|
||||||
pluginConfDir string
|
pluginConfDir string
|
||||||
prefix string
|
pluginMaxConfNum int
|
||||||
|
prefix string
|
||||||
}
|
}
|
||||||
|
|
||||||
type PortMapping struct {
|
type PortMapping struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user