podspec

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultTerminationGracePeriodSeconds is the termination grace period for the Elasalert containers
	DefaultTerminationGracePeriodSeconds int64 = 10
	DefaultElastAlertName                      = "elastalert"
	DefautlImage                               = "toughnoah/elastalert:v1.0"
	DefaultCertVolumeName                      = "elasticsearch-cert"
	DefaultCertSuffix                          = "-es-cert"
	DefaultCertMountPath                       = "/ssl"
	DefaultElasticCertName                     = "elasticCA.crt"
	DefaultRulesFolder                         = "/etc/elastalert/rules/..data/"
	DefaultElasticCertPath                     = "/ssl/elasticCA.crt"
)

Variables

View Source
var (
	DefaultMemoryLimits = resource.MustParse("2Gi")
	// DefaultResources for the Elasalert container. The JVM default heap size is 1Gi, so we
	// request at least 2Gi for the container to make sure ES can work properly.
	// Not applying this minimum default would make Elasalert randomly crash (OOM) on small machines.
	// Similarly, we apply a default memory limit of 2Gi, to ensure the Pod isn't the first one to get evicted.
	// No CPU requirement is set by default.
	DefaultResources = corev1.ResourceRequirements{
		Requests: map[corev1.ResourceName]resource.Quantity{
			corev1.ResourceMemory: DefaultMemoryLimits,
		},
		Limits: map[corev1.ResourceName]resource.Quantity{
			corev1.ResourceMemory: DefaultMemoryLimits,
		},
	}
)

Functions

func BuildCertSecret

func BuildCertSecret(e *esv1alpha1.Elastalert) *corev1.Secret

func BuildDeployment

func BuildDeployment(elastalert v1alpha1.Elastalert) *appsv1.Deployment

func BuildPodTemplateSpec

func BuildPodTemplateSpec(elastalert v1alpha1.Elastalert) corev1.PodTemplateSpec

func ConfigMapsToMap

func ConfigMapsToMap(cms []corev1.ConfigMap) map[string]corev1.ConfigMap

func ContainsKeys

func ContainsKeys(m map[string]string, labels ...string) bool

ContainsKeys determines if a set of label (keys) are present in a map of labels (keys and values).

func DefaultAffinity

func DefaultAffinity(esName string) *corev1.Affinity

DefaultAffinity returns the default affinity for pods in a cluster.

func GenerateCertSecret

func GenerateCertSecret(Scheme *runtime.Scheme, e *esv1alpha1.Elastalert) (*corev1.Secret, error)

func GenerateNewConfigmap

func GenerateNewConfigmap(Scheme *runtime.Scheme, e *esv1alpha1.Elastalert, suffix string) (*corev1.ConfigMap, error)

func GenerateNewDeployment

func GenerateNewDeployment(Scheme *runtime.Scheme, e *v1alpha1.Elastalert) (*appsv1.Deployment, error)

func GenerateYamlMap

func GenerateYamlMap(ruleArray []esv1alpha1.FreeForm) (map[string]string, error)

func GetDefaultContainerPorts

func GetDefaultContainerPorts() []corev1.ContainerPort

func GetUtcTime

func GetUtcTime() time.Time

func GetUtcTimeString

func GetUtcTimeString() string

func IsSubset

func IsSubset(toCheck, fullSet map[string]string) bool

IsSubset compares two maps to determine if one of them is fully contained in the other.

func Merge

func Merge(dest, src map[string]string) map[string]string

Merge merges source into destination, overwriting existing values if necessary.

func MergeInterfaceMap

func MergeInterfaceMap(dest, src map[string]interface{}) map[string]interface{}

func MergePreservingExistingKeys

func MergePreservingExistingKeys(dest, src map[string]string) map[string]string

MergePreservingExistingKeys merges source into destination while skipping any keys that exist in the destination.

func PatchAlertSettings

func PatchAlertSettings(e *esv1alpha1.Elastalert) error

func PatchConfigSettings

func PatchConfigSettings(e *esv1alpha1.Elastalert, stringCert string) error

PatchConfigSettings TODO should change to Chain Of Responsibility

Types

type AddCertHandler

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

type DefaultRulesFolderHandler

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

type Defaulter

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

Defaulter ensures that values are set if none exists in the base container.

func NewDefaulter

func NewDefaulter(base *corev1.Container) Defaulter

func (Defaulter) Container

func (d Defaulter) Container() corev1.Container

Container returns a copy of the resulting container.

func (Defaulter) From

func (d Defaulter) From(other corev1.Container) Defaulter

From inherits default values from an other container.

func (Defaulter) WithArgs

func (d Defaulter) WithArgs(args []string) Defaulter

func (Defaulter) WithCommand

func (d Defaulter) WithCommand(command []string) Defaulter

func (Defaulter) WithEnv

func (d Defaulter) WithEnv(vars []corev1.EnvVar) Defaulter

func (Defaulter) WithImage

func (d Defaulter) WithImage(image string) Defaulter

WithImage sets up the Container Docker image, unless already provided. The default image will be used unless customImage is not empty.

func (Defaulter) WithLivenessProbe

func (d Defaulter) WithLivenessProbe(LivenessProbe *corev1.Probe) Defaulter

func (Defaulter) WithPorts

func (d Defaulter) WithPorts(ports []corev1.ContainerPort) Defaulter

func (Defaulter) WithPreStopHook

func (d Defaulter) WithPreStopHook(handler *corev1.Handler) Defaulter

func (Defaulter) WithReadinessProbe

func (d Defaulter) WithReadinessProbe(readinessProbe *corev1.Probe) Defaulter

func (Defaulter) WithResources

func (d Defaulter) WithResources(resources corev1.ResourceRequirements) Defaulter

WithResources ensures that resource requirements are set in the container.

func (Defaulter) WithVolumeMounts

func (d Defaulter) WithVolumeMounts(volumeMounts []corev1.VolumeMount) Defaulter

type PodTemplateBuilder

type PodTemplateBuilder struct {
	PodTemplate corev1.PodTemplateSpec
	// contains filtered or unexported fields
}

func NewPodTemplateBuilder

func NewPodTemplateBuilder(base corev1.PodTemplateSpec, containerName string) *PodTemplateBuilder

func (*PodTemplateBuilder) WithAffinity

func (b *PodTemplateBuilder) WithAffinity(affinity *corev1.Affinity) *PodTemplateBuilder

WithAffinity sets a default affinity, unless already provided in the template. An empty affinity in the spec is not overridden.

func (*PodTemplateBuilder) WithAnnotations

func (b *PodTemplateBuilder) WithAnnotations(annotations map[string]string) *PodTemplateBuilder

WithAnnotations sets the given annotations, but does not override those that already exist.

func (*PodTemplateBuilder) WithCommand

func (b *PodTemplateBuilder) WithCommand(command []string) *PodTemplateBuilder

WithCommand sets the given command to the Container, unless already provided in the template.

func (*PodTemplateBuilder) WithDockerImage

func (b *PodTemplateBuilder) WithDockerImage(customImage string, defaultImage string) *PodTemplateBuilder

WithDockerImage sets up the Container Docker image, unless already provided. The default image will be used unless customImage is not empty.

func (*PodTemplateBuilder) WithEnv

func (b *PodTemplateBuilder) WithEnv(vars ...corev1.EnvVar) *PodTemplateBuilder

WithEnv appends the given env vars to the Container, unless already provided in the template.

func (*PodTemplateBuilder) WithInitContainerDefaults

func (b *PodTemplateBuilder) WithInitContainerDefaults(additionalEnvVars ...corev1.EnvVar) *PodTemplateBuilder

WithInitContainerDefaults sets default values for the current init containers.

Defaults:

  • If the init container contains an empty image field, it's inherited from the elastalert container.
  • VolumeMounts from the elastalert container are added to the init container VolumeMounts, unless they would conflict with a specified VolumeMount (by having the same VolumeMount.Name or VolumeMount.MountPath)
  • default environment variables

This method can also be used to set some additional environment variables.

func (*PodTemplateBuilder) WithInitContainers

func (b *PodTemplateBuilder) WithInitContainers(
	initContainers ...corev1.Container,
) *PodTemplateBuilder

WithInitContainers includes the given init containers to the pod template.

Ordering: - Provided init containers are prepended to the existing ones in the template. - If an init container by the same name already exists in the template, the two PodTemplates are merged, the values provided by the user take precedence.

func (*PodTemplateBuilder) WithLabels

func (b *PodTemplateBuilder) WithLabels(labels map[string]string) *PodTemplateBuilder

WithLabels sets the given labels, but does not override those that already exist.

func (*PodTemplateBuilder) WithLivenessProbe

func (b *PodTemplateBuilder) WithLivenessProbe(LivenessProbe corev1.Probe) *PodTemplateBuilder

WithLivenessProbe sets up the given readiness probe, unless already provided in the template.

func (*PodTemplateBuilder) WithPorts

WithPorts appends the given ports to the Container ports, unless already provided in the template.

func (*PodTemplateBuilder) WithPreStopHook

func (b *PodTemplateBuilder) WithPreStopHook(handler corev1.Handler) *PodTemplateBuilder

func (*PodTemplateBuilder) WithReadinessProbe

func (b *PodTemplateBuilder) WithReadinessProbe(readinessProbe corev1.Probe) *PodTemplateBuilder

WithReadinessProbe sets up the given readiness probe, unless already provided in the template.

func (*PodTemplateBuilder) WithResources

WithResources sets up the given resource requirements if both resources limits and requests are nil in the main container. If a zero-value (empty map) for at least one of limits or request is provided, the given resource requirements are not applied: the user may want to use a LimitRange.

func (*PodTemplateBuilder) WithTerminationGracePeriod

func (b *PodTemplateBuilder) WithTerminationGracePeriod(period int64) *PodTemplateBuilder

WithTerminationGracePeriod sets the given termination grace period if not already specified in the template.

func (*PodTemplateBuilder) WithVolumeMounts

func (b *PodTemplateBuilder) WithVolumeMounts(volumeMounts ...corev1.VolumeMount) *PodTemplateBuilder

WithVolumeMounts appends the given volume mounts to the Container, unless already provided in the template.

func (*PodTemplateBuilder) WithVolumes

func (b *PodTemplateBuilder) WithVolumes(volumes ...corev1.Volume) *PodTemplateBuilder

WithVolumes appends the given volumes to the Container, unless already provided in the template.

type RawConfig

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

type UseSSLHandler

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

type VerifyCertHandler

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

Jump to

Keyboard shortcuts

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