diff --git a/docs/thick-plugin.md b/docs/thick-plugin.md index 01af594e7..66b095978 100644 --- a/docs/thick-plugin.md +++ b/docs/thick-plugin.md @@ -66,6 +66,7 @@ The server configuration is encoded in JSON, and allows the following keys: - `"socketDir"`: Specify the location where the unix domain socket used for client/server communication will be located. This is the location where the **Daemon** will read the configuration from. Defaults to `"/run/multus"`. +- `multusKeepConfig`: Specify whether to keep the generated multus CNI config or not. Defaults to `false`, which means that the multus config file (e.g. `/etc/cni/net.d/00-multus.conf` will be deleted automatically when the multus-daemon is deleted). - `"metricsPort"`: Metrics port (of multus' metric exporter); by default, no port is provided. - `"logFile"`: the path to where the daemon logs will be persisted. @@ -90,7 +91,8 @@ Below you can see an example of the daemon configuration: "cniVersion": "0.3.1", "cniConfigDir": "/host/etc/cni/net.d", "multusConfigFile": "auto", - "multusAutoconfigDir": "/host/etc/cni/net.d" + "multusAutoconfigDir": "/host/etc/cni/net.d", + "multusKeepConfig": true, } ``` diff --git a/pkg/server/config/generator.go b/pkg/server/config/generator.go index 30473d764..7d18fe551 100644 --- a/pkg/server/config/generator.go +++ b/pkg/server/config/generator.go @@ -60,6 +60,7 @@ type MultusConf struct { MultusConfigFile string `json:"multusConfigFile,omitempty"` MultusMasterCni string `json:"multusMasterCNI,omitempty"` MultusAutoconfigDir string `json:"multusAutoconfigDir,omitempty"` + MultusKeepConfig bool `json:"multusKeepConfig,omitempty"` ForceCNIVersion bool `json:"forceCNIVersion,omitempty"` OverrideNetworkName bool `json:"overrideNetworkName,omitempty"` } diff --git a/pkg/server/config/manager.go b/pkg/server/config/manager.go index 6b450c13a..92667e4f7 100644 --- a/pkg/server/config/manager.go +++ b/pkg/server/config/manager.go @@ -159,8 +159,11 @@ func (m *Manager) Start(ctx context.Context, wg *sync.WaitGroup) error { _ = logging.Errorf("error watching file: %v", err) } logging.Verbosef("ConfigWatcher done") - logging.Verbosef("Delete old config @ %v", multusConfigFile) - os.Remove(multusConfigFile) + + if !m.multusConfig.MultusKeepConfig { + logging.Verbosef("Delete old config @ %v", multusConfigFile) + os.Remove(multusConfigFile) + } }() return nil