2018-05-01 13:08:39 -05:00
|
|
|
// Copyright (c) 2017 Intel Corporation
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
//
|
|
|
|
|
|
|
|
package types
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
2020-06-09 12:43:49 +09:00
|
|
|
"fmt"
|
thick-plugin: refactor multus
Multus is refactored as a thick plugin, featuring 2 main components:
- a server listening to a unix domain socket, running in a pod
- a shim, a binary on the host that will send JSON requests built from
its environment / stdin values to the aforementioned server.
The pod where the multus daemon is running must share the host's PID
namespace.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
react to maintainers review
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, deployment: update the daemonset spec
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, config: validate the cni config passed by the runtime
Without this patch, we're blindly trusting anything sent by the server.
This way, we assure the requests arriving at the multus controller are
valid before hand.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick: model client / server config
Also add a new command line parameter on the multus controller, pointing
it to the server configuration.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
SQUASH candidate, thick, config: cleanup the configuration
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
multus: use args.args instead of an env variable
CNI is already filling the args structure; we should consume that
rather than rely on the environment variables.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
unit tests: remove weird tests that check an impossible scenario
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
docs, thick: document the thick plugin variant
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, server, multus: re-use common types
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
2021-12-16 18:18:35 +01:00
|
|
|
"io/ioutil"
|
2019-08-27 16:52:58 +09:00
|
|
|
"net"
|
2022-02-21 23:55:33 +09:00
|
|
|
"os"
|
2020-10-29 13:10:12 -04:00
|
|
|
"strings"
|
2018-06-13 15:14:02 -05:00
|
|
|
|
2018-07-27 00:04:52 +01:00
|
|
|
"github.com/containernetworking/cni/libcni"
|
|
|
|
"github.com/containernetworking/cni/pkg/skel"
|
2022-03-02 01:55:23 +09:00
|
|
|
cni100 "github.com/containernetworking/cni/pkg/types/100"
|
2018-06-13 15:14:02 -05:00
|
|
|
"github.com/containernetworking/cni/pkg/version"
|
2020-11-03 09:42:30 -05:00
|
|
|
nadutils "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/utils"
|
2021-03-16 16:08:53 +09:00
|
|
|
"gopkg.in/k8snetworkplumbingwg/multus-cni.v3/pkg/logging"
|
2018-05-01 13:08:39 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2018-12-06 13:42:17 +09:00
|
|
|
defaultCNIDir = "/var/lib/cni/multus"
|
|
|
|
defaultConfDir = "/etc/cni/multus/net.d"
|
|
|
|
defaultBinDir = "/opt/cni/bin"
|
2018-10-10 14:09:38 -04:00
|
|
|
defaultReadinessIndicatorFile = ""
|
2019-03-26 00:34:35 +00:00
|
|
|
defaultMultusNamespace = "kube-system"
|
2020-10-29 13:10:12 -04:00
|
|
|
defaultNonIsolatedNamespace = "default"
|
2018-05-01 13:08:39 -05:00
|
|
|
)
|
|
|
|
|
thick-plugin: refactor multus
Multus is refactored as a thick plugin, featuring 2 main components:
- a server listening to a unix domain socket, running in a pod
- a shim, a binary on the host that will send JSON requests built from
its environment / stdin values to the aforementioned server.
The pod where the multus daemon is running must share the host's PID
namespace.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
react to maintainers review
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, deployment: update the daemonset spec
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, config: validate the cni config passed by the runtime
Without this patch, we're blindly trusting anything sent by the server.
This way, we assure the requests arriving at the multus controller are
valid before hand.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick: model client / server config
Also add a new command line parameter on the multus controller, pointing
it to the server configuration.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
SQUASH candidate, thick, config: cleanup the configuration
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
multus: use args.args instead of an env variable
CNI is already filling the args structure; we should consume that
rather than rely on the environment variables.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
unit tests: remove weird tests that check an impossible scenario
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
docs, thick: document the thick plugin variant
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, server, multus: re-use common types
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
2021-12-16 18:18:35 +01:00
|
|
|
// const block for multus-daemon configs
|
|
|
|
const (
|
|
|
|
// DefaultMultusDaemonConfigFile is the default path of the config file
|
|
|
|
DefaultMultusDaemonConfigFile = "/etc/cni/net.d/multus.d/daemon-config.json"
|
2022-04-08 23:08:07 +09:00
|
|
|
defaultMultusRunDir = "/run/multus/"
|
thick-plugin: refactor multus
Multus is refactored as a thick plugin, featuring 2 main components:
- a server listening to a unix domain socket, running in a pod
- a shim, a binary on the host that will send JSON requests built from
its environment / stdin values to the aforementioned server.
The pod where the multus daemon is running must share the host's PID
namespace.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
react to maintainers review
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, deployment: update the daemonset spec
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, config: validate the cni config passed by the runtime
Without this patch, we're blindly trusting anything sent by the server.
This way, we assure the requests arriving at the multus controller are
valid before hand.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick: model client / server config
Also add a new command line parameter on the multus controller, pointing
it to the server configuration.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
SQUASH candidate, thick, config: cleanup the configuration
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
multus: use args.args instead of an env variable
CNI is already filling the args structure; we should consume that
rather than rely on the environment variables.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
unit tests: remove weird tests that check an impossible scenario
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
docs, thick: document the thick plugin variant
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, server, multus: re-use common types
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
2021-12-16 18:18:35 +01:00
|
|
|
)
|
|
|
|
|
2019-06-24 16:57:03 +09:00
|
|
|
// LoadDelegateNetConfList reads DelegateNetConf from bytes
|
2018-07-27 00:04:52 +01:00
|
|
|
func LoadDelegateNetConfList(bytes []byte, delegateConf *DelegateNetConf) error {
|
2018-08-06 16:54:32 +09:00
|
|
|
logging.Debugf("LoadDelegateNetConfList: %s, %v", string(bytes), delegateConf)
|
2019-06-24 16:57:03 +09:00
|
|
|
|
2018-07-27 00:04:52 +01:00
|
|
|
if err := json.Unmarshal(bytes, &delegateConf.ConfList); err != nil {
|
2019-10-02 18:02:26 +09:00
|
|
|
return logging.Errorf("LoadDelegateNetConfList: error unmarshalling delegate conflist: %v", err)
|
2018-07-27 00:04:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if delegateConf.ConfList.Plugins == nil {
|
2019-10-02 18:02:26 +09:00
|
|
|
return logging.Errorf("LoadDelegateNetConfList: delegate must have the 'type' or 'plugin' field")
|
2018-07-27 00:04:52 +01:00
|
|
|
}
|
2019-07-11 15:03:53 -04:00
|
|
|
|
2018-07-27 00:04:52 +01:00
|
|
|
if delegateConf.ConfList.Plugins[0].Type == "" {
|
2019-10-02 18:02:26 +09:00
|
|
|
return logging.Errorf("LoadDelegateNetConfList: a plugin delegate must have the 'type' field")
|
2018-07-27 00:04:52 +01:00
|
|
|
}
|
|
|
|
delegateConf.ConfListPlugin = true
|
2021-04-19 23:20:07 +09:00
|
|
|
delegateConf.Name = delegateConf.ConfList.Name
|
2018-07-27 00:04:52 +01:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-06-24 16:57:03 +09:00
|
|
|
// LoadDelegateNetConf converts raw CNI JSON into a DelegateNetConf structure
|
2022-01-07 22:47:23 +09:00
|
|
|
func LoadDelegateNetConf(bytes []byte, netElement *NetworkSelectionElement, deviceID string, resourceName string) (*DelegateNetConf, error) {
|
2018-10-26 14:47:59 +09:00
|
|
|
var err error
|
2022-01-07 22:47:23 +09:00
|
|
|
logging.Debugf("LoadDelegateNetConf: %s, %v, %s", string(bytes), netElement, deviceID)
|
2018-08-28 19:21:50 +09:00
|
|
|
|
2018-10-26 14:47:59 +09:00
|
|
|
delegateConf := &DelegateNetConf{}
|
2018-07-30 11:59:13 +01:00
|
|
|
if err := json.Unmarshal(bytes, &delegateConf.Conf); err != nil {
|
2019-10-02 18:02:26 +09:00
|
|
|
return nil, logging.Errorf("LoadDelegateNetConf: error unmarshalling delegate config: %v", err)
|
2018-07-30 11:59:13 +01:00
|
|
|
}
|
2021-04-19 23:20:07 +09:00
|
|
|
delegateConf.Name = delegateConf.Conf.Name
|
2018-07-30 11:59:13 +01:00
|
|
|
|
|
|
|
// Do some minimal validation
|
|
|
|
if delegateConf.Conf.Type == "" {
|
|
|
|
if err := LoadDelegateNetConfList(bytes, delegateConf); err != nil {
|
2019-10-02 18:02:26 +09:00
|
|
|
return nil, logging.Errorf("LoadDelegateNetConf: failed with: %v", err)
|
2018-07-30 11:59:13 +01:00
|
|
|
}
|
2019-03-26 00:34:35 +00:00
|
|
|
if deviceID != "" {
|
|
|
|
bytes, err = addDeviceIDInConfList(bytes, deviceID)
|
|
|
|
if err != nil {
|
2019-10-02 18:02:26 +09:00
|
|
|
return nil, logging.Errorf("LoadDelegateNetConf: failed to add deviceID in NetConfList bytes: %v", err)
|
2019-03-26 00:34:35 +00:00
|
|
|
}
|
2022-06-21 14:47:04 +02:00
|
|
|
delegateConf.ResourceName = resourceName
|
|
|
|
delegateConf.DeviceID = deviceID
|
2019-03-26 00:34:35 +00:00
|
|
|
}
|
2022-01-07 22:47:23 +09:00
|
|
|
if netElement != nil && netElement.CNIArgs != nil {
|
|
|
|
bytes, err = addCNIArgsInConfList(bytes, netElement.CNIArgs)
|
2019-08-19 17:17:51 +09:00
|
|
|
if err != nil {
|
|
|
|
return nil, logging.Errorf("LoadDelegateNetConf(): failed to add cni-args in NetConfList bytes: %v", err)
|
|
|
|
}
|
|
|
|
}
|
2019-03-26 00:34:35 +00:00
|
|
|
} else {
|
|
|
|
if deviceID != "" {
|
|
|
|
bytes, err = delegateAddDeviceID(bytes, deviceID)
|
|
|
|
if err != nil {
|
2019-10-02 18:02:26 +09:00
|
|
|
return nil, logging.Errorf("LoadDelegateNetConf: failed to add deviceID in NetConf bytes: %v", err)
|
2019-03-26 00:34:35 +00:00
|
|
|
}
|
2020-11-03 09:42:30 -05:00
|
|
|
// Save them for housekeeping
|
|
|
|
delegateConf.ResourceName = resourceName
|
|
|
|
delegateConf.DeviceID = deviceID
|
2019-03-26 00:34:35 +00:00
|
|
|
}
|
2022-01-07 22:47:23 +09:00
|
|
|
if netElement != nil && netElement.CNIArgs != nil {
|
|
|
|
bytes, err = addCNIArgsInConfig(bytes, netElement.CNIArgs)
|
2019-08-19 17:17:51 +09:00
|
|
|
if err != nil {
|
|
|
|
return nil, logging.Errorf("LoadDelegateNetConf(): failed to add cni-args in NetConfList bytes: %v", err)
|
|
|
|
}
|
|
|
|
}
|
2018-07-30 11:59:13 +01:00
|
|
|
}
|
|
|
|
|
2022-01-07 22:47:23 +09:00
|
|
|
if netElement != nil {
|
|
|
|
if netElement.Name != "" {
|
2020-06-09 12:43:49 +09:00
|
|
|
// Overwrite CNI config name with net-attach-def name
|
2022-01-07 22:47:23 +09:00
|
|
|
delegateConf.Name = fmt.Sprintf("%s/%s", netElement.Namespace, netElement.Name)
|
2020-03-04 16:42:29 +09:00
|
|
|
}
|
2022-01-07 22:47:23 +09:00
|
|
|
if netElement.InterfaceRequest != "" {
|
|
|
|
delegateConf.IfnameRequest = netElement.InterfaceRequest
|
2018-08-28 19:21:50 +09:00
|
|
|
}
|
2022-01-07 22:47:23 +09:00
|
|
|
if netElement.MacRequest != "" {
|
|
|
|
delegateConf.MacRequest = netElement.MacRequest
|
2018-08-28 19:21:50 +09:00
|
|
|
}
|
2022-01-07 22:47:23 +09:00
|
|
|
if netElement.IPRequest != nil {
|
|
|
|
delegateConf.IPRequest = netElement.IPRequest
|
2018-11-28 13:27:49 +02:00
|
|
|
}
|
2022-01-07 22:47:23 +09:00
|
|
|
if netElement.BandwidthRequest != nil {
|
|
|
|
delegateConf.BandwidthRequest = netElement.BandwidthRequest
|
2019-08-16 18:55:12 +09:00
|
|
|
}
|
2022-01-07 22:47:23 +09:00
|
|
|
if netElement.PortMappingsRequest != nil {
|
|
|
|
delegateConf.PortMappingsRequest = netElement.PortMappingsRequest
|
2019-08-16 18:55:12 +09:00
|
|
|
}
|
2022-01-07 22:47:23 +09:00
|
|
|
if netElement.GatewayRequest != nil {
|
|
|
|
var list []net.IP
|
|
|
|
if delegateConf.GatewayRequest != nil {
|
|
|
|
list = append(*delegateConf.GatewayRequest, *netElement.GatewayRequest...)
|
|
|
|
} else {
|
|
|
|
list = *netElement.GatewayRequest
|
|
|
|
}
|
|
|
|
delegateConf.GatewayRequest = &list
|
2019-08-27 16:52:58 +09:00
|
|
|
}
|
2022-01-07 22:47:23 +09:00
|
|
|
if netElement.InfinibandGUIDRequest != "" {
|
|
|
|
delegateConf.InfinibandGUIDRequest = netElement.InfinibandGUIDRequest
|
2020-04-27 10:23:26 +03:00
|
|
|
}
|
2022-01-07 22:47:23 +09:00
|
|
|
if netElement.DeviceID != "" {
|
2020-10-28 08:51:01 -04:00
|
|
|
if deviceID != "" {
|
|
|
|
logging.Debugf("Warning: Both RuntimeConfig and ResourceMap provide deviceID. Ignoring RuntimeConfig")
|
|
|
|
} else {
|
2022-01-07 22:47:23 +09:00
|
|
|
delegateConf.DeviceID = netElement.DeviceID
|
2020-10-28 08:51:01 -04:00
|
|
|
}
|
|
|
|
}
|
2018-07-30 11:59:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
delegateConf.Bytes = bytes
|
|
|
|
|
|
|
|
return delegateConf, nil
|
|
|
|
}
|
|
|
|
|
2020-10-27 17:21:28 -04:00
|
|
|
// mergeCNIRuntimeConfig creates CNI runtimeconfig from delegate
|
|
|
|
func mergeCNIRuntimeConfig(runtimeConfig *RuntimeConfig, delegate *DelegateNetConf) *RuntimeConfig {
|
|
|
|
logging.Debugf("mergeCNIRuntimeConfig: %v %v", runtimeConfig, delegate)
|
2021-02-09 10:03:17 +01:00
|
|
|
var mergedRuntimeConfig RuntimeConfig
|
|
|
|
|
2019-08-16 18:55:12 +09:00
|
|
|
if runtimeConfig == nil {
|
2021-02-09 10:03:17 +01:00
|
|
|
mergedRuntimeConfig = RuntimeConfig{}
|
|
|
|
} else {
|
|
|
|
mergedRuntimeConfig = *runtimeConfig
|
2019-08-16 18:55:12 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
// multus inject RuntimeConfig only in case of non MasterPlugin.
|
|
|
|
if delegate.MasterPlugin != true {
|
2021-02-09 10:03:17 +01:00
|
|
|
logging.Debugf("mergeCNIRuntimeConfig: add runtimeConfig for net-attach-def: %v", mergedRuntimeConfig)
|
2019-08-16 18:55:12 +09:00
|
|
|
if delegate.PortMappingsRequest != nil {
|
2021-02-09 10:03:17 +01:00
|
|
|
mergedRuntimeConfig.PortMaps = delegate.PortMappingsRequest
|
2019-08-16 18:55:12 +09:00
|
|
|
}
|
|
|
|
if delegate.BandwidthRequest != nil {
|
2021-02-09 10:03:17 +01:00
|
|
|
mergedRuntimeConfig.Bandwidth = delegate.BandwidthRequest
|
2019-08-16 18:55:12 +09:00
|
|
|
}
|
|
|
|
if delegate.IPRequest != nil {
|
2021-02-09 10:03:17 +01:00
|
|
|
mergedRuntimeConfig.IPs = delegate.IPRequest
|
2019-08-16 18:55:12 +09:00
|
|
|
}
|
|
|
|
if delegate.MacRequest != "" {
|
2021-02-09 10:03:17 +01:00
|
|
|
mergedRuntimeConfig.Mac = delegate.MacRequest
|
2019-08-16 18:55:12 +09:00
|
|
|
}
|
2020-04-27 10:23:26 +03:00
|
|
|
if delegate.InfinibandGUIDRequest != "" {
|
2021-02-09 10:03:17 +01:00
|
|
|
mergedRuntimeConfig.InfinibandGUID = delegate.InfinibandGUIDRequest
|
2020-04-27 10:23:26 +03:00
|
|
|
}
|
2020-10-28 08:51:01 -04:00
|
|
|
if delegate.DeviceID != "" {
|
2021-02-09 10:03:17 +01:00
|
|
|
mergedRuntimeConfig.DeviceID = delegate.DeviceID
|
2020-10-28 08:51:01 -04:00
|
|
|
}
|
2021-02-09 10:03:17 +01:00
|
|
|
logging.Debugf("mergeCNIRuntimeConfig: add runtimeConfig for net-attach-def: %v", mergedRuntimeConfig)
|
2019-08-16 18:55:12 +09:00
|
|
|
}
|
2021-02-09 10:03:17 +01:00
|
|
|
return &mergedRuntimeConfig
|
2019-08-16 18:55:12 +09:00
|
|
|
}
|
|
|
|
|
2020-10-27 17:21:28 -04:00
|
|
|
// CreateCNIRuntimeConf create CNI RuntimeConf for a delegate. If delegate configuration
|
|
|
|
// exists, merge data with the runtime config.
|
2020-11-03 09:42:30 -05:00
|
|
|
func CreateCNIRuntimeConf(args *skel.CmdArgs, k8sArgs *K8sArgs, ifName string, rc *RuntimeConfig, delegate *DelegateNetConf) (*libcni.RuntimeConf, string) {
|
thick-plugin: refactor multus
Multus is refactored as a thick plugin, featuring 2 main components:
- a server listening to a unix domain socket, running in a pod
- a shim, a binary on the host that will send JSON requests built from
its environment / stdin values to the aforementioned server.
The pod where the multus daemon is running must share the host's PID
namespace.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
react to maintainers review
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, deployment: update the daemonset spec
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, config: validate the cni config passed by the runtime
Without this patch, we're blindly trusting anything sent by the server.
This way, we assure the requests arriving at the multus controller are
valid before hand.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick: model client / server config
Also add a new command line parameter on the multus controller, pointing
it to the server configuration.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
SQUASH candidate, thick, config: cleanup the configuration
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
multus: use args.args instead of an env variable
CNI is already filling the args structure; we should consume that
rather than rely on the environment variables.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
unit tests: remove weird tests that check an impossible scenario
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
docs, thick: document the thick plugin variant
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, server, multus: re-use common types
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
2021-12-16 18:18:35 +01:00
|
|
|
podName := string(k8sArgs.K8S_POD_NAME)
|
|
|
|
podNamespace := string(k8sArgs.K8S_POD_NAMESPACE)
|
|
|
|
podUID := string(k8sArgs.K8S_POD_UID)
|
|
|
|
sandboxID := string(k8sArgs.K8S_POD_INFRA_CONTAINER_ID)
|
2022-08-10 00:45:23 +09:00
|
|
|
return newCNIRuntimeConf(args.ContainerID, sandboxID, podName, podNamespace, podUID, args.Netns, ifName, rc, delegate)
|
thick-plugin: refactor multus
Multus is refactored as a thick plugin, featuring 2 main components:
- a server listening to a unix domain socket, running in a pod
- a shim, a binary on the host that will send JSON requests built from
its environment / stdin values to the aforementioned server.
The pod where the multus daemon is running must share the host's PID
namespace.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
react to maintainers review
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, deployment: update the daemonset spec
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, config: validate the cni config passed by the runtime
Without this patch, we're blindly trusting anything sent by the server.
This way, we assure the requests arriving at the multus controller are
valid before hand.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick: model client / server config
Also add a new command line parameter on the multus controller, pointing
it to the server configuration.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
SQUASH candidate, thick, config: cleanup the configuration
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
multus: use args.args instead of an env variable
CNI is already filling the args structure; we should consume that
rather than rely on the environment variables.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
unit tests: remove weird tests that check an impossible scenario
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
docs, thick: document the thick plugin variant
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, server, multus: re-use common types
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
2021-12-16 18:18:35 +01:00
|
|
|
}
|
2020-10-27 17:21:28 -04:00
|
|
|
|
2022-08-10 00:45:23 +09:00
|
|
|
// newCNIRuntimeConf creates the CNI `RuntimeConf` for the given ADD / DEL request.
|
|
|
|
func newCNIRuntimeConf(containerID, sandboxID, podName, podNamespace, podUID, netNs, ifName string, rc *RuntimeConfig, delegate *DelegateNetConf) (*libcni.RuntimeConf, string) {
|
thick-plugin: refactor multus
Multus is refactored as a thick plugin, featuring 2 main components:
- a server listening to a unix domain socket, running in a pod
- a shim, a binary on the host that will send JSON requests built from
its environment / stdin values to the aforementioned server.
The pod where the multus daemon is running must share the host's PID
namespace.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
react to maintainers review
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, deployment: update the daemonset spec
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, config: validate the cni config passed by the runtime
Without this patch, we're blindly trusting anything sent by the server.
This way, we assure the requests arriving at the multus controller are
valid before hand.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick: model client / server config
Also add a new command line parameter on the multus controller, pointing
it to the server configuration.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
SQUASH candidate, thick, config: cleanup the configuration
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
multus: use args.args instead of an env variable
CNI is already filling the args structure; we should consume that
rather than rely on the environment variables.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
unit tests: remove weird tests that check an impossible scenario
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
docs, thick: document the thick plugin variant
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, server, multus: re-use common types
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
2021-12-16 18:18:35 +01:00
|
|
|
logging.Debugf("LoadCNIRuntimeConf: %s, %v %v", ifName, rc, delegate)
|
2019-06-24 16:57:03 +09:00
|
|
|
|
2022-08-10 00:45:23 +09:00
|
|
|
delegateRc := delegateRuntimeConfig(containerID, delegate, rc, ifName)
|
2018-07-27 00:04:52 +01:00
|
|
|
// In part, adapted from K8s pkg/kubelet/dockershim/network/cni/cni.go#buildCNIRuntimeConf
|
2022-08-10 00:45:23 +09:00
|
|
|
rt := createRuntimeConf(netNs, podNamespace, podName, containerID, sandboxID, podUID, ifName)
|
2018-09-26 09:52:37 +02:00
|
|
|
|
thick-plugin: refactor multus
Multus is refactored as a thick plugin, featuring 2 main components:
- a server listening to a unix domain socket, running in a pod
- a shim, a binary on the host that will send JSON requests built from
its environment / stdin values to the aforementioned server.
The pod where the multus daemon is running must share the host's PID
namespace.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
react to maintainers review
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, deployment: update the daemonset spec
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, config: validate the cni config passed by the runtime
Without this patch, we're blindly trusting anything sent by the server.
This way, we assure the requests arriving at the multus controller are
valid before hand.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick: model client / server config
Also add a new command line parameter on the multus controller, pointing
it to the server configuration.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
SQUASH candidate, thick, config: cleanup the configuration
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
multus: use args.args instead of an env variable
CNI is already filling the args structure; we should consume that
rather than rely on the environment variables.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
unit tests: remove weird tests that check an impossible scenario
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
docs, thick: document the thick plugin variant
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, server, multus: re-use common types
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
2021-12-16 18:18:35 +01:00
|
|
|
var cniDeviceInfoFile string
|
2022-02-21 23:55:33 +09:00
|
|
|
|
2022-04-25 10:13:09 -05:00
|
|
|
// Populate rt.Args with CNI_ARGS if the rt.Args value is not set
|
2022-02-21 23:55:33 +09:00
|
|
|
cniArgs := os.Getenv("CNI_ARGS")
|
|
|
|
if cniArgs != "" {
|
2022-03-23 02:36:34 +09:00
|
|
|
logging.Debugf("ARGS: %s", cniArgs)
|
2022-02-21 23:55:33 +09:00
|
|
|
for _, arg := range strings.Split(cniArgs, ";") {
|
2022-04-25 10:13:09 -05:00
|
|
|
// SplitN to handle = within values, like BLAH=foo=bar
|
|
|
|
keyval := strings.SplitN(arg, "=", 2)
|
2022-03-23 02:36:34 +09:00
|
|
|
if len(keyval) != 2 {
|
2022-04-25 10:13:09 -05:00
|
|
|
logging.Errorf("CreateCNIRuntimeConf: CNI_ARGS %s %s %d is not recognized as CNI arg, skipped", arg, keyval, len(keyval))
|
2022-03-23 02:36:34 +09:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
envKey := string(keyval[0])
|
|
|
|
envVal := string(keyval[1])
|
2022-04-25 10:13:09 -05:00
|
|
|
found := false
|
|
|
|
for i := range rt.Args {
|
|
|
|
// Update existing key if its value is empty
|
|
|
|
if rt.Args[i][0] == envKey && rt.Args[i][1] == "" && envVal != "" {
|
2022-02-21 23:55:33 +09:00
|
|
|
logging.Debugf("CreateCNIRuntimeConf: add new val: %s", arg)
|
2022-04-25 10:13:09 -05:00
|
|
|
rt.Args[i][1] = envVal
|
|
|
|
found = true
|
|
|
|
break
|
2022-02-21 23:55:33 +09:00
|
|
|
}
|
|
|
|
}
|
2022-04-25 10:13:09 -05:00
|
|
|
if !found {
|
|
|
|
// Add the new key if it didn't exist yet
|
2022-03-23 02:36:34 +09:00
|
|
|
rt.Args = append(rt.Args, [2]string{envKey, envVal})
|
|
|
|
}
|
2022-02-21 23:55:33 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-27 17:21:28 -04:00
|
|
|
if delegateRc != nil {
|
thick-plugin: refactor multus
Multus is refactored as a thick plugin, featuring 2 main components:
- a server listening to a unix domain socket, running in a pod
- a shim, a binary on the host that will send JSON requests built from
its environment / stdin values to the aforementioned server.
The pod where the multus daemon is running must share the host's PID
namespace.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
react to maintainers review
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, deployment: update the daemonset spec
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, config: validate the cni config passed by the runtime
Without this patch, we're blindly trusting anything sent by the server.
This way, we assure the requests arriving at the multus controller are
valid before hand.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick: model client / server config
Also add a new command line parameter on the multus controller, pointing
it to the server configuration.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
SQUASH candidate, thick, config: cleanup the configuration
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
multus: use args.args instead of an env variable
CNI is already filling the args structure; we should consume that
rather than rely on the environment variables.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
unit tests: remove weird tests that check an impossible scenario
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
docs, thick: document the thick plugin variant
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, server, multus: re-use common types
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
2021-12-16 18:18:35 +01:00
|
|
|
cniDeviceInfoFile = delegateRc.CNIDeviceInfoFile
|
2019-08-16 18:55:12 +09:00
|
|
|
capabilityArgs := map[string]interface{}{}
|
2020-10-27 17:21:28 -04:00
|
|
|
if len(delegateRc.PortMaps) != 0 {
|
|
|
|
capabilityArgs["portMappings"] = delegateRc.PortMaps
|
2019-08-16 18:55:12 +09:00
|
|
|
}
|
2020-10-27 17:21:28 -04:00
|
|
|
if delegateRc.Bandwidth != nil {
|
|
|
|
capabilityArgs["bandwidth"] = delegateRc.Bandwidth
|
2019-08-16 18:55:12 +09:00
|
|
|
}
|
2020-10-27 17:21:28 -04:00
|
|
|
if len(delegateRc.IPs) != 0 {
|
|
|
|
capabilityArgs["ips"] = delegateRc.IPs
|
2019-08-16 18:55:12 +09:00
|
|
|
}
|
2020-10-27 17:21:28 -04:00
|
|
|
if len(delegateRc.Mac) != 0 {
|
|
|
|
capabilityArgs["mac"] = delegateRc.Mac
|
2018-09-26 09:52:37 +02:00
|
|
|
}
|
2020-10-27 17:21:28 -04:00
|
|
|
if len(delegateRc.InfinibandGUID) != 0 {
|
|
|
|
capabilityArgs["infinibandGUID"] = delegateRc.InfinibandGUID
|
2020-04-27 10:23:26 +03:00
|
|
|
}
|
2020-10-28 08:51:01 -04:00
|
|
|
if delegateRc.DeviceID != "" {
|
|
|
|
capabilityArgs["deviceID"] = delegateRc.DeviceID
|
|
|
|
}
|
2020-11-03 09:42:30 -05:00
|
|
|
if delegateRc.CNIDeviceInfoFile != "" {
|
|
|
|
capabilityArgs["CNIDeviceInfoFile"] = delegateRc.CNIDeviceInfoFile
|
|
|
|
}
|
2019-08-16 18:55:12 +09:00
|
|
|
rt.CapabilityArgs = capabilityArgs
|
2018-09-26 09:52:37 +02:00
|
|
|
}
|
2020-11-03 09:42:30 -05:00
|
|
|
return rt, cniDeviceInfoFile
|
2018-07-27 00:04:52 +01:00
|
|
|
}
|
|
|
|
|
2022-08-10 00:45:23 +09:00
|
|
|
// createRuntimeConf creates the CNI `RuntimeConf` for the given ADD / DEL request.
|
|
|
|
func createRuntimeConf(netNs, podNamespace, podName, containerID, sandboxID, podUID, ifName string) *libcni.RuntimeConf {
|
thick-plugin: refactor multus
Multus is refactored as a thick plugin, featuring 2 main components:
- a server listening to a unix domain socket, running in a pod
- a shim, a binary on the host that will send JSON requests built from
its environment / stdin values to the aforementioned server.
The pod where the multus daemon is running must share the host's PID
namespace.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
react to maintainers review
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, deployment: update the daemonset spec
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, config: validate the cni config passed by the runtime
Without this patch, we're blindly trusting anything sent by the server.
This way, we assure the requests arriving at the multus controller are
valid before hand.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick: model client / server config
Also add a new command line parameter on the multus controller, pointing
it to the server configuration.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
SQUASH candidate, thick, config: cleanup the configuration
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
multus: use args.args instead of an env variable
CNI is already filling the args structure; we should consume that
rather than rely on the environment variables.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
unit tests: remove weird tests that check an impossible scenario
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
docs, thick: document the thick plugin variant
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, server, multus: re-use common types
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
2021-12-16 18:18:35 +01:00
|
|
|
return &libcni.RuntimeConf{
|
|
|
|
ContainerID: containerID,
|
|
|
|
NetNS: netNs,
|
|
|
|
IfName: ifName,
|
|
|
|
// NOTE: Verbose logging depends on this order, so please keep Args order.
|
|
|
|
Args: [][2]string{
|
|
|
|
{"IgnoreUnknown", "true"},
|
|
|
|
{"K8S_POD_NAMESPACE", podNamespace},
|
|
|
|
{"K8S_POD_NAME", podName},
|
|
|
|
{"K8S_POD_INFRA_CONTAINER_ID", sandboxID},
|
|
|
|
{"K8S_POD_UID", podUID},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-10 00:45:23 +09:00
|
|
|
// delegateRuntimeConfig creates the CNI `RuntimeConf` for the given ADD / DEL request.
|
|
|
|
func delegateRuntimeConfig(containerID string, delegate *DelegateNetConf, rc *RuntimeConfig, ifName string) *RuntimeConfig {
|
thick-plugin: refactor multus
Multus is refactored as a thick plugin, featuring 2 main components:
- a server listening to a unix domain socket, running in a pod
- a shim, a binary on the host that will send JSON requests built from
its environment / stdin values to the aforementioned server.
The pod where the multus daemon is running must share the host's PID
namespace.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
react to maintainers review
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, deployment: update the daemonset spec
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, config: validate the cni config passed by the runtime
Without this patch, we're blindly trusting anything sent by the server.
This way, we assure the requests arriving at the multus controller are
valid before hand.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick: model client / server config
Also add a new command line parameter on the multus controller, pointing
it to the server configuration.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
SQUASH candidate, thick, config: cleanup the configuration
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
multus: use args.args instead of an env variable
CNI is already filling the args structure; we should consume that
rather than rely on the environment variables.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
unit tests: remove weird tests that check an impossible scenario
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
docs, thick: document the thick plugin variant
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, server, multus: re-use common types
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
2021-12-16 18:18:35 +01:00
|
|
|
var delegateRc *RuntimeConfig
|
|
|
|
|
|
|
|
if delegate != nil {
|
|
|
|
delegateRc = mergeCNIRuntimeConfig(rc, delegate)
|
|
|
|
if delegateRc.DeviceID != "" {
|
|
|
|
if delegateRc.CNIDeviceInfoFile != "" {
|
|
|
|
logging.Debugf("Warning: Existing value of CNIDeviceInfoFile will be overwritten %s", delegateRc.CNIDeviceInfoFile)
|
|
|
|
}
|
|
|
|
autoDeviceInfo := fmt.Sprintf("%s-%s_%s", delegate.Name, containerID, ifName)
|
|
|
|
delegateRc.CNIDeviceInfoFile = nadutils.GetCNIDeviceInfoPath(autoDeviceInfo)
|
|
|
|
logging.Debugf("Adding auto-generated CNIDeviceInfoFile: %s", delegateRc.CNIDeviceInfoFile)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
delegateRc = rc
|
|
|
|
}
|
|
|
|
return delegateRc
|
|
|
|
}
|
|
|
|
|
2019-08-27 16:52:58 +09:00
|
|
|
// GetGatewayFromResult retrieves gateway IP addresses from CNI result
|
2022-03-02 01:55:23 +09:00
|
|
|
func GetGatewayFromResult(result *cni100.Result) []net.IP {
|
2019-08-27 16:52:58 +09:00
|
|
|
var gateways []net.IP
|
|
|
|
|
|
|
|
for _, route := range result.Routes {
|
|
|
|
if mask, _ := route.Dst.Mask.Size(); mask == 0 {
|
|
|
|
gateways = append(gateways, route.GW)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return gateways
|
|
|
|
}
|
|
|
|
|
2022-08-10 00:45:23 +09:00
|
|
|
// GetDefaultNetConf returns NetConf with default variables
|
|
|
|
func GetDefaultNetConf() *NetConf {
|
|
|
|
// LogToStderr's default value set to true
|
|
|
|
return &NetConf{
|
|
|
|
BinDir: defaultBinDir,
|
|
|
|
ConfDir: defaultConfDir,
|
|
|
|
CNIDir: defaultCNIDir,
|
|
|
|
LogToStderr: true,
|
|
|
|
MultusNamespace: defaultMultusNamespace,
|
|
|
|
NonIsolatedNamespaces: []string{defaultNonIsolatedNamespace},
|
|
|
|
ReadinessIndicatorFile: defaultReadinessIndicatorFile,
|
|
|
|
SystemNamespaces: []string{"kube-system"},
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-06-24 16:57:03 +09:00
|
|
|
// LoadNetConf converts inputs (i.e. stdin) to NetConf
|
2018-05-01 13:08:39 -05:00
|
|
|
func LoadNetConf(bytes []byte) (*NetConf, error) {
|
2022-08-10 00:45:23 +09:00
|
|
|
netconf := GetDefaultNetConf()
|
2018-08-06 15:55:30 +09:00
|
|
|
|
2018-08-06 16:54:32 +09:00
|
|
|
logging.Debugf("LoadNetConf: %s", string(bytes))
|
2018-05-01 13:08:39 -05:00
|
|
|
if err := json.Unmarshal(bytes, netconf); err != nil {
|
2019-10-02 18:02:26 +09:00
|
|
|
return nil, logging.Errorf("LoadNetConf: failed to load netconf: %v", err)
|
2018-05-01 13:08:39 -05:00
|
|
|
}
|
|
|
|
|
2018-06-29 17:41:18 +09:00
|
|
|
// Logging
|
2021-02-23 15:01:58 -08:00
|
|
|
logging.SetLogStderr(netconf.LogToStderr)
|
2022-04-11 23:22:48 +08:00
|
|
|
logging.SetLogOptions(netconf.LogOptions)
|
2018-07-12 12:15:53 +09:00
|
|
|
if netconf.LogFile != "" {
|
|
|
|
logging.SetLogFile(netconf.LogFile)
|
2018-06-29 17:41:18 +09:00
|
|
|
}
|
2018-07-12 12:15:53 +09:00
|
|
|
if netconf.LogLevel != "" {
|
|
|
|
logging.SetLogLevel(netconf.LogLevel)
|
2018-06-29 17:41:18 +09:00
|
|
|
}
|
|
|
|
|
2018-06-13 15:14:02 -05:00
|
|
|
// Parse previous result
|
|
|
|
if netconf.RawPrevResult != nil {
|
|
|
|
resultBytes, err := json.Marshal(netconf.RawPrevResult)
|
|
|
|
if err != nil {
|
2019-10-02 18:02:26 +09:00
|
|
|
return nil, logging.Errorf("LoadNetConf: could not serialize prevResult: %v", err)
|
2018-06-13 15:14:02 -05:00
|
|
|
}
|
|
|
|
res, err := version.NewResult(netconf.CNIVersion, resultBytes)
|
|
|
|
if err != nil {
|
2019-10-02 18:02:26 +09:00
|
|
|
return nil, logging.Errorf("LoadNetConf: could not parse prevResult: %v", err)
|
2018-06-13 15:14:02 -05:00
|
|
|
}
|
|
|
|
netconf.RawPrevResult = nil
|
2022-03-02 01:55:23 +09:00
|
|
|
netconf.PrevResult, err = cni100.NewResultFromResult(res)
|
2018-06-13 15:14:02 -05:00
|
|
|
if err != nil {
|
2019-10-02 18:02:26 +09:00
|
|
|
return nil, logging.Errorf("LoadNetConf: could not convert result to current version: %v", err)
|
2018-06-13 15:14:02 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-01 13:08:39 -05:00
|
|
|
// Delegates must always be set. If no kubeconfig is present, the
|
|
|
|
// delegates are executed in-order. If a kubeconfig is present,
|
|
|
|
// at least one delegate must be present and the first delegate is
|
|
|
|
// the master plugin. Kubernetes CRD delegates are then appended to
|
|
|
|
// the existing delegate list and all delegates executed in-order.
|
|
|
|
|
2018-10-11 17:57:20 +09:00
|
|
|
if len(netconf.RawDelegates) == 0 && netconf.ClusterNetwork == "" {
|
2022-03-23 02:36:34 +09:00
|
|
|
return nil, logging.Errorf("LoadNetConf: at least one delegate/clusterNetwork must be specified")
|
2018-05-01 13:08:39 -05:00
|
|
|
}
|
|
|
|
|
2020-10-29 13:10:12 -04:00
|
|
|
// setup namespace isolation
|
2022-08-10 00:45:23 +09:00
|
|
|
if netconf.RawNonIsolatedNamespaces != "" {
|
2020-10-29 13:10:12 -04:00
|
|
|
// Parse the comma separated list
|
|
|
|
nonisolated := strings.Split(netconf.RawNonIsolatedNamespaces, ",")
|
|
|
|
// Cleanup the whitespace
|
|
|
|
for i, nonv := range nonisolated {
|
|
|
|
nonisolated[i] = strings.TrimSpace(nonv)
|
|
|
|
}
|
|
|
|
netconf.NonIsolatedNamespaces = nonisolated
|
|
|
|
}
|
|
|
|
|
2018-10-11 17:57:20 +09:00
|
|
|
// get RawDelegates and put delegates field
|
2018-10-15 16:32:15 +09:00
|
|
|
if netconf.ClusterNetwork == "" {
|
2018-10-11 17:57:20 +09:00
|
|
|
// for Delegates
|
|
|
|
if len(netconf.RawDelegates) == 0 {
|
2019-10-02 18:02:26 +09:00
|
|
|
return nil, logging.Errorf("LoadNetConf: at least one delegate must be specified")
|
2018-06-19 21:27:42 -05:00
|
|
|
}
|
2018-10-11 17:57:20 +09:00
|
|
|
for idx, rawConf := range netconf.RawDelegates {
|
|
|
|
bytes, err := json.Marshal(rawConf)
|
|
|
|
if err != nil {
|
2019-10-02 18:02:26 +09:00
|
|
|
return nil, logging.Errorf("LoadNetConf: error marshalling delegate %d config: %v", idx, err)
|
2018-10-11 17:57:20 +09:00
|
|
|
}
|
2020-11-03 09:42:30 -05:00
|
|
|
delegateConf, err := LoadDelegateNetConf(bytes, nil, "", "")
|
2018-10-11 17:57:20 +09:00
|
|
|
if err != nil {
|
2019-10-02 18:02:26 +09:00
|
|
|
return nil, logging.Errorf("LoadNetConf: failed to load delegate %d config: %v", idx, err)
|
2018-10-11 17:57:20 +09:00
|
|
|
}
|
|
|
|
netconf.Delegates = append(netconf.Delegates, delegateConf)
|
2018-05-01 13:08:39 -05:00
|
|
|
}
|
2018-10-11 17:57:20 +09:00
|
|
|
netconf.RawDelegates = nil
|
2018-05-01 13:08:39 -05:00
|
|
|
|
2018-10-11 17:57:20 +09:00
|
|
|
// First delegate is always the master plugin
|
|
|
|
netconf.Delegates[0].MasterPlugin = true
|
|
|
|
}
|
2018-05-01 13:08:39 -05:00
|
|
|
|
|
|
|
return netconf, nil
|
|
|
|
}
|
|
|
|
|
thick-plugin: refactor multus
Multus is refactored as a thick plugin, featuring 2 main components:
- a server listening to a unix domain socket, running in a pod
- a shim, a binary on the host that will send JSON requests built from
its environment / stdin values to the aforementioned server.
The pod where the multus daemon is running must share the host's PID
namespace.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
react to maintainers review
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, deployment: update the daemonset spec
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, config: validate the cni config passed by the runtime
Without this patch, we're blindly trusting anything sent by the server.
This way, we assure the requests arriving at the multus controller are
valid before hand.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick: model client / server config
Also add a new command line parameter on the multus controller, pointing
it to the server configuration.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
SQUASH candidate, thick, config: cleanup the configuration
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
multus: use args.args instead of an env variable
CNI is already filling the args structure; we should consume that
rather than rely on the environment variables.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
unit tests: remove weird tests that check an impossible scenario
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
docs, thick: document the thick plugin variant
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, server, multus: re-use common types
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
2021-12-16 18:18:35 +01:00
|
|
|
// LoadDaemonNetConf loads the configuration for the multus daemon
|
2022-03-23 02:36:34 +09:00
|
|
|
func LoadDaemonNetConf(configPath string) (*ControllerNetConf, []byte, error) {
|
thick-plugin: refactor multus
Multus is refactored as a thick plugin, featuring 2 main components:
- a server listening to a unix domain socket, running in a pod
- a shim, a binary on the host that will send JSON requests built from
its environment / stdin values to the aforementioned server.
The pod where the multus daemon is running must share the host's PID
namespace.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
react to maintainers review
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, deployment: update the daemonset spec
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, config: validate the cni config passed by the runtime
Without this patch, we're blindly trusting anything sent by the server.
This way, we assure the requests arriving at the multus controller are
valid before hand.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick: model client / server config
Also add a new command line parameter on the multus controller, pointing
it to the server configuration.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
SQUASH candidate, thick, config: cleanup the configuration
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
multus: use args.args instead of an env variable
CNI is already filling the args structure; we should consume that
rather than rely on the environment variables.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
unit tests: remove weird tests that check an impossible scenario
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
docs, thick: document the thick plugin variant
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, server, multus: re-use common types
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
2021-12-16 18:18:35 +01:00
|
|
|
config, err := ioutil.ReadFile(configPath)
|
|
|
|
if err != nil {
|
2022-03-23 02:36:34 +09:00
|
|
|
return nil, nil, fmt.Errorf("failed to read the config file's contents: %w", err)
|
thick-plugin: refactor multus
Multus is refactored as a thick plugin, featuring 2 main components:
- a server listening to a unix domain socket, running in a pod
- a shim, a binary on the host that will send JSON requests built from
its environment / stdin values to the aforementioned server.
The pod where the multus daemon is running must share the host's PID
namespace.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
react to maintainers review
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, deployment: update the daemonset spec
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, config: validate the cni config passed by the runtime
Without this patch, we're blindly trusting anything sent by the server.
This way, we assure the requests arriving at the multus controller are
valid before hand.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick: model client / server config
Also add a new command line parameter on the multus controller, pointing
it to the server configuration.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
SQUASH candidate, thick, config: cleanup the configuration
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
multus: use args.args instead of an env variable
CNI is already filling the args structure; we should consume that
rather than rely on the environment variables.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
unit tests: remove weird tests that check an impossible scenario
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
docs, thick: document the thick plugin variant
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, server, multus: re-use common types
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
2021-12-16 18:18:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
daemonNetConf := &ControllerNetConf{}
|
|
|
|
if err := json.Unmarshal(config, daemonNetConf); err != nil {
|
2022-03-23 02:36:34 +09:00
|
|
|
return nil, nil, fmt.Errorf("failed to unmarshall the daemon configuration: %w", err)
|
thick-plugin: refactor multus
Multus is refactored as a thick plugin, featuring 2 main components:
- a server listening to a unix domain socket, running in a pod
- a shim, a binary on the host that will send JSON requests built from
its environment / stdin values to the aforementioned server.
The pod where the multus daemon is running must share the host's PID
namespace.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
react to maintainers review
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, deployment: update the daemonset spec
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, config: validate the cni config passed by the runtime
Without this patch, we're blindly trusting anything sent by the server.
This way, we assure the requests arriving at the multus controller are
valid before hand.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick: model client / server config
Also add a new command line parameter on the multus controller, pointing
it to the server configuration.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
SQUASH candidate, thick, config: cleanup the configuration
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
multus: use args.args instead of an env variable
CNI is already filling the args structure; we should consume that
rather than rely on the environment variables.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
unit tests: remove weird tests that check an impossible scenario
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
docs, thick: document the thick plugin variant
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, server, multus: re-use common types
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
2021-12-16 18:18:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
logging.SetLogStderr(daemonNetConf.LogToStderr)
|
|
|
|
if daemonNetConf.LogFile != DefaultMultusDaemonConfigFile {
|
|
|
|
logging.SetLogFile(daemonNetConf.LogFile)
|
|
|
|
}
|
|
|
|
if daemonNetConf.LogLevel != "" {
|
|
|
|
logging.SetLogLevel(daemonNetConf.LogLevel)
|
|
|
|
}
|
|
|
|
|
|
|
|
if daemonNetConf.CNIDir == "" {
|
|
|
|
daemonNetConf.CNIDir = defaultCNIDir
|
|
|
|
}
|
|
|
|
|
|
|
|
if daemonNetConf.ConfDir == "" {
|
|
|
|
daemonNetConf.ConfDir = defaultConfDir
|
|
|
|
}
|
|
|
|
|
|
|
|
if daemonNetConf.BinDir == "" {
|
|
|
|
daemonNetConf.BinDir = defaultBinDir
|
|
|
|
}
|
|
|
|
|
|
|
|
if daemonNetConf.MultusSocketDir == "" {
|
|
|
|
daemonNetConf.MultusSocketDir = defaultMultusRunDir
|
|
|
|
}
|
|
|
|
|
2022-03-23 02:36:34 +09:00
|
|
|
return daemonNetConf, config, nil
|
thick-plugin: refactor multus
Multus is refactored as a thick plugin, featuring 2 main components:
- a server listening to a unix domain socket, running in a pod
- a shim, a binary on the host that will send JSON requests built from
its environment / stdin values to the aforementioned server.
The pod where the multus daemon is running must share the host's PID
namespace.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
react to maintainers review
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, deployment: update the daemonset spec
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, config: validate the cni config passed by the runtime
Without this patch, we're blindly trusting anything sent by the server.
This way, we assure the requests arriving at the multus controller are
valid before hand.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick: model client / server config
Also add a new command line parameter on the multus controller, pointing
it to the server configuration.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
SQUASH candidate, thick, config: cleanup the configuration
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
multus: use args.args instead of an env variable
CNI is already filling the args structure; we should consume that
rather than rely on the environment variables.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
unit tests: remove weird tests that check an impossible scenario
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
docs, thick: document the thick plugin variant
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
thick, server, multus: re-use common types
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
2021-12-16 18:18:35 +01:00
|
|
|
}
|
|
|
|
|
2018-05-01 13:08:39 -05:00
|
|
|
// AddDelegates appends the new delegates to the delegates list
|
|
|
|
func (n *NetConf) AddDelegates(newDelegates []*DelegateNetConf) error {
|
2018-08-06 15:55:30 +09:00
|
|
|
logging.Debugf("AddDelegates: %v", newDelegates)
|
2018-05-01 13:08:39 -05:00
|
|
|
n.Delegates = append(n.Delegates, newDelegates...)
|
|
|
|
return nil
|
|
|
|
}
|
2018-09-10 16:27:07 +01:00
|
|
|
|
|
|
|
// delegateAddDeviceID injects deviceID information in delegate bytes
|
|
|
|
func delegateAddDeviceID(inBytes []byte, deviceID string) ([]byte, error) {
|
|
|
|
var rawConfig map[string]interface{}
|
|
|
|
var err error
|
|
|
|
|
|
|
|
err = json.Unmarshal(inBytes, &rawConfig)
|
|
|
|
if err != nil {
|
|
|
|
return nil, logging.Errorf("delegateAddDeviceID: failed to unmarshal inBytes: %v", err)
|
|
|
|
}
|
|
|
|
// Inject deviceID
|
|
|
|
rawConfig["deviceID"] = deviceID
|
2019-04-25 15:31:45 +08:00
|
|
|
rawConfig["pciBusID"] = deviceID
|
2018-09-10 16:27:07 +01:00
|
|
|
configBytes, err := json.Marshal(rawConfig)
|
|
|
|
if err != nil {
|
|
|
|
return nil, logging.Errorf("delegateAddDeviceID: failed to re-marshal Spec.Config: %v", err)
|
|
|
|
}
|
2019-10-02 18:02:26 +09:00
|
|
|
logging.Debugf("delegateAddDeviceID updated configBytes %s", string(configBytes))
|
2019-03-26 00:34:35 +00:00
|
|
|
return configBytes, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// addDeviceIDInConfList injects deviceID information in delegate bytes
|
|
|
|
func addDeviceIDInConfList(inBytes []byte, deviceID string) ([]byte, error) {
|
|
|
|
var rawConfig map[string]interface{}
|
|
|
|
var err error
|
|
|
|
|
|
|
|
err = json.Unmarshal(inBytes, &rawConfig)
|
|
|
|
if err != nil {
|
2019-10-02 18:02:26 +09:00
|
|
|
return nil, logging.Errorf("addDeviceIDInConfList: failed to unmarshal inBytes: %v", err)
|
2019-03-26 00:34:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pList, ok := rawConfig["plugins"]
|
|
|
|
if !ok {
|
2019-10-02 18:02:26 +09:00
|
|
|
return nil, logging.Errorf("addDeviceIDInConfList: unable to get plugin list")
|
2019-03-26 00:34:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pMap, ok := pList.([]interface{})
|
|
|
|
if !ok {
|
2019-10-02 18:02:26 +09:00
|
|
|
return nil, logging.Errorf("addDeviceIDInConfList: unable to typecast plugin list")
|
2019-03-26 00:34:35 +00:00
|
|
|
}
|
|
|
|
|
2020-03-04 15:28:03 +02:00
|
|
|
for idx, plugin := range pMap {
|
|
|
|
currentPlugin, ok := plugin.(map[string]interface{})
|
|
|
|
if !ok {
|
|
|
|
return nil, logging.Errorf("addDeviceIDInConfList: unable to typecast plugin #%d", idx)
|
|
|
|
}
|
|
|
|
// Inject deviceID
|
|
|
|
currentPlugin["deviceID"] = deviceID
|
|
|
|
currentPlugin["pciBusID"] = deviceID
|
2019-03-26 00:34:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
configBytes, err := json.Marshal(rawConfig)
|
|
|
|
if err != nil {
|
2019-10-02 18:02:26 +09:00
|
|
|
return nil, logging.Errorf("addDeviceIDInConfList: failed to re-marshal: %v", err)
|
2019-03-26 00:34:35 +00:00
|
|
|
}
|
2019-10-02 18:02:26 +09:00
|
|
|
logging.Debugf("addDeviceIDInConfList: updated configBytes %s", string(configBytes))
|
2018-09-10 16:27:07 +01:00
|
|
|
return configBytes, nil
|
|
|
|
}
|
2019-01-29 19:02:47 +09:00
|
|
|
|
2019-08-19 17:17:51 +09:00
|
|
|
// injectCNIArgs injects given args to cniConfig
|
|
|
|
func injectCNIArgs(cniConfig *map[string]interface{}, args *map[string]interface{}) error {
|
|
|
|
if argsval, ok := (*cniConfig)["args"]; ok {
|
|
|
|
argsvalmap := argsval.(map[string]interface{})
|
|
|
|
if cnival, ok := argsvalmap["cni"]; ok {
|
|
|
|
cnivalmap := cnival.(map[string]interface{})
|
|
|
|
// merge it if conf has args
|
|
|
|
for key, val := range *args {
|
|
|
|
cnivalmap[key] = val
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
argsvalmap["cni"] = *args
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
argsval := map[string]interface{}{}
|
|
|
|
argsval["cni"] = *args
|
|
|
|
(*cniConfig)["args"] = argsval
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// addCNIArgsInConfig injects given cniArgs to CNI config in inBytes
|
|
|
|
func addCNIArgsInConfig(inBytes []byte, cniArgs *map[string]interface{}) ([]byte, error) {
|
|
|
|
var rawConfig map[string]interface{}
|
|
|
|
var err error
|
|
|
|
|
|
|
|
err = json.Unmarshal(inBytes, &rawConfig)
|
|
|
|
if err != nil {
|
|
|
|
return nil, logging.Errorf("addCNIArgsInConfig(): failed to unmarshal inBytes: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
injectCNIArgs(&rawConfig, cniArgs)
|
|
|
|
|
|
|
|
configBytes, err := json.Marshal(rawConfig)
|
|
|
|
if err != nil {
|
|
|
|
return nil, logging.Errorf("addCNIArgsInConfig(): failed to re-marshal: %v", err)
|
|
|
|
}
|
|
|
|
return configBytes, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// addCNIArgsInConfList injects given cniArgs to CNI conflist in inBytes
|
|
|
|
func addCNIArgsInConfList(inBytes []byte, cniArgs *map[string]interface{}) ([]byte, error) {
|
|
|
|
var rawConfig map[string]interface{}
|
|
|
|
var err error
|
|
|
|
|
|
|
|
err = json.Unmarshal(inBytes, &rawConfig)
|
|
|
|
if err != nil {
|
|
|
|
return nil, logging.Errorf("addCNIArgsInConfList(): failed to unmarshal inBytes: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
pList, ok := rawConfig["plugins"]
|
|
|
|
if !ok {
|
|
|
|
return nil, logging.Errorf("addCNIArgsInConfList(): unable to get plugin list")
|
|
|
|
}
|
|
|
|
|
|
|
|
pMap, ok := pList.([]interface{})
|
|
|
|
if !ok {
|
|
|
|
return nil, logging.Errorf("addCNIArgsInConfList(): unable to typecast plugin list")
|
|
|
|
}
|
|
|
|
|
|
|
|
for idx := range pMap {
|
|
|
|
valMap := pMap[idx].(map[string]interface{})
|
|
|
|
injectCNIArgs(&valMap, cniArgs)
|
|
|
|
}
|
|
|
|
|
|
|
|
configBytes, err := json.Marshal(rawConfig)
|
|
|
|
if err != nil {
|
|
|
|
return nil, logging.Errorf("addCNIArgsInConfList(): failed to re-marshal: %v", err)
|
|
|
|
}
|
|
|
|
return configBytes, nil
|
|
|
|
}
|
|
|
|
|
2021-12-04 00:48:50 +09:00
|
|
|
// CheckGatewayConfig check gatewayRequest and mark IsFilter{V4,V6}Gateway flag if
|
2019-08-27 16:52:58 +09:00
|
|
|
// gw filtering is required
|
2021-12-04 00:48:50 +09:00
|
|
|
func CheckGatewayConfig(delegates []*DelegateNetConf) error {
|
|
|
|
|
|
|
|
v4Gateways := 0
|
|
|
|
v6Gateways := 0
|
|
|
|
|
|
|
|
// Check the gateway
|
|
|
|
for _, delegate := range delegates {
|
2022-01-07 22:47:23 +09:00
|
|
|
if delegate.GatewayRequest != nil {
|
|
|
|
for _, gw := range *delegate.GatewayRequest {
|
|
|
|
if gw.To4() != nil {
|
|
|
|
v4Gateways++
|
|
|
|
} else {
|
|
|
|
v6Gateways++
|
|
|
|
}
|
2021-12-04 00:48:50 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if v4Gateways > 1 || v6Gateways > 1 {
|
|
|
|
return fmt.Errorf("multus does not support ECMP for default-route")
|
|
|
|
}
|
|
|
|
|
|
|
|
// set filter flag for each delegate
|
2019-08-27 16:52:58 +09:00
|
|
|
for i, delegate := range delegates {
|
2022-08-30 15:29:53 +02:00
|
|
|
delegates[i].IsFilterV4Gateway = true
|
|
|
|
delegates[i].IsFilterV6Gateway = true
|
|
|
|
if delegate.GatewayRequest != nil {
|
2022-01-07 22:47:23 +09:00
|
|
|
for _, gw := range *delegate.GatewayRequest {
|
2021-12-04 00:48:50 +09:00
|
|
|
if gw.To4() != nil {
|
2022-08-30 15:29:53 +02:00
|
|
|
delegates[i].IsFilterV4Gateway = false
|
2021-12-04 00:48:50 +09:00
|
|
|
} else {
|
2022-08-30 15:29:53 +02:00
|
|
|
delegates[i].IsFilterV6Gateway = false
|
2021-12-04 00:48:50 +09:00
|
|
|
}
|
|
|
|
}
|
2019-08-27 16:52:58 +09:00
|
|
|
}
|
|
|
|
}
|
2021-12-04 00:48:50 +09:00
|
|
|
return nil
|
2019-08-27 16:52:58 +09:00
|
|
|
}
|
|
|
|
|
2019-01-29 19:02:47 +09:00
|
|
|
// CheckSystemNamespaces checks whether given namespace is in systemNamespaces or not.
|
|
|
|
func CheckSystemNamespaces(namespace string, systemNamespaces []string) bool {
|
|
|
|
for _, nsname := range systemNamespaces {
|
|
|
|
if namespace == nsname {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|