settings

package
v1.4.0-dev-20240917 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: Apache-2.0 Imports: 10 Imported by: 13

Documentation

Index

Constants

View Source
const (
	AdditionalCASettingName                           = "additional-ca"
	BackupTargetSettingName                           = "backup-target"
	VMForceResetPolicySettingName                     = "vm-force-reset-policy"
	SupportBundleTimeoutSettingName                   = "support-bundle-timeout"
	HTTPProxySettingName                              = "http-proxy"
	OvercommitConfigSettingName                       = "overcommit-config"
	SSLCertificatesSettingName                        = "ssl-certificates"
	SSLParametersName                                 = "ssl-parameters"
	VipPoolsConfigSettingName                         = "vip-pools"
	VolumeSnapshotClassSettingName                    = "volume-snapshot-class"
	DefaultDashboardUIURL                             = "https://releases.rancher.com/harvester-ui/dashboard/release-harvester-v1.4/index.html"
	SupportBundleImageName                            = "support-bundle-image"
	CSIDriverConfigSettingName                        = "csi-driver-config"
	UIIndexSettingName                                = "ui-index"
	UIPathSettingName                                 = "ui-path"
	UISourceSettingName                               = "ui-source"
	UIPluginIndexSettingName                          = "ui-plugin-index"
	UIPluginBundledVersionSettingName                 = "ui-plugin-bundled-version"
	DefaultUIPluginURL                                = "https://releases.rancher.com/harvester-ui/plugin/harvester-release-harvester-v1.4/harvester-release-harvester-v1.4.umd.min.js"
	ContainerdRegistrySettingName                     = "containerd-registry"
	HarvesterCSICCMSettingName                        = "harvester-csi-ccm-versions"
	StorageNetworkName                                = "storage-network"
	DefaultVMTerminationGracePeriodSecondsSettingName = "default-vm-termination-grace-period-seconds"
	SupportBundleExpirationSettingName                = "support-bundle-expiration"
	NTPServersSettingName                             = "ntp-servers"
	AutoRotateRKE2CertsSettingName                    = "auto-rotate-rke2-certs"
	KubeconfigDefaultTokenTTLMinutesSettingName       = "kubeconfig-default-token-ttl-minutes"
	SupportBundleNodeCollectionTimeoutName            = "support-bundle-node-collection-timeout"
	UpgradeConfigSettingName                          = "upgrade-config"
	LonghornV2DataEngineSettingName                   = "longhorn-v2-data-engine-enabled"
	LogLevelSettingName                               = "log-level"
	AdditionalGuestMemoryOverheadRatioName            = "additional-guest-memory-overhead-ratio"

	// settings have `default` and `value` string used in many places, replace them with const
	KeywordDefault = "default"
	KeywordValue   = "value"
)
View Source
const (
	AdditionalGuestMemoryOverheadRatioMinValue = 1.0
	AdditionalGuestMemoryOverheadRatioMaxValue = 10.0 // when ratio is 10.0, the overhead is about 2.5 Gi, should be enough for most cases

	AdditionalGuestMemoryOverheadRatioDefault = "1.5" // After kubevirt computes the overhead, it will further multiple with this factor
)

Variables

View Source
var (
	InjectDefaults string

	AdditionalCA                           = NewSetting(AdditionalCASettingName, "")
	APIUIVersion                           = NewSetting("api-ui-version", "1.1.9") // Please update the HARVESTER_API_UI_VERSION in package/Dockerfile when updating the version here.
	ClusterRegistrationURL                 = NewSetting("cluster-registration-url", "")
	ServerVersion                          = NewSetting("server-version", "dev")
	UIIndex                                = NewSetting(UIIndexSettingName, DefaultDashboardUIURL)
	UIPath                                 = NewSetting(UIPathSettingName, "/usr/share/harvester/harvester")
	UISource                               = NewSetting(UISourceSettingName, "auto") // Options are 'auto', 'external' or 'bundled'
	UIPluginIndex                          = NewSetting(UIPluginIndexSettingName, DefaultUIPluginURL)
	VolumeSnapshotClass                    = NewSetting(VolumeSnapshotClassSettingName, "longhorn")
	BackupTargetSet                        = NewSetting(BackupTargetSettingName, "")
	UpgradableVersions                     = NewSetting("upgradable-versions", "")
	UpgradeCheckerEnabled                  = NewSetting("upgrade-checker-enabled", "true")
	UpgradeCheckerURL                      = NewSetting("upgrade-checker-url", "https://harvester-upgrade-responder.rancher.io/v1/checkupgrade")
	ReleaseDownloadURL                     = NewSetting("release-download-url", "https://releases.rancher.com/harvester")
	LogLevel                               = NewSetting(LogLevelSettingName, "info") // options are info, debug and trace
	SSLCertificates                        = NewSetting(SSLCertificatesSettingName, "{}")
	SSLParameters                          = NewSetting(SSLParametersName, "{}")
	SupportBundleImage                     = NewSetting(SupportBundleImageName, "{}")
	SupportBundleNamespaces                = NewSetting("support-bundle-namespaces", "")
	SupportBundleTimeout                   = NewSetting(SupportBundleTimeoutSettingName, "10")                                                                  // Unit is minute. 0 means disable timeout.
	SupportBundleExpiration                = NewSetting(SupportBundleExpirationSettingName, supportBundleUtil.SupportBundleExpirationDefaultStr)                // Unit is minute.
	SupportBundleNodeCollectionTimeout     = NewSetting(SupportBundleNodeCollectionTimeoutName, supportBundleUtil.SupportBundleNodeCollectionTimeoutDefaultStr) // Unit is minute.
	DefaultStorageClass                    = NewSetting("default-storage-class", "longhorn")
	HTTPProxy                              = NewSetting(HTTPProxySettingName, "{}")
	VMForceResetPolicySet                  = NewSetting(VMForceResetPolicySettingName, InitVMForceResetPolicy())
	OvercommitConfig                       = NewSetting(OvercommitConfigSettingName, `{"cpu":1600,"memory":150,"storage":200}`)
	VipPools                               = NewSetting(VipPoolsConfigSettingName, "")
	AutoDiskProvisionPaths                 = NewSetting("auto-disk-provision-paths", "")
	CSIDriverConfig                        = NewSetting(CSIDriverConfigSettingName, `{"driver.longhorn.io":{"volumeSnapshotClassName":"longhorn-snapshot","backupVolumeSnapshotClassName":"longhorn"}}`)
	ContainerdRegistry                     = NewSetting(ContainerdRegistrySettingName, "")
	StorageNetwork                         = NewSetting(StorageNetworkName, "")
	DefaultVMTerminationGracePeriodSeconds = NewSetting(DefaultVMTerminationGracePeriodSecondsSettingName, "120")
	AutoRotateRKE2CertsSet                 = NewSetting(AutoRotateRKE2CertsSettingName, InitAutoRotateRKE2Certs())
	KubeconfigTTL                          = NewSetting(KubeconfigDefaultTokenTTLMinutesSettingName, "0") // "0" is default value to ensure token does not expire
	LonghornV2DataEngineEnabled            = NewSetting(LonghornV2DataEngineSettingName, "false")
	AdditionalGuestMemoryOverheadRatio     = NewSetting(AdditionalGuestMemoryOverheadRatioName, AdditionalGuestMemoryOverheadRatioDefault)
	// HarvesterCSICCMVersion this is the chart version from https://github.com/harvester/charts instead of image versions
	HarvesterCSICCMVersion = NewSetting(HarvesterCSICCMSettingName, `{"harvester-cloud-provider":">=0.0.1 <0.3.0","harvester-csi-provider":">=0.0.1 <0.3.0"}`)
	NTPServers             = NewSetting(NTPServersSettingName, "")
	WhiteListedSettings    = []string{"server-version", "default-storage-class", "harvester-csi-ccm-versions", "default-vm-termination-grace-period-seconds"}
	UpgradeConfigSet       = NewSetting(UpgradeConfigSettingName, `{"imagePreloadOption":{"strategy":{"type":"sequential"}}, "restoreVM": false}`)
)

Functions

func DecodeConfig added in v1.4.0

func DecodeConfig[T any](value string) (*T, error)

func GetEnvDefaultValueKey added in v1.4.0

func GetEnvDefaultValueKey(key string) string

func GetEnvKey

func GetEnvKey(key string) string

func InitAutoRotateRKE2Certs added in v1.3.0

func InitAutoRotateRKE2Certs() string

func InitBackupTargetToString

func InitBackupTargetToString() string

func InitVMForceResetPolicy added in v1.0.0

func InitVMForceResetPolicy() string

func IsRelease

func IsRelease() bool

func SetProvider

func SetProvider(p Provider) error

func ValidateAdditionalGuestMemoryOverheadRatioHelper added in v1.4.0

func ValidateAdditionalGuestMemoryOverheadRatioHelper(value string) error

Types

type AdditionalGuestMemoryOverheadRatioConfig added in v1.4.0

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

func NewAdditionalGuestMemoryOverheadRatioConfig added in v1.4.0

func NewAdditionalGuestMemoryOverheadRatioConfig(value string) (*AdditionalGuestMemoryOverheadRatioConfig, error)

func (*AdditionalGuestMemoryOverheadRatioConfig) IsEmpty added in v1.4.0

this setting is cleared when: value field "0" or "0.0" value & default fields are both empty

func (*AdditionalGuestMemoryOverheadRatioConfig) Ratio added in v1.4.0

func (*AdditionalGuestMemoryOverheadRatioConfig) Value added in v1.4.0

type AutoRotateRKE2Certs added in v1.3.0

type AutoRotateRKE2Certs struct {
	Enable          bool `json:"enable"`
	ExpiringInHours int  `json:"expiringInHours"`
}

type BackupTarget

type BackupTarget struct {
	Type               TargetType `json:"type"`
	Endpoint           string     `json:"endpoint"`
	AccessKeyID        string     `json:"accessKeyId"`
	SecretAccessKey    string     `json:"secretAccessKey"`
	BucketName         string     `json:"bucketName"`
	BucketRegion       string     `json:"bucketRegion"`
	Cert               string     `json:"cert"`
	VirtualHostedStyle bool       `json:"virtualHostedStyle"`
}

func DecodeBackupTarget added in v1.0.0

func DecodeBackupTarget(value string) (*BackupTarget, error)

func (*BackupTarget) IsDefaultBackupTarget added in v1.0.0

func (target *BackupTarget) IsDefaultBackupTarget() bool

type CSIDriverInfo added in v1.1.0

type CSIDriverInfo struct {
	VolumeSnapshotClassName       string `json:"volumeSnapshotClassName"`
	BackupVolumeSnapshotClassName string `json:"backupVolumeSnapshotClassName"`
}

func GetCSIDriverInfo added in v1.1.0

func GetCSIDriverInfo(provisioner string) (*CSIDriverInfo, error)

type Image added in v1.0.1

type Image struct {
	Repository      string            `json:"repository"`
	Tag             interface{}       `json:"tag"`
	ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy"`
}

func (Image) GetTag added in v1.2.2

func (i Image) GetTag() string

GetTag gets correct format tag from Chart.Values The tag might be "v12.2", 12.2 and "12.2" etc. So we need to convert it in the case.

func (Image) ImageName added in v1.2.2

func (i Image) ImageName() string

type ImagePreloadOption added in v1.4.0

type ImagePreloadOption struct {
	// PreloadStrategy tweaks the way images are preloaded.
	Strategy PreloadStrategy `json:"strategy,omitempty"`
}

type Overcommit added in v1.0.0

type Overcommit struct {
	CPU     int `json:"cpu"`
	Memory  int `json:"memory"`
	Storage int `json:"storage"`
}

type PreloadStrategy added in v1.4.0

type PreloadStrategy struct {
	Type StrategyType `json:"type,omitempty"`

	// Concurrency only takes effect when ParallelType is specified. Default to
	// 0, which means "full scale." Any value higher than the number of the
	// cluster nodes will be treated as 0; values lower than 0 will be rejected
	// by the validator.
	Concurrency int `json:"concurrency,omitempty"`
}

type Provider

type Provider interface {
	Get(name string) string
	Set(name, value string) error
	SetIfUnset(name, value string) error
	SetAll(settings map[string]Setting) error
}

type SSLCertificate added in v1.0.0

type SSLCertificate struct {
	CA                string `json:"ca"`
	PublicCertificate string `json:"publicCertificate"`
	PrivateKey        string `json:"privateKey"`
}

type SSLParameter added in v1.0.0

type SSLParameter struct {
	Protocols string `json:"protocols"`
	Ciphers   string `json:"ciphers"`
}

type Setting

type Setting struct {
	Name     string
	Default  string
	ReadOnly bool
}

func NewSetting

func NewSetting(name, def string) Setting

func (Setting) Get

func (s Setting) Get() string

func (Setting) GetInt

func (s Setting) GetInt() int

func (Setting) Set

func (s Setting) Set(value string) error

func (Setting) SetIfUnset

func (s Setting) SetIfUnset(value string) error

type StrategyType added in v1.4.0

type StrategyType string
const (
	// Do no preloading
	SkipType StrategyType = "skip"

	// Preloading one node at a time
	SequentialType StrategyType = "sequential"

	// Preloading multiple nodes starts at the same time
	ParallelType StrategyType = "parallel"
)

type TargetType

type TargetType string
const (
	S3BackupType  TargetType = "s3"
	NFSBackupType TargetType = "nfs"
)

type UpgradeConfig added in v1.4.0

type UpgradeConfig struct {
	// Options for the Image Preload phase of Harvester Upgrade
	PreloadOption ImagePreloadOption `json:"imagePreloadOption,omitempty"`
	// set true to restore vm to the pre-upgrade state, this option only works under single node.
	RestoreVM bool `json:"restoreVM,omitempty"`
}

type VMForceResetPolicy added in v1.0.0

type VMForceResetPolicy struct {
	Enable bool `json:"enable"`
	// Period means how many seconds to wait for a node get back.
	Period int64 `json:"period"`
}

func DecodeVMForceResetPolicy added in v1.0.0

func DecodeVMForceResetPolicy(value string) (*VMForceResetPolicy, error)

Jump to

Keyboard shortcuts

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