mirror of
https://github.com/k8snetworkplumbingwg/multus-cni.git
synced 2025-09-19 08:25:18 +00:00
Merge pull request #11 from redhat-nfvpe/dev/default_network
[npwg] Prototype for default network
This commit is contained in:
17
README.md
17
README.md
@@ -451,6 +451,23 @@ Given the following network configuration:
|
||||
EOF
|
||||
|
||||
```
|
||||
|
||||
### Further options for CNI configuration file.
|
||||
|
||||
One may also specify `always_use_default` as a boolean value. This option requires that you're using the CRD method (and therefore requires that you must also specify both the `kubeconfig` and the `delegates` option as well, or Multus will present an error message). In the case that `always_use_default` is true, the `delegates` network will always be applied, along with those specified in the annotations.
|
||||
|
||||
For example, a valid configuration using the `always_use_default` may look like:
|
||||
|
||||
```
|
||||
{
|
||||
"name": "multus-cni-network",
|
||||
"type": "multus",
|
||||
"delegates": [{"type": "flannel", "isDefaultGateway": true, "masterplugin": true}],
|
||||
"always_use_default": true,
|
||||
"kubeconfig": "/etc/kubernetes/kubelet.conf"
|
||||
}
|
||||
```
|
||||
|
||||
## Testing the Multus CNI ##
|
||||
### Multiple Flannel Network
|
||||
Github user [YYGCui](https://github.com/YYGCui) has used Multiple flannel network to work with Multus CNI plugin. Please refer this [closed issue](https://github.com/Intel-Corp/multus-cni/issues/7) for Multiple overlay network support with Multus CNI.
|
||||
|
@@ -49,6 +49,7 @@ type NetConf struct {
|
||||
CNIDir string `json:"cniDir"`
|
||||
Delegates []map[string]interface{} `json:"delegates"`
|
||||
Kubeconfig string `json:"kubeconfig"`
|
||||
UseDefault bool `json:"always_use_default"`
|
||||
}
|
||||
|
||||
type netplugin struct {
|
||||
@@ -88,10 +89,17 @@ func loadNetConf(bytes []byte) (*NetConf, error) {
|
||||
defaultcninetwork = true
|
||||
}
|
||||
|
||||
if netconf.Kubeconfig != "" && !defaultcninetwork {
|
||||
if netconf.UseDefault {
|
||||
if netconf.Kubeconfig == "" || !defaultcninetwork {
|
||||
return nil, fmt.Errorf(`If you have set always_use_default, you must also set the delegates & the kubeconfig, refer to the README`)
|
||||
}
|
||||
return netconf, nil
|
||||
}
|
||||
|
||||
if !netconf.UseDefault && (netconf.Kubeconfig != "" && !defaultcninetwork) {
|
||||
return netconf, nil
|
||||
}
|
||||
|
||||
if len(netconf.Delegates) == 0 && !defaultcninetwork {
|
||||
return nil, fmt.Errorf(`delegates or kubeconfig option is must, refer README.md`)
|
||||
}
|
||||
@@ -541,8 +549,20 @@ func cmdAdd(args *skel.CmdArgs) error {
|
||||
}
|
||||
}
|
||||
|
||||
// If it's empty just leave it as the netconfig states (e.g. just default)
|
||||
if len(podDelegate) != 0 {
|
||||
n.Delegates = podDelegate
|
||||
if n.UseDefault {
|
||||
// In the case that we force the default
|
||||
// We add the found configs from CRD
|
||||
for _, eachDelegate := range podDelegate {
|
||||
eachDelegate["masterplugin"] = false
|
||||
n.Delegates = append(n.Delegates,eachDelegate)
|
||||
}
|
||||
|
||||
} else {
|
||||
// Otherwise, only the CRD delegates are used.
|
||||
n.Delegates = podDelegate
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -609,7 +629,16 @@ func cmdDel(args *skel.CmdArgs) error {
|
||||
}
|
||||
|
||||
if len(podDelegate) != 0 {
|
||||
in.Delegates = podDelegate
|
||||
if in.UseDefault {
|
||||
// In the case that we force the default
|
||||
// We add the found configs from CRD (in reverse order)
|
||||
for i := len(podDelegate)-1; i >= 0; i-- {
|
||||
podDelegate[i]["masterplugin"] = false
|
||||
in.Delegates = append(in.Delegates,podDelegate[i])
|
||||
}
|
||||
} else {
|
||||
in.Delegates = podDelegate
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user