build

package
v0.61.2 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2025 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MustSkipRuntimeValidation bool

MustSkipRuntimeValidation defines whether runtime object validation must be skipped the most usual case for it, if webhook validation is configured

Functions

func AddConfigReloadAuthKeyToApp added in v0.57.0

func AddConfigReloadAuthKeyToApp(container *corev1.Container, extraArgs map[string]string, spec *vmv1beta1.CommonConfigReloaderParams)

AddConfigReloadAuthKeyToApp adds authKey env var to the given application container

func AddConfigReloadAuthKeyToReloader added in v0.57.0

func AddConfigReloadAuthKeyToReloader(container *corev1.Container, spec *vmv1beta1.CommonConfigReloaderParams)

AddConfigReloadAuthKeyToReloader adds authKey env var to the given config-reloader container

func AddConfigReloadAuthKeyVolume added in v0.57.0

func AddConfigReloadAuthKeyVolume(dst []corev1.Volume, spec *vmv1beta1.CommonConfigReloaderParams) []corev1.Volume

AddConfigReloadAuthKeyVolume conditionally adds volume with config reload auth secret

func AddDefaults added in v0.48.0

func AddDefaults(scheme *runtime.Scheme)

AddDefaults adds defaulting functions to the runtimeScheme

func AddExtraArgsOverrideDefaults

func AddExtraArgsOverrideDefaults(args []string, extraArgs map[string]string, dashes string) []string

AddExtraArgsOverrideDefaults adds extraArgs for given source args it trims in-place args if it was set via extraArgs no need to check for extraEnvs, it has priority over args at VictoriaMetrics apps dashes is either "-" or "--", depending on the process. alertmanager needs two dashes.

func AddServiceAccountTokenVolume added in v0.54.0

func AddServiceAccountTokenVolume(dst []corev1.Volume, params *vmv1beta1.CommonApplicationDeploymentParams) []corev1.Volume

AddServiceAccountTokenVolume conditionally adds volume "kube-api-access" with ServiceAccountToken projection

func AddServiceAccountTokenVolumeMount added in v0.54.0

func AddServiceAccountTokenVolumeMount(dst *corev1.Container, params *vmv1beta1.CommonApplicationDeploymentParams)

AddServiceAccountTokenVolumeMount conditionally adds volumeMount to the provided container if DisableAutomountServiceAccountToken is set

func AddStrictSecuritySettingsToContainers

func AddStrictSecuritySettingsToContainers(p *vmv1beta1.SecurityContext, containers []corev1.Container, enableStrictSecurity bool)

AddStrictSecuritySettingsToContainers conditionally adds Security settings to given containers

func AddStrictSecuritySettingsToPod

func AddStrictSecuritySettingsToPod(p *vmv1beta1.SecurityContext, enableStrictSecurity bool) *corev1.PodSecurityContext

AddStrictSecuritySettingsToPod conditionally creates security context for pod or returns predefined one

func AddSyslogArgsTo added in v0.61.0

func AddSyslogArgsTo(dst []string, syslogSpec *vmv1.SyslogServerSpec, tlsServerConfigMountPath string) []string

AddSyslogArgsTo adds syslog flag args into provided dst

func AddSyslogPortsTo added in v0.61.0

func AddSyslogPortsTo(dst []corev1.ContainerPort, syslogSpec *vmv1.SyslogServerSpec) []corev1.ContainerPort

AddSyslogPortsTo adds syslog ports into provided dst

func AddSyslogPortsToService added in v0.61.0

func AddSyslogPortsToService(svc *corev1.Service, syslogSpec *vmv1.SyslogServerSpec)

AddSyslogPortsToService adds syslog ports to the provided service

func AddSyslogTLSConfigToVolumes added in v0.61.0

func AddSyslogTLSConfigToVolumes(dstVolumes []corev1.Volume, dstMounts []corev1.VolumeMount, syslogSpec *vmv1.SyslogServerSpec, tlsServerConfigMountPath string) ([]corev1.Volume, []corev1.VolumeMount)

AddSyslogTLSConfigToVolumes adds syslog tlsConfig volumes and mounts to the provided dsts

func AdditionalServiceFromDefault

func AdditionalServiceFromDefault(defaultSvc *corev1.Service, svcSpec *vmv1beta1.AdditionalServiceSpec) *corev1.Service

AdditionalServiceFromDefault builds service from given exist service and overrides params if needed

func AddsPortProbesToConfigReloaderContainer

func AddsPortProbesToConfigReloaderContainer(useVMConfigReloader bool, crContainer *corev1.Container)

AddsPortProbesToConfigReloaderContainer conditionally adds readiness and liveness probes to the custom config-reloader image exposes reloader-http port for container

func AppendArgsForInsertPorts

func AppendArgsForInsertPorts(args []string, ip *vmv1beta1.InsertPorts) []string

AppendArgsForInsertPorts conditionally appends insert ports as flags to the given args

func AppendFlagsToArgs added in v0.61.0

func AppendFlagsToArgs(args []string, total int, fss ...*Flag) []string

func AppendInsertPorts

func AppendInsertPorts(ports []corev1.ContainerPort, ip *vmv1beta1.InsertPorts) []corev1.ContainerPort

AppendInsertPorts conditionally adds ingestPorts to the given ports slice

func AppendInsertPortsToService

func AppendInsertPortsToService(ip *vmv1beta1.InsertPorts, svc *corev1.Service)

AppendInsertPortsToService conditionally appends insert ports to the given service definition

func DaemonSetAddCommonParams added in v0.55.0

func DaemonSetAddCommonParams(dst *appsv1.DaemonSet, useStrictSecurity bool, params *vmv1beta1.CommonApplicationDeploymentParams)

DeploymentAddCommonParams adds common params for all deployments

func DeploymentAddCommonParams added in v0.48.0

func DeploymentAddCommonParams(dst *appsv1.Deployment, useStrictSecurity bool, params *vmv1beta1.CommonApplicationDeploymentParams)

DeploymentAddCommonParams adds common params for all deployments

func HPA

HPA creates HorizontalPodAutoscaler object

func IsNotFound added in v0.60.0

func IsNotFound(err error) bool

IsNotFound performs a check if provided error is KeyNotFoundError

func LicenseArgsTo added in v0.60.0

func LicenseArgsTo(args []string, l *vmv1beta1.License, secretMountDir string) []string

LicenseArgsTo conditionally adds license commandline args into given args

func LicenseDoubleDashArgsTo added in v0.60.0

func LicenseDoubleDashArgsTo(args []string, l *vmv1beta1.License, secretMountDir string) []string

LicenseDoubleDashArgsTo conditionally adds double-dash license commandline args into given args

func LicenseVolumeTo added in v0.60.0

func LicenseVolumeTo(volumes []corev1.Volume, mounts []corev1.VolumeMount, l *vmv1beta1.License, secretMountDir string) ([]corev1.Volume, []corev1.VolumeMount)

LicenseVolumeTo conditionally mounts secret with license key into given volumes and volume mounts

func OrderByKeys added in v0.60.0

func OrderByKeys[T any](target []T, sorter []string)

OrderByKeys orders targets slice according sorter slice sorting result

func PodDNSAddress added in v0.51.0

func PodDNSAddress(baseName string, podIndex int32, namespace string, portName string, domain string) string

PodDNSAddress formats pod dns address with optional domain name

func PodDisruptionBudget

func PodDisruptionBudget(cr builderOpts, spec *vmv1beta1.EmbeddedPodDisruptionBudgetSpec) *policyv1.PodDisruptionBudget

PodDisruptionBudget creates object for given CRD

func Probe

func Probe(container corev1.Container, cr probeCRD) corev1.Container

Probe builds probe for container with possible custom values with

func ResourceMeta added in v0.60.0

func ResourceMeta(kind ResourceKind, cr builderOpts) metav1.ObjectMeta

ResourceMeta return kubernetes metadata object for given kind and cr

func ResourceName added in v0.60.0

func ResourceName(kind ResourceKind, cr builderOpts) string

ResourceName returns a name for provided resource and corresponding cr object

func Resources

func Resources(crdResources corev1.ResourceRequirements, defaultResources config.Resource, useDefault bool) corev1.ResourceRequirements

Resources creates container resources with conditional defaults values

func Service

func Service(cr builderOpts, defaultPort string, setOptions func(svc *corev1.Service)) *corev1.Service

Service builds service for the given args and applies optional callback for it

func ServiceAccount

func ServiceAccount(cr objectForServiceAccountBuilder) *corev1.ServiceAccount

ServiceAccount builds service account for CRD

func SetSkipRuntimeValidation added in v0.54.0

func SetSkipRuntimeValidation(mustSkip bool)

SetSkipRuntimeValidation configures MustSkipRuntimeValidation param

func SetSpaceTrim added in v0.60.0

func SetSpaceTrim(disabled bool)

SetSpaceTrim configures option to trim space at Secret/ConfigMap keys

Must called before any method from cache.go file could be used

func StatefulSetAddCommonParams added in v0.48.0

func StatefulSetAddCommonParams(dst *appsv1.StatefulSet, useStrictSecurity bool, params *vmv1beta1.CommonApplicationDeploymentParams)

StatefulSetAddCommonParams adds common params to given statefulset

func StreamAggrArgsTo added in v0.61.0

func StreamAggrArgsTo(args []string, prefix string, keys []string, cs ...*vmv1beta1.StreamAggrConfig) []string

StreamAggrArgsTo conditionally adds stream aggregation commandline args into given args

func StreamAggrVolumeTo added in v0.61.0

func StreamAggrVolumeTo(volumes []corev1.Volume, mounts []corev1.VolumeMount, cr streamAggrOpts) ([]corev1.Volume, []corev1.VolumeMount)

StreamAggrVolumeTo conditionally mounts configmap with stream aggregation config into given volumes and volume mounts

func VMBackupManager

func VMBackupManager(
	ctx context.Context,
	cr *vmv1beta1.VMBackup,
	port string,
	storagePath, dataVolumeName string,
	extraArgs map[string]string,
	isCluster bool,
	license *vmv1beta1.License,
) (*corev1.Container, error)

VMBackupManager conditionally creates vmbackupmanager container

func VMPodScrapeForObjectWithSpec added in v0.55.0

func VMPodScrapeForObjectWithSpec(psb podScrapeBuilder, serviceScrapeSpec *vmv1beta1.VMServiceScrapeSpec, extraArgs map[string]string) *vmv1beta1.VMPodScrape

VMPodScrapeForObjectWithSpec build VMPodScrape for given podScrapeBuilder with provided args optionally could filter out ports from service

func VMRestore

func VMRestore(
	cr *vmv1beta1.VMBackup,
	storagePath, dataVolumeName string,
) (*corev1.Container, error)

VMRestore conditionally creates vmrestore container

func VMServiceScrapeForAlertmanager added in v0.47.0

func VMServiceScrapeForAlertmanager(service *corev1.Service, amCR *vmv1beta1.VMAlertmanager) *vmv1beta1.VMServiceScrape

VMServiceScrapeForServiceWithSpec build VMServiceScrape for VMAlertmanager

func VMServiceScrapeForServiceWithSpec

func VMServiceScrapeForServiceWithSpec(service *corev1.Service, builder serviceScrapeBuilder, additionalPortNames ...string) *vmv1beta1.VMServiceScrape

VMServiceScrapeForServiceWithSpec creates corresponding object with `http` port endpoint obtained from given service add additionalPortNames to the monitoring if needed

Types

type AssetsCache added in v0.60.0

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

AssetsCache is a shared cache for all CR assets that stores configmaps and secrets during reconcile loop

It's mostly needed to reduce pressure on Kubernetes API server because by default, operator disables client.Cache for those objects. Since it greatly increases memory usage.

func NewAssetsCache added in v0.60.0

func NewAssetsCache(ctx context.Context, client client.Client, cfg map[ResourceKind]*ResourceCfg) *AssetsCache

NewAssetsCache returns a new cache instance

func (*AssetsCache) AuthorizationToYAML added in v0.60.0

func (ac *AssetsCache) AuthorizationToYAML(ns string, cfg *vmv1beta1.Authorization) (yaml.MapSlice, error)

AuthorizationToYAML returns yaml representation of provided Authorization config Please note all secret values will be added as a plain text to it.

func (*AssetsCache) BasicAuthToYAML added in v0.60.0

func (ac *AssetsCache) BasicAuthToYAML(ns string, cfg *vmv1beta1.BasicAuth) (yaml.MapSlice, error)

BasicAuthToYAML returns yaml representation of provided BasicAuth configuration Please note all secret values will be added as a plain text to it.

func (*AssetsCache) BuildBasicAuthCreds added in v0.60.0

func (ac *AssetsCache) BuildBasicAuthCreds(ns string, cfg *vmv1beta1.BasicAuth) (*BasicAuthCreds, error)

BuildBasicAuthCreds fetches basic auth credentials object by given secret selectors

func (*AssetsCache) BuildTLSCreds added in v0.60.0

func (ac *AssetsCache) BuildTLSCreds(ns string, cfg *vmv1beta1.TLSConfig) (*TLSCreds, error)

BuildTLSCreds fetches content of provided TLSConfig Returns an object with paths to the fetched secret values mounted on disk

func (*AssetsCache) GetOutput added in v0.60.0

func (ac *AssetsCache) GetOutput() map[ResourceKind]corev1.Secret

GetOutput returns Secret objects with cached content of fetched secrets grouped by ResourceKind

func (*AssetsCache) LoadKeyFromConfigMap added in v0.60.0

func (ac *AssetsCache) LoadKeyFromConfigMap(ns string, cs *corev1.ConfigMapKeySelector) (string, error)

LoadKeyFromConfigMap fetches content of configmap by given selector and namespace

func (*AssetsCache) LoadKeyFromSecret added in v0.60.0

func (ac *AssetsCache) LoadKeyFromSecret(ns string, ss *corev1.SecretKeySelector) (string, error)

LoadKeyFromSecret fetch content of secret by given selector and namespace returns plain text secret value

func (*AssetsCache) LoadKeyFromSecretOrConfigMap added in v0.60.0

func (ac *AssetsCache) LoadKeyFromSecretOrConfigMap(ns string, soc *vmv1beta1.SecretOrConfigMap) (string, error)

LoadKeyFromSecretOrConfigMap fetches content of secret or configmap by given selector and namespace returns plain text value

func (*AssetsCache) LoadPathFromSecret added in v0.60.0

func (ac *AssetsCache) LoadPathFromSecret(kind ResourceKind, ns string, ss *corev1.SecretKeySelector) (string, error)

LoadPathFromSecret loads content of the secret by given selector and namespace returns path to the secret content file mounted on pod volume

func (*AssetsCache) LoadPathFromSecretOrConfigMap added in v0.60.0

func (ac *AssetsCache) LoadPathFromSecretOrConfigMap(kind ResourceKind, ns string, soc *vmv1beta1.SecretOrConfigMap) (string, error)

LoadPathFromSecretOrConfigMap fetches content of the configmap by given selector and namespace returns path to the configmap content file mounted on pod volume

func (*AssetsCache) LoadSecret added in v0.60.0

func (ac *AssetsCache) LoadSecret(ns, name string) (*corev1.Secret, error)

LoadSecret returns secret object by given namespace and name

func (*AssetsCache) OAuth2ToYAML added in v0.60.0

func (ac *AssetsCache) OAuth2ToYAML(ns string, cfg *vmv1beta1.OAuth2) (yaml.MapSlice, error)

OAuth2ToYAML returns yaml representation of provided oauth2 configuration Please note all secret values will be added as a plain text to it.

func (*AssetsCache) ProxyAuthToYAML added in v0.60.0

func (ac *AssetsCache) ProxyAuthToYAML(ns string, cfg *vmv1beta1.ProxyAuth) (yaml.MapSlice, error)

ProxyAuthToYAML returns yaml representation of provided ProxyAuth config Please note all secret values will be added as a plain text to it.

func (*AssetsCache) TLSToYAML added in v0.60.0

func (ac *AssetsCache) TLSToYAML(ns, prefix string, cfg *vmv1beta1.TLSConfig) (yaml.MapSlice, error)

TLSToYAML returns yaml representation of provided TLSConfig config Please note all secret values will be added as a plain text to it.

func (*AssetsCache) VolumeTo added in v0.60.0

func (ac *AssetsCache) VolumeTo(volumes []corev1.Volume, mounts []corev1.VolumeMount) ([]corev1.Volume, []corev1.VolumeMount)

VolumeTo adds volumes and volume Mounts to the provided destinations

type BasicAuthCreds added in v0.60.0

type BasicAuthCreds struct {
	Username string
	Password string
}

BasicAuthCreds defines basic auth credentials object

type Flag added in v0.61.0

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

func NewEmptyFlag added in v0.61.0

func NewEmptyFlag(name string) *Flag

NewEmptyFlag builds Flag with empty string default value

func NewFlag added in v0.61.0

func NewFlag(name, empty string) *Flag

func (*Flag) Add added in v0.61.0

func (f *Flag) Add(value string, idx int)

func (*Flag) IsSet added in v0.61.0

func (f *Flag) IsSet() bool

type KeyNotFoundError added in v0.60.0

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

KeyNotFoundError represents an error if expected key was not found at secret or configmap data

func (*KeyNotFoundError) Error added in v0.60.0

func (ke *KeyNotFoundError) Error() string

Error implements errors.Error interface

type ResourceCfg added in v0.60.0

type ResourceCfg struct {
	MountDir   string
	SecretName string
}

type ResourceKind added in v0.60.0

type ResourceKind string

ResourceKind defines a type of resource to perform build operations on

const (
	// TLSAssetsResourceKind defines build type for tls configuration assets
	TLSAssetsResourceKind ResourceKind = "tls-assets"
	// SecretConfigResourceKind defines build for configuration secret object
	SecretConfigResourceKind ResourceKind = "config"
	// StreamAggrConfigResourceKind defines build for stream aggregation configmap object
	StreamAggrConfigResourceKind ResourceKind = "stream-aggr"
)

type TLSCreds added in v0.60.0

type TLSCreds struct {
	CAFile   string
	CertFile string
	KeyFile  string
}

TLSCreds defines TLS configuration object file paths

Jump to

Keyboard shortcuts

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