config

package
v3.9.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 26, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package config is the package that contains multus cni config related utilities.

Index

Constants

View Source
const (
	MultusDefaultNetworkName = "multus-cni-network"
)

MultusDefaultNetworkName holds the default name of the multus network

Variables

This section is empty.

Functions

func CheckVersionCompatibility

func CheckVersionCompatibility(mc *MultusConf) error

CheckVersionCompatibility checks compatibilty of the top level cni version with the delegate cni version. Since version 0.4.0, CHECK was introduced, which causes incompatibility.

func MutateLogOptions

func MutateLogOptions(logOption *LogOptions, logOptionFunc ...LogOptionFunc)

MutateLogOptions update the LoggingOptions of the MultusConf according to the provided configuration `loggingOptions`

Types

type LogOptionFunc

type LogOptionFunc func(logOptions *LogOptions)

LogOptionFunc mutates the `LoggingOptions` object

func WithLogCompress

func WithLogCompress(compress *bool) LogOptionFunc

WithLogCompress mutates the inner state to set the logCompress attribute

func WithLogMaxAge

func WithLogMaxAge(maxAge *int) LogOptionFunc

WithLogMaxAge mutates the inner state to set the logMaxAge attribute

func WithLogMaxBackups

func WithLogMaxBackups(maxBackups *int) LogOptionFunc

WithLogMaxBackups mutates the inner state to set the logMaxBackups attribute

func WithLogMaxSize

func WithLogMaxSize(maxSize *int) LogOptionFunc

WithLogMaxSize mutates the inner state to set the logMaxSize attribute

type LogOptions

type LogOptions struct {
	MaxAge     *int  `json:"maxAge,omitempty"`
	MaxSize    *int  `json:"maxSize,omitempty"`
	MaxBackups *int  `json:"maxBackups,omitempty"`
	Compress   *bool `json:"compress,omitempty"`
}

LogOptions specifies the configuration of the log

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager monitors the configuration of the primary CNI plugin, and regenerates multus configuration whenever it gets updated.

func NewManager

func NewManager(config MultusConf, multusAutoconfigDir string) (*Manager, error)

NewManager returns a config manager object, configured to persist the configuration to `multusAutoconfigDir`. This constructor will auto-discover the primary CNI for which it will delegate.

func NewManagerWithExplicitPrimaryCNIPlugin

func NewManagerWithExplicitPrimaryCNIPlugin(config MultusConf, multusAutoconfigDir string, primaryCNIPluginName string) (*Manager, error)

NewManagerWithExplicitPrimaryCNIPlugin returns a config manager object, configured to persist the configuration to `multusAutoconfigDir`. This constructor will use the primary CNI plugin indicated by the user, via the primaryCNIPluginName variable.

func (Manager) GenerateConfig

func (m Manager) GenerateConfig() (string, error)

GenerateConfig generates a multus configuration from its current state

func (Manager) MonitorDelegatedPluginConfiguration

func (m Manager) MonitorDelegatedPluginConfiguration(shutDown chan struct{}, done chan struct{}) error

MonitorDelegatedPluginConfiguration monitors the configuration file pointed to by the primaryCNIPluginName attribute, and re-generates the multus configuration whenever the primary CNI config is updated.

func (*Manager) OverrideNetworkName

func (m *Manager) OverrideNetworkName() error

OverrideNetworkName overrides the name of the multus configuration with the name of the delegated primary CNI.

func (Manager) PersistMultusConfig

func (m Manager) PersistMultusConfig(config string) error

PersistMultusConfig persists the provided configuration to the disc, with Read / Write permissions. The output file path is `<multus auto config dir>/00-multus.conf`

type MultusConf

type MultusConf struct {
	BinDir                   string          `json:"binDir,omitempty"`
	Capabilities             map[string]bool `json:"capabilities,omitempty"`
	CNIVersion               string          `json:"cniVersion"`
	Delegates                []interface{}   `json:"delegates"`
	LogFile                  string          `json:"logFile,omitempty"`
	LogLevel                 string          `json:"logLevel,omitempty"`
	LogToStderr              bool            `json:"logToStderr,omitempty"`
	LogOptions               *LogOptions     `json:"logOptions,omitempty"`
	Kubeconfig               string          `json:"kubeconfig"`
	Name                     string          `json:"name"`
	NamespaceIsolation       bool            `json:"namespaceIsolation,omitempty"`
	RawNonIsolatedNamespaces string          `json:"globalNamespaces,omitempty"`
	ReadinessIndicatorFile   string          `json:"readinessindicatorfile,omitempty"`
	Type                     string          `json:"type"`
}

MultusConf holds the multus configuration, and persists it to disk

func NewMultusConfig

func NewMultusConfig(pluginName string, cniVersion string, kubeconfig string, configurationOptions ...Option) (*MultusConf, error)

NewMultusConfig creates a basic configuration generator. It can be mutated via the `With...` methods.

func (*MultusConf) Generate

func (mc *MultusConf) Generate() (string, error)

Generate generates the multus configuration from whatever state is currently held

func (*MultusConf) Mutate

func (mc *MultusConf) Mutate(configurationOptions ...Option) error

Mutate updates the MultusConf attributes according to the provided configuration `Option`s

type Option

type Option func(conf *MultusConf)

Option mutates the `conf` object

func WithAdditionalBinaryFileDir

func WithAdditionalBinaryFileDir(directoryPath string) Option

WithAdditionalBinaryFileDir mutates the inner state to set the BinDir attribute

func WithGlobalNamespaces

func WithGlobalNamespaces(globalNamespaces string) Option

WithGlobalNamespaces mutates the inner state to set the RawNonIsolatedNamespaces attribute

func WithLogFile

func WithLogFile(logFile string) Option

WithLogFile mutates the inner state to set the logFile attribute

func WithLogLevel

func WithLogLevel(logLevel string) Option

WithLogLevel mutates the inner state to set the LogLevel attribute

func WithLogOptions

func WithLogOptions(logOptions *LogOptions) Option

WithLogOptions mutates the inner state to set the LogOptions attribute

func WithLogToStdErr

func WithLogToStdErr() Option

WithLogToStdErr mutates the inner state to enable the WithLogToStdErr attribute

func WithNamespaceIsolation

func WithNamespaceIsolation() Option

WithNamespaceIsolation mutates the inner state to enable the NamespaceIsolation attribute

func WithOverriddenName

func WithOverriddenName(networkName string) Option

WithOverriddenName mutates the inner state to set the Name attribute

func WithReadinessFileIndicator

func WithReadinessFileIndicator(path string) Option

WithReadinessFileIndicator mutates the inner state to set the ReadinessIndicatorFile attribute

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL