config

package
v0.0.0-...-6843e3f Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0, BSD-2-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package config provides the configuration for the cubelet

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendConfigWatcher

func AppendConfigWatcher(listener Watcher)

func DefaultLivenessProbeEnabled

func DefaultLivenessProbeEnabled() bool

DefaultLivenessProbeEnabled is true unless config turns the envd probe off.

func GetPoolSizeForInit

func GetPoolSizeForInit(defaultSize int) int

func GetTenantNamespaceFromMap

func GetTenantNamespaceFromMap(annos map[string]string) string

func RecoverLivenessProbesDisabled

func RecoverLivenessProbesDisabled() bool

RecoverLivenessProbesDisabled reports the debug switch that skips reattaching probes after process start.

func StatusReportBatchSize

func StatusReportBatchSize() int

StatusReportBatchSize is how many sandboxes one POST carries. The default is 100.

func StatusReportEnabled

func StatusReportEnabled() bool

StatusReportEnabled is true unless sandbox_status_report.enabled is false.

func StatusReportInterval

func StatusReportInterval() time.Duration

StatusReportInterval is the flush period. The default is one second.

Types

type CommonConf

type CommonConf struct {
	CommonTimeout         time.Duration `yaml:"common_timeout"`
	LogLevel              string        `yaml:"log_level"`
	DescribeAsyncInterval time.Duration `yaml:"describe_asynchronous"`
	EnablePFMode          bool          `yaml:"enable_pf_mode"`
	DescribeBDFInterval   time.Duration `yaml:"describe_bdf"`
	DescribeBDFTimeout    time.Duration `yaml:"describe_bdf_timeout"`
	GetBDFByUuidCmd       string        `yaml:"get_bdf_by_uuid_cmd"`
	GetBDFByIfNameCmd     string        `yaml:"get_bdf_by_ifname_cmd"`
	CommandTimeout        time.Duration `yaml:"command_timeout"`

	DisableHostCgroup bool `yaml:"disable_host_cgroup"`

	// DisableRestartPolicy stops new liveness probes and restart loops.
	// In-flight loops exit at their next check. Default false (enabled).
	DisableRestartPolicy bool `yaml:"disable_restart_policy"`

	// DisableRecoverLivenessProbes skips reattaching probes after this
	// process starts. A sandbox that is already dead still restarts.
	DisableRecoverLivenessProbes bool `yaml:"disable_recover_liveness_probes"`

	// DefaultLivenessProbe injects GET :49983/health only when the sandbox
	// has envd and the user did not set a probe. Nil means enabled.
	DefaultLivenessProbe *DefaultLivenessProbeConf `yaml:"default_liveness_probe"`

	// SandboxStatusReport posts restart status to CubeMaster. Nil means
	// enabled, once a second, 100 items per batch.
	SandboxStatusReport *SandboxStatusReportConf `yaml:"sandbox_status_report"`

	DisableVmCgroup bool `yaml:"disable_vm_cgroup"`

	EnableSandboxExecCmdBeforeExist bool          `yaml:"enable_sandbox_exec_cmd_before_exist"`
	SandboxExecCmdTimeOut           time.Duration `yaml:"sandbox_exec_cmd_time_out"`
	SandboxExecCmdBeforeExist       []string      `yaml:"sandbox_exec_cmd_before_exist"`
	SandboxExecCmdBeforeExistLogOut bool          `yaml:"sandbox_exec_cmd_before_exist_log_out"`
	SandboxExecCmdOutMaxLines       int           `yaml:"sandbox_exec_cmd_out_max_lines"`
	SandboxExecCmdMatchLine         string        `yaml:"sandbox_exec_cmd_match_line"`
	SandboxExecCmdAfterMatch        []string      `yaml:"sandbox_exec_cmd_after_match"`
	SandboxExecCmdBase64AfterMatch  string        `yaml:"sandbox_exec_base64_cmd_after_match"`
	SandboxExecCmdAfterMatchLogOut  bool          `yaml:"sandbox_exec_cmd_after_match_log_out"`

	CgroupDisableMemoryReparentFile string `yaml:"cgroup_disable_memory_reparent_file"`
	CgroupDisableCpusetList         string `yaml:"cgroup_disable_cpuset_list"`

	DisableHostNetfile bool `yaml:"disable_host_netfile"`

	// OperatorAllowOut is an administrator-owned IPv4 CIDR allowlist. Restart Cubelet after changes.
	OperatorAllowOut   []string      `yaml:"operator_allow_out"`
	DefaultDNSServers  []string      `yaml:"default_dns_servers"`
	DefaultDNSSearches []string      `yaml:"default_dns_searches"`
	DefaultDNSOptions  []string      `yaml:"default_dns_options"`
	ReconcileInterval  time.Duration `yaml:"reconcile_interval"`

	DisableCubeBoxTemplateBaseFormatPoolOfNumberVer bool `yaml:"disable_cube_box_template_base_format_pool_of_number_ver"`
}

func GetCommon

func GetCommon() *CommonConf

type Config

type Config struct {
	Common           *CommonConf       `yaml:"common"`
	Tenant           *TenantManager    `yaml:"tenant"`
	MetaServerConfig *MetaServerConfig `yaml:"meta_server_config"`
	HostConf         *HostConf         `yaml:"host"`
}

func GetConfig

func GetConfig() *Config

func Init

func Init(configPath string, useDefault bool) (*Config, error)

type DefaultLivenessProbeConf

type DefaultLivenessProbeConf struct {
	Enabled *bool `yaml:"enabled"`
}

DefaultLivenessProbeConf gates the envd health check used when a restarting sandbox has no user probe.

type HostConf

type HostConf struct {
	Quota          HostConfigQuota `yaml:"quota"`
	GC             HostConfigGC    `yaml:"gc"`
	SchedulerLabel string          `yaml:"scheduler_label"`
}

func GetHostConf

func GetHostConf() *HostConf

type HostConfigGC

type HostConfigGC struct {
	CodeExpirationTime  string `yaml:"code_expiration_time"`
	ImageExpirationTime string `yaml:"image_expiration_time"`
}

type HostConfigQuota

type HostConfigQuota struct {
	Cpu                   int    `yaml:"mcpu_limit"`
	Mem                   string `yaml:"mem_limit"`
	MvmLimit              int    `yaml:"mvm_limit"`
	CreationConcurrentNum int    `yaml:"creation_concurrent_num"`

	// CpuOvercommitFactor multiplies detected host CPU when mcpu_limit is unset
	// (or <= 0). Zero / omitted keeps the historical default of 2.0. Explicit
	// mcpu_limit always wins and ignores this factor. Must be finite and in
	// [0, 20]; 0 means "use default". The derived value is also what CubeOps
	// stores as node Capacity and CubeMaster uses for CPU watermark filters.
	CpuOvercommitFactor float64 `yaml:"cpu_overcommit_factor"`
	// MemOvercommitFactor multiplies detected host memory when mem_limit is
	// unset (or empty). Zero / omitted keeps the historical default of 1.25
	// (5/4). Explicit mem_limit always wins and ignores this factor. Must be
	// finite and in [0, 3]; 0 means "use default". Raising this also raises
	// the Capacity / MemMBTotal watermark CubeMaster uses for memfilter, so
	// the physical free-memory threshold scales with the same ratio.
	MemOvercommitFactor float64 `yaml:"mem_overcommit_factor"`

	// PausedResourceReleaseRatio is the paused-resource scheduling dial.
	// Pausing a sandbox snapshots it to disk and shuts the MicroVM down, so its
	// host CPU/RAM is already reclaimed; this ratio decides how much of that
	// quota is released back to the scheduler vs kept reserved as resume
	// headroom. It is in [0,1] (out-of-range values are clamped) and is applied
	// symmetrically to CPU and memory:
	//   0.0 (default) -- release nothing: paused sandboxes keep their full
	//                    quota, so resume is guaranteed. Identical to the legacy
	//                    behaviour (the safe zero-value default).
	//   1.0           -- release everything: maximum density, resume is purely
	//                    best-effort and rejected when the node can no longer
	//                    fit the sandbox (see UpdateWithResume admission).
	//   0 < r < 1     -- release a fraction r and reserve (1-r) as headroom. A
	//                    pause-heavy node then (a) keeps room for its own
	//                    resumes and (b), because the reserved quota still shows
	//                    up in QuotaCpuUsage/QuotaMemUsage, is naturally
	//                    deprioritised by the cpu/mem quota scoring factors, so
	//                    the scheduler stops piling new sandboxes onto nodes
	//                    that already hold many paused ones.
	// Disk is intentionally still counted (the pause snapshot occupies storage)
	// and paused sandboxes still count toward MvmNum, regardless of the ratio.
	PausedResourceReleaseRatio float64 `yaml:"paused_resource_release_ratio"`
}

type MetaServerConfig

type MetaServerConfig struct {
	MetaServerEndpoint  string `yaml:"meta_server_endpoint,omitempty"`
	NodeStatusMaxImages int32  `yaml:"node_status_max_images,omitempty"`
	// CubeMasterHTTPAddr is the CubeMaster HTTP address for artifact downloads.
	CubeMasterHTTPAddr string `yaml:"cubemaster_http_addr,omitempty"`
}

type SandboxStatusReportConf

type SandboxStatusReportConf struct {
	Enabled   *bool         `yaml:"enabled"`
	Interval  time.Duration `yaml:"interval"`
	BatchSize int           `yaml:"batch_size"`
}

SandboxStatusReportConf tunes the CubeMaster status client.

type TenantConf

type TenantConf struct {
	Namespace string `toml:"namespace"`
}

type TenantManager

type TenantManager struct {
	Tenants                map[string]*TenantConf `yaml:"tenants"`
	UseRespectiveNamespace bool                   `yaml:"useRespectiveNamespace"`
	DefaultNS              string                 `yaml:"defaultNS"`

	ZiyanUinListStr string `yaml:"ziyanUinListStr"`
}

type Watcher

type Watcher interface {
	OnEvent(data *Config)
}

Jump to

Keyboard shortcuts

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