config

package
v0.0.0-...-a954c3e Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HostIDKey = "HOSTID"
)

Variables

View Source
var DefaultConfig = Config{
	Debug:                   "false",
	UseHostname:             constants.UseHostname,
	ClusterRole:             constants.RoleNone,
	KubeServiceState:        constants.ServiceStateIgnore,
	TransportURL:            "localhost:8111",
	ConnectTimeout:          20,
	FullRetryCount:          10,
	UseCgroups:              true,
	PhaseRetry:              3,
	CPULimit:                40,
	LoopInterval:            constants.DefaultLoopInterval,
	PhaseScriptsDir:         constants.DefaultPhaseBaseDir,
	ExtensionOutputFile:     constants.ExtensionOutputFile,
	DisableSunpike:          false,
	DisableLoop:             false,
	DisableExtFile:          false,
	DisableScripts:          false,
	KubeEnvPath:             constants.KubeEnvPath,
	ResmgrKubeEnvPath:       constants.DefaultResmgrKubeEnvPath,
	SunpikeConfigPath:       constants.DefaultSunpikeConfigPath,
	SunpikeKubeEnvPath:      constants.DefaultSunpikeKubeEnvPath,
	GRPCRetryMax:            3,
	GRPCRetryTimeoutSeconds: 5,
	NumCmdOutputLinesToLog:  10,
	UserImagesDir:           constants.UserImagesDir,
	CoreDNSHostsFile:        constants.CoreDNSHostsFile,
	K8sPrivateRegistry:      constants.K8sRegistry,
	Runtime:                 constants.Runtime,
	DockerLogMaxFile:        constants.DockerLogMaxFile,
	ContainerLogMaxFiles:    constants.ContainerLogMaxFiles,
	ContainerLogMaxSize:     constants.ContainerLogMaxSize,
	EnableCAS:               constants.EnableCAS,
	ContainerdCgroup:        constants.ContainerdCgroup,
	AllowSwap:               constants.AllowSwap,
	CPUManagerPolicy:        constants.CPUManagerPolicy,
	TopologyManagerPolicy:   constants.TopologyManagerPolicy,
	ReservedCPUs:            constants.ReservedCPUs,
	KubeletCloudConfig:      constants.KubeletCloudConfig,
	ServicesCIDR:            constants.ServicesCIDR,
}

DefaultConfig contains sane defaults for nodelet service

Functions

This section is empty.

Types

type Config

type Config struct {
	// FIXME The fields below are used in both script and golang code; after the dependency is removed, convert them to booleans.
	Debug       string `mapstructure:"DEBUG"`
	UseHostname string `mapstructure:"USE_HOSTNAME"`

	ClusterRole               string  `mapstructure:"ROLE"`
	ClusterID                 string  `mapstructure:"CLUSTER_ID"`
	HostID                    string  `mapstructure:"HOSTID"`
	TransportURL              string  `mapstructure:"TRANSPORT_URL"`
	ConnectTimeout            int     `mapstructure:"CONNECTION_TIMEOUT"`
	KubeServiceState          string  `mapstructure:"KUBE_SERVICE_STATE"`
	FullRetryCount            int     `mapstructure:"FULL_RETRY_COUNT"`
	UseCgroups                bool    `mapstructure:"USE_CGROUPS"`
	PhaseRetry                int     `mapstructure:"PHASE_RETRY"`
	CPULimit                  float64 `mapstructure:"CPU_LIMIT"`
	PF9StatusThresholdSeconds int     `mapstructure:"PF9_STATUS_THRESHOLD_SECONDS"`
	LoopInterval              int     `mapstructure:"LOOP_INTERVAL"`
	PhaseScriptsDir           string  `mapstructure:"PHASE_SCRIPTS_DIR"`
	ExtensionOutputFile       string  `mapstructure:"EXTENSION_OUTPUT_FILE"`
	KubeEnvPath               string  `mapstructure:"KUBE_ENV_PATH"`
	ResmgrKubeEnvPath         string  `mapstructure:"RESMGR_KUBE_ENV_PATH"`
	SunpikeConfigPath         string  `mapstructure:"SUNPIKE_CONFIG_PATH"`
	SunpikeKubeEnvPath        string  `mapstructure:"SUNPIKE_KUBE_ENV_PATH"`
	DisableSunpike            bool    `mapstructure:"DISABLE_SUNPIKE"`
	DisableLoop               bool    `mapstructure:"DISABLE_LOOP"`
	DisableExtFile            bool    `mapstructure:"DISABLE_EXTFILE"`
	DisableScripts            bool    `mapstructure:"DISABLE_SCRIPTS"`
	DisableConfigUpdate       bool    `mapstructure:"DISABLE_CONFIGUPDATE"`
	DisableExitOnUpdate       bool    `mapstructure:"DISABLE_EXITONUPDATE"`
	GRPCRetryMax              uint    `mapstructure:"GRPC_RETRY_MAX"`
	GRPCRetryTimeoutSeconds   int     `mapstructure:"GRPC_RETRY_TIMEOUT_SECONDS"`
	NumCmdOutputLinesToLog    int     `mapstructure:"NUM_CMD_OP_LINES_TO_LOG"`
	CloudProviderType         string  `mapstructure:"CLOUD_PROVIDER_TYPE"`
	MasterIp                  string  `mapstructure:"MASTER_IP"`
	K8sApiPort                string  `mapstructure:"K8S_API_PORT"`
	MasterSchedulable         bool    `mapstructure:"ALLOW_WORKLOADS_ON_MASTER"`
	UserImagesDir             string  `mapstructure:"USER_IMAGES_DIR"`
	K8sPrivateRegistry        string  `mapstructure:"K8S_PRIVATE_REGISTRY"`
	ServicesCIDR              string  `mapstructure:"SERVICES_CIDR"`
	AppCatalogEnabled         bool    `mapstructure:"APP_CATALOG_ENABLED"`
	KubeletCloudConfig        string  `mapstructure:"KUBELET_CLOUD_CONFIG"`
	CoreDNSHostsFile          string  `mapstructure:"COREDNS_HOSTS_FILE"`
	Runtime                   string  `mapstructure:"RUNTIME"`
	DockerLogMaxFile          string  `maptructure:"DOCKER_LOG_MAX_FILE"`
	ContainerLogMaxFiles      string  `mapstructure:"CONTAINER_LOG_MAX_FILES"`
	ContainerLogMaxSize       string  `mapstructure:"CONTAINER_LOG_MAX_SIZE"`
	EnableCAS                 bool    `mapstructure:"ENABLE_CAS"`
	ContainerdCgroup          string  `mapstructure:"CONTAINERD_CGROUP"`
	AllowSwap                 bool    `mapstructure:"ALLOW_SWAP"`
	CPUManagerPolicy          string  `mapstructure:"CPU_MANAGER_POLICY"`
	TopologyManagerPolicy     string  `mapstructure:"TOPOLOGY_MANAGER_POLICY"`
	ReservedCPUs              string  `mapstructure:"RESERVED_CPUS"`
	IPv6Enabled               bool    `mapstructure:"IPV6_ENABLED"`
}

Config a struct to load the values from viper for future use.

func GetConfigFromDir

func GetConfigFromDir(configDir string) (*Config, error)

GetConfigFromDir : Tries to load YAML config files from configDir i.e. /etc/pf9/nodelet directory.

This function returns an error if the directory is inaccessible or if no config files could be loaded

func GetConfigFromFile

func GetConfigFromFile(configFile string) (*Config, error)

func GetDefaultConfig

func GetDefaultConfig() (*Config, error)

GetDefaultConfig returns a copy of the default config.

func (Config) IsDebug

func (c Config) IsDebug() bool

IsDebug is a convenience function to check if the debug is enabled in config

func (Config) ToStringMap

func (c Config) ToStringMap() map[string]string

ToStringMap converts the Config struct to a map of strings

type KubeEnvMap

type KubeEnvMap map[string]string

KubeEnvMap is a representation of the kube.env-like key-value mapping.

func ConvertHostToKubeEnvMap

func ConvertHostToKubeEnvMap(host *sunpikev1alpha1.Host) KubeEnvMap

ConvertHostToKubeEnvMap transforms a Sunpike Host into a KubeEnvMap.

For the conversion it looks at the `kube.env` tags of the fields to decide to which key the field should be mapped. ExtraCfg is mapped too using its key-value pair. However it is not allowed to override existing fields.

func (KubeEnvMap) Copy

func (k KubeEnvMap) Copy() KubeEnvMap

Copy creates a shallow clone of the current KubeEnvMap.

func (KubeEnvMap) Keys

func (k KubeEnvMap) Keys() []string

Keys returns all keys in the map, sorted alphabetically.

func (KubeEnvMap) ToConfig

func (k KubeEnvMap) ToConfig() (*Config, error)

ToConfig converts the KubeEnvMap into a Nodelet Config, without setting any defaults.

func (KubeEnvMap) ToHost

func (k KubeEnvMap) ToHost() (*sunpikev1alpha1.Host, error)

ToHost converts the KubeEnvMap back into a Sunpike Host.

It fills the Spec and the Name of the Host. Because we cannot assume that the types are correct in the KubeEnvMap, the mapstructure package is used internally to do the decoding, which tries to infer the type based on the value contents.

Note: this is a best-effort conversion, because we lack the type information in the kubeEnvMap. So this should only be used for optional work and debugging. Do not rely on this for equality checks!

func (KubeEnvMap) ToKubeEnv

func (k KubeEnvMap) ToKubeEnv(w io.Writer) error

ToKubeEnv writes the KubeEnvMap to a destination in the kube.env format.

Format: export FOO="BAR"

func (KubeEnvMap) ToYAML

func (k KubeEnvMap) ToYAML(w io.Writer) error

ToYAML writes the KubeEnvMap to a destination in the nodelet/config.yaml format.

Jump to

Keyboard shortcuts

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