Documentation ¶
Index ¶
- Constants
- Variables
- func BuildCertSecret(e *esv1alpha1.Elastalert) *corev1.Secret
- func BuildDeployment(elastalert v1alpha1.Elastalert) *appsv1.Deployment
- func BuildPodTemplateSpec(elastalert v1alpha1.Elastalert) corev1.PodTemplateSpec
- func ConfigMapsToMap(cms []corev1.ConfigMap) map[string]corev1.ConfigMap
- func ContainsKeys(m map[string]string, labels ...string) bool
- func DefaultAffinity(esName string) *corev1.Affinity
- func GenerateCertSecret(Scheme *runtime.Scheme, e *esv1alpha1.Elastalert) (*corev1.Secret, error)
- func GenerateNewConfigmap(Scheme *runtime.Scheme, e *esv1alpha1.Elastalert, suffix string) (*corev1.ConfigMap, error)
- func GenerateNewDeployment(Scheme *runtime.Scheme, e *v1alpha1.Elastalert) (*appsv1.Deployment, error)
- func GenerateYamlMap(ruleArray []esv1alpha1.FreeForm) (map[string]string, error)
- func GetDefaultContainerPorts() []corev1.ContainerPort
- func GetUtcTime() time.Time
- func GetUtcTimeString() string
- func IsSubset(toCheck, fullSet map[string]string) bool
- func Merge(dest, src map[string]string) map[string]string
- func MergeInterfaceMap(dest, src map[string]interface{}) map[string]interface{}
- func MergePreservingExistingKeys(dest, src map[string]string) map[string]string
- func PatchAlertSettings(e *esv1alpha1.Elastalert) error
- func PatchConfigSettings(e *esv1alpha1.Elastalert, stringCert string) error
- type AddCertHandler
- type DefaultRulesFolderHandler
- type Defaulter
- func (d Defaulter) Container() corev1.Container
- func (d Defaulter) From(other corev1.Container) Defaulter
- func (d Defaulter) WithArgs(args []string) Defaulter
- func (d Defaulter) WithCommand(command []string) Defaulter
- func (d Defaulter) WithEnv(vars []corev1.EnvVar) Defaulter
- func (d Defaulter) WithImage(image string) Defaulter
- func (d Defaulter) WithLivenessProbe(LivenessProbe *corev1.Probe) Defaulter
- func (d Defaulter) WithPorts(ports []corev1.ContainerPort) Defaulter
- func (d Defaulter) WithPreStopHook(handler *corev1.Handler) Defaulter
- func (d Defaulter) WithReadinessProbe(readinessProbe *corev1.Probe) Defaulter
- func (d Defaulter) WithResources(resources corev1.ResourceRequirements) Defaulter
- func (d Defaulter) WithVolumeMounts(volumeMounts []corev1.VolumeMount) Defaulter
- type PodTemplateBuilder
- func (b *PodTemplateBuilder) WithAffinity(affinity *corev1.Affinity) *PodTemplateBuilder
- func (b *PodTemplateBuilder) WithAnnotations(annotations map[string]string) *PodTemplateBuilder
- func (b *PodTemplateBuilder) WithCommand(command []string) *PodTemplateBuilder
- func (b *PodTemplateBuilder) WithDockerImage(customImage string, defaultImage string) *PodTemplateBuilder
- func (b *PodTemplateBuilder) WithEnv(vars ...corev1.EnvVar) *PodTemplateBuilder
- func (b *PodTemplateBuilder) WithInitContainerDefaults(additionalEnvVars ...corev1.EnvVar) *PodTemplateBuilder
- func (b *PodTemplateBuilder) WithInitContainers(initContainers ...corev1.Container) *PodTemplateBuilder
- func (b *PodTemplateBuilder) WithLabels(labels map[string]string) *PodTemplateBuilder
- func (b *PodTemplateBuilder) WithLivenessProbe(LivenessProbe corev1.Probe) *PodTemplateBuilder
- func (b *PodTemplateBuilder) WithPorts(ports []corev1.ContainerPort) *PodTemplateBuilder
- func (b *PodTemplateBuilder) WithPreStopHook(handler corev1.Handler) *PodTemplateBuilder
- func (b *PodTemplateBuilder) WithReadinessProbe(readinessProbe corev1.Probe) *PodTemplateBuilder
- func (b *PodTemplateBuilder) WithResources(resources corev1.ResourceRequirements) *PodTemplateBuilder
- func (b *PodTemplateBuilder) WithTerminationGracePeriod(period int64) *PodTemplateBuilder
- func (b *PodTemplateBuilder) WithVolumeMounts(volumeMounts ...corev1.VolumeMount) *PodTemplateBuilder
- func (b *PodTemplateBuilder) WithVolumes(volumes ...corev1.Volume) *PodTemplateBuilder
- type RawConfig
- type UseSSLHandler
- type VerifyCertHandler
Constants ¶
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 ¶
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 ContainsKeys ¶
ContainsKeys determines if a set of label (keys) are present in a map of labels (keys and values).
func DefaultAffinity ¶
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 GetUtcTimeString ¶
func GetUtcTimeString() string
func IsSubset ¶
IsSubset compares two maps to determine if one of them is fully contained in the other.
func MergeInterfaceMap ¶
func MergePreservingExistingKeys ¶
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 (Defaulter) WithCommand ¶
func (Defaulter) WithImage ¶
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 (Defaulter) WithPreStopHook ¶
func (Defaulter) WithReadinessProbe ¶
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 ¶
func (b *PodTemplateBuilder) WithPorts(ports []corev1.ContainerPort) *PodTemplateBuilder
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 ¶
func (b *PodTemplateBuilder) WithResources(resources corev1.ResourceRequirements) *PodTemplateBuilder
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 UseSSLHandler ¶
type UseSSLHandler struct {
// contains filtered or unexported fields
}
type VerifyCertHandler ¶
type VerifyCertHandler struct {
// contains filtered or unexported fields
}