mirror of
https://github.com/k8snetworkplumbingwg/multus-cni.git
synced 2025-08-30 15:01:24 +00:00
Refine multus config file (masterplugin and always_use_default)
This fix removes 'masterplugin' and 'always_use_default' from multus config file. default network, defined in /etc/cni/net.d/*conf should be master and this network should be used as default from network plumbing working group draft.
This commit is contained in:
parent
600ca0824b
commit
215ddb5a1d
21
README.md
21
README.md
@ -54,7 +54,6 @@ Go 1.5 users will need to set `GO15VENDOREXPERIMENT=1` to get vendored dependenc
|
||||
* `type` (string, required): "multus"
|
||||
* `kubeconfig` (string, optional): kubeconfig file for the out of cluster communication with kube-apiserver, Refer the doc
|
||||
* `delegates` (([]map,required): number of delegate details in the Multus, ignored in case kubeconfig is added.
|
||||
* `masterplugin` (bool,required): master plugin to report back the IP address and DNS to the container
|
||||
|
||||
## Usage with Kubernetes CRD/TPR based Network Objects
|
||||
|
||||
@ -303,8 +302,7 @@ sriov-conf Network.v1.kubernetes-network.cni.cncf.io
|
||||
"kubeconfig": "/etc/kubernetes/node-kubeconfig.yaml",
|
||||
"delegates": [{
|
||||
"type": "weave-net",
|
||||
"hairpinMode": true,
|
||||
"masterplugin": true
|
||||
"hairpinMode": true
|
||||
}]
|
||||
}
|
||||
```
|
||||
@ -443,7 +441,6 @@ Given the following network configuration:
|
||||
},
|
||||
{
|
||||
"type": "flannel",
|
||||
"masterplugin": true,
|
||||
"delegate": {
|
||||
"isDefaultGateway": true
|
||||
}
|
||||
@ -454,22 +451,6 @@ 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.
|
||||
|
@ -10,7 +10,7 @@ It is expected that aspects of your own setup will vary, at least in part, from
|
||||
|
||||
More specifically, these examples show:
|
||||
|
||||
* Multus configured, using CNI a `.conf` file, with CRD support, specifying that we will use a "default network" with the `always_use_default` option set.
|
||||
* Multus configured, using CNI a `.conf` file, with CRD support, specifying that we will use a "default network".
|
||||
* A resource definition with a daemonset that places the `.conf` on each node in the cluster.
|
||||
* A CRD definining the "networks" @ `networks.kubernetes.cni.cncf.io`
|
||||
* CRD objects containing the configuration for both Flannel & macvlan.
|
||||
@ -59,4 +59,4 @@ A sample `cni-configuration.conf` is provided, typically this file is placed in
|
||||
|
||||
## Other considerations
|
||||
|
||||
Primarily in this setup one thing that one should consider are the aspects of the `macvlan-conf.yml`, which is likely specific to the configuration of the node on which this resides.
|
||||
Primarily in this setup one thing that one should consider are the aspects of the `macvlan-conf.yml`, which is likely specific to the configuration of the node on which this resides.
|
||||
|
@ -4,12 +4,10 @@
|
||||
"delegates": [
|
||||
{
|
||||
"type": "flannel",
|
||||
"masterplugin": true,
|
||||
"delegate": {
|
||||
"isDefaultGateway": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"always_use_default": true,
|
||||
"kubeconfig": "/etc/kubernetes/kubelet.conf"
|
||||
}
|
||||
|
@ -67,13 +67,11 @@ data:
|
||||
"delegates": [
|
||||
{
|
||||
"type": "flannel",
|
||||
"masterplugin": true,
|
||||
"delegate": {
|
||||
"isDefaultGateway": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"always_use_default": true,
|
||||
"kubeconfig": "/etc/kubernetes/kubelet.conf"
|
||||
}
|
||||
net-conf.json: |
|
||||
|
@ -71,21 +71,17 @@ func loadNetConf(bytes []byte) (*types.NetConf, error) {
|
||||
netconf.ConfDir = defaultConfDir
|
||||
}
|
||||
|
||||
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 netconf.Kubeconfig == "" || !defaultcninetwork {
|
||||
return nil, fmt.Errorf(`You must also set the delegates & the kubeconfig, refer to the README`)
|
||||
}
|
||||
|
||||
if len(netconf.Delegates) == 0 && !defaultcninetwork {
|
||||
return nil, fmt.Errorf(`delegates or kubeconfig option is must, refer README.md`)
|
||||
}
|
||||
|
||||
// default network in multus conf as master plugin
|
||||
netconf.Delegates[0]["masterplugin"] = true
|
||||
|
||||
return netconf, nil
|
||||
}
|
||||
|
||||
@ -304,17 +300,11 @@ 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 {
|
||||
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
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -384,15 +374,11 @@ func cmdDel(args *skel.CmdArgs) error {
|
||||
}
|
||||
|
||||
if len(podDelegate) != 0 {
|
||||
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
|
||||
// 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])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ type NetConf struct {
|
||||
CNIDir string `json:"cniDir"`
|
||||
Delegates []map[string]interface{} `json:"delegates"`
|
||||
Kubeconfig string `json:"kubeconfig"`
|
||||
UseDefault bool `json:"always_use_default"`
|
||||
}
|
||||
|
||||
type Network struct {
|
||||
|
Loading…
Reference in New Issue
Block a user