webhook

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2025 License: Apache-2.0 Imports: 5 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"

	// 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"

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

	// AnnotationDynatraceReason is add to provide extra info why an injection didn't happen.
	AnnotationDynatraceReason = "dynakube.dynatrace.com/reason"

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

	AnnotationContainerInjection = "container.inject.dynatrace.com"

	// 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 = "dynatrace-operator"
)

Variables

This section is empty.

Functions

func IsContainerExcludedFromInjection added in v1.3.0

func IsContainerExcludedFromInjection(dkAnnotations, podAnnotations map[string]string, name string) bool

Types

type BaseRequest

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

BaseRequest is the base request for all mutation requests

func (*BaseRequest) NewContainers added in v1.3.0

func (req *BaseRequest) NewContainers(isInjected func(corev1.Container) bool) (newContainers []*corev1.Container)

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, dk dynakube.DynaKube) *MutationRequest

func (*MutationRequest) ToReinvocationRequest

func (request *MutationRequest) ToReinvocationRequest() *ReinvocationRequest

type PodInjector added in v1.5.0

type PodInjector interface {
	Handle(context.Context, *MutationRequest) error
}

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.

Jump to

Keyboard shortcuts

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