webhook

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// InjectionInstanceLabel can be set in a Namespace and indicates the corresponding DynaKube object assigned to it.
	InjectionInstanceLabel = "dynakube.internal.dynatrace.com/instance"

	// AnnotationDynatraceInjected is set to "true" by the webhook to Pods to indicate that it has been injected.
	AnnotationDynatraceInjected = "dynakube.dynatrace.com/injected"

	// AnnotationDynatraceInject is set to "false" on the Pod to indicate that does not want any injection.
	AnnotationDynatraceInject = "dynatrace.com/inject"

	OneAgentPrefix = "oneagent"
	// AnnotationOneAgentInject can be set at pod level to enable/disable OneAgent injection.
	AnnotationOneAgentInject   = OneAgentPrefix + ".dynatrace.com/inject"
	AnnotationOneAgentInjected = OneAgentPrefix + ".dynatrace.com/injected"
	AnnotationOneAgentReason   = OneAgentPrefix + ".dynatrace.com/reason"

	EmptyConnectionInfoReason = "EmptyConnectionInfo"

	MetadataEnrichmentPrefix = "metrics-enrichment"
	// AnnotationMetadataEnrichmentInject can be set at pod level to enable/disable metadata-enrichment injection.
	AnnotationMetadataEnrichmentInject   = MetadataEnrichmentPrefix + ".dynatrace.com/inject"
	AnnotationMetadataEnrichmentInjected = MetadataEnrichmentPrefix + ".dynatrace.com/injected"

	// AnnotationFlavor can be set on a Pod to configure which code modules flavor to download. It's set to "default"
	// if not set.
	AnnotationFlavor = "oneagent.dynatrace.com/flavor"

	// AnnotationTechnologies can be set on a Pod to configure which code module technologies to download. It's set to
	// "all" if not set.
	AnnotationTechnologies = "oneagent.dynatrace.com/technologies"

	// AnnotationInstallPath can be set on a Pod to configure on which directory the OneAgent will be available from,
	// defaults to DefaultInstallPath if not set.
	AnnotationInstallPath = "oneagent.dynatrace.com/install-path"

	// AnnotationInstallerUrl can be set on a Pod to configure the installer url for downloading the agent
	// defaults to the PaaS installer download url of your tenant
	AnnotationInstallerUrl = "oneagent.dynatrace.com/installer-url"

	// AnnotationFailurePolicy can be set on a Pod to control what the init container does on failures. When set to
	// "fail", the init container will exit with error code 1. Defaults to "silent".
	AnnotationFailurePolicy = "oneagent.dynatrace.com/failure-policy"

	AnnotationContainerInjection = "container.inject.dynatrace.com"

	// DefaultInstallPath is the default directory to install the app-only OneAgent package.
	DefaultInstallPath = "/opt/dynatrace/oneagent-paas"

	// SecretCertsName is the name of the secret where the webhook certificates are stored.
	SecretCertsName = "dynatrace-webhook-certs"

	// DeploymentName is the name used for the Deployment of any webhooks and WebhookConfiguration objects.
	DeploymentName = "dynatrace-webhook"

	WebhookContainerName = "webhook"

	// InstallContainerName is the name used for the install container
	InstallContainerName = "install-oneagent"

	// AnnotationWorkloadKind is added to any injected pods when the metadata-enrichment feature is enabled
	AnnotationWorkloadKind = "metadata.dynatrace.com/k8s.workload.kind"
	// AnnotationWorkloadName is added to any injected pods when the metadata-enrichment feature is enabled
	AnnotationWorkloadName = "metadata.dynatrace.com/k8s.workload.name"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseRequest

type BaseRequest struct {
	Pod       *corev1.Pod
	Namespace corev1.Namespace
	DynaKube  dynatracev1beta1.DynaKube
}

BaseRequest is the base request for all mutation requests

func (BaseRequest) PodName

func (req BaseRequest) PodName() string

type MutationRequest

type MutationRequest struct {
	*BaseRequest
	Context          context.Context
	InstallContainer *corev1.Container
}

MutationRequest contains all the information needed to mutate a pod It is meant to be passed into each mutator, so that they can mutate the elements in the way they need to, and after passing it in to all the mutator the request will have the final state which can be used to mutate the pod.

func NewMutationRequest

func NewMutationRequest(ctx context.Context, namespace corev1.Namespace, installContainer *corev1.Container, pod *corev1.Pod, dynakube dynatracev1beta1.DynaKube) *MutationRequest

func (*MutationRequest) ToReinvocationRequest

func (request *MutationRequest) ToReinvocationRequest() *ReinvocationRequest

type PodMutator

type PodMutator interface {
	// Enabled returns true if the mutator needs to be executed for the given request.
	// This is used to filter out mutators that are not needed for the given request.
	Enabled(request *BaseRequest) bool

	// Injected returns true if the mutator has already injected into the pod of the given request.
	// This is used during reinvocation to prevent multiple injections.
	Injected(request *BaseRequest) bool

	// Mutate mutates the elements of the given MutationRequest, specifically the pod and installContainer.
	Mutate(ctx context.Context, request *MutationRequest) error

	// Reinvocation mutates the pod of the given ReinvocationRequest.
	// It only mutates the parts of the pod that haven't been mutated yet. (example: another webhook mutated the pod after our webhook was executed)
	Reinvoke(request *ReinvocationRequest) bool
}

type ReinvocationRequest

type ReinvocationRequest struct {
	*BaseRequest
}

ReinvocationRequest contains all the information needed to reinvoke a pod It is meant to be passed into each mutator, so that they can mutate the elements in the way they need to, and after passing it in to all the mutator the request will have the final state which can be used to mutate the pod.

Directories

Path Synopsis
internal
mutation
pod

Jump to

Keyboard shortcuts

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