From f96cd523b09c14a9f182965ffa86fa70202d990a Mon Sep 17 00:00:00 2001 From: Jacob Aronoff Date: Wed, 11 Oct 2023 12:41:50 -0400 Subject: [PATCH 01/15] lots of moving things around and simplifcation --- controllers/suite_test.go | 3 +- .../webhook/collector/webhook.go | 214 +++++---- .../webhook/collector/webhook_test.go | 439 ++++++++++-------- .../webhook/instrumentation/webhook.go | 257 +++++----- .../webhook/instrumentation/webhook_test.go | 118 ++--- .../sidecar}/webhookhandler.go | 12 +- .../sidecar}/webhookhandler_suite_test.go | 6 +- .../sidecar}/webhookhandler_test.go | 4 +- main.go | 25 +- pkg/collector/reconcile/suite_test.go | 3 +- pkg/collector/upgrade/suite_test.go | 5 +- pkg/instrumentation/podmutator.go | 4 +- pkg/instrumentation/upgrade/upgrade.go | 21 +- pkg/instrumentation/upgrade/upgrade_test.go | 30 +- pkg/sidecar/podmutator.go | 4 +- 15 files changed, 603 insertions(+), 542 deletions(-) rename apis/v1alpha1/opentelemetrycollector_webhook.go => internal/webhook/collector/webhook.go (53%) rename apis/v1alpha1/opentelemetrycollector_webhook_test.go => internal/webhook/collector/webhook_test.go (55%) rename apis/v1alpha1/instrumentation_webhook.go => internal/webhook/instrumentation/webhook.go (62%) rename apis/v1alpha1/instrumentation_webhook_test.go => internal/webhook/instrumentation/webhook_test.go (53%) rename internal/{webhookhandler => webhook/sidecar}/webhookhandler.go (91%) rename internal/{webhookhandler => webhook/sidecar}/webhookhandler_suite_test.go (93%) rename internal/{webhookhandler => webhook/sidecar}/webhookhandler_test.go (99%) diff --git a/controllers/suite_test.go b/controllers/suite_test.go index 4d91e64486..6e71aacabc 100644 --- a/controllers/suite_test.go +++ b/controllers/suite_test.go @@ -49,6 +49,7 @@ import ( "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/manifests" "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/testdata" + collectorwebhook "github.com/open-telemetry/opentelemetry-operator/internal/webhook/collector" // +kubebuilder:scaffold:imports ) @@ -125,7 +126,7 @@ func TestMain(m *testing.M) { os.Exit(1) } - if err = (&v1alpha1.OpenTelemetryCollector{}).SetupWebhookWithManager(mgr); err != nil { + if err = collectorwebhook.SetupCollectorValidatingWebhookWithManager(mgr, config.New()); err != nil { fmt.Printf("failed to SetupWebhookWithManager: %v", err) os.Exit(1) } diff --git a/apis/v1alpha1/opentelemetrycollector_webhook.go b/internal/webhook/collector/webhook.go similarity index 53% rename from apis/v1alpha1/opentelemetrycollector_webhook.go rename to internal/webhook/collector/webhook.go index 3d1d9828ba..f267eea25b 100644 --- a/apis/v1alpha1/opentelemetrycollector_webhook.go +++ b/internal/webhook/collector/webhook.go @@ -12,46 +12,82 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1alpha1 +package collectorwebhook import ( + "context" "fmt" + "github.com/go-logr/logr" autoscalingv2 "k8s.io/api/autoscaling/v2" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/apimachinery/pkg/util/validation" ctrl "sigs.k8s.io/controller-runtime" - logf "sigs.k8s.io/controller-runtime/pkg/log" - "sigs.k8s.io/controller-runtime/pkg/webhook" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" + "github.com/open-telemetry/opentelemetry-operator/internal/config" ta "github.com/open-telemetry/opentelemetry-operator/internal/manifests/targetallocator/adapters" "github.com/open-telemetry/opentelemetry-operator/pkg/featuregate" ) -// log is for logging in this package. -var opentelemetrycollectorlog = logf.Log.WithName("opentelemetrycollector-resource") +var ( + _ admission.CustomValidator = &Webhook{} + _ admission.CustomDefaulter = &Webhook{} +) -func (r *OpenTelemetryCollector) SetupWebhookWithManager(mgr ctrl.Manager) error { - return ctrl.NewWebhookManagedBy(mgr). - For(r). - Complete() +// +kubebuilder:webhook:path=/mutate-opentelemetry-io-v1alpha1-opentelemetrycollector,mutating=true,failurePolicy=fail,groups=opentelemetry.io,resources=opentelemetrycollectors,verbs=create;update,versions=v1alpha1,name=mopentelemetrycollector.kb.io,sideEffects=none,admissionReviewVersions=v1 +// +kubebuilder:webhook:verbs=create;update,path=/validate-opentelemetry-io-v1alpha1-opentelemetrycollector,mutating=false,failurePolicy=fail,groups=opentelemetry.io,resources=opentelemetrycollectors,versions=v1alpha1,name=vopentelemetrycollectorcreateupdate.kb.io,sideEffects=none,admissionReviewVersions=v1 +// +kubebuilder:webhook:verbs=delete,path=/validate-opentelemetry-io-v1alpha1-opentelemetrycollector,mutating=false,failurePolicy=ignore,groups=opentelemetry.io,resources=opentelemetrycollectors,versions=v1alpha1,name=vopentelemetrycollectordelete.kb.io,sideEffects=none,admissionReviewVersions=v1 + +// Webhook is isolated because there are known registration issues when a custom webhook is in the same package +// as the types. +// See here: https://github.com/kubernetes-sigs/controller-runtime/issues/780#issuecomment-713408479 +type Webhook struct { + logger logr.Logger + cfg config.Config + scheme *runtime.Scheme } -// +kubebuilder:webhook:path=/mutate-opentelemetry-io-v1alpha1-opentelemetrycollector,mutating=true,failurePolicy=fail,groups=opentelemetry.io,resources=opentelemetrycollectors,verbs=create;update,versions=v1alpha1,name=mopentelemetrycollector.kb.io,sideEffects=none,admissionReviewVersions=v1 +func (c Webhook) Default(ctx context.Context, obj runtime.Object) error { + otelcol, ok := obj.(*v1alpha1.OpenTelemetryCollector) + if !ok { + return fmt.Errorf("expected an OpenTelemetryCollector, received %T", obj) + } + return c.defaulter(otelcol) +} -var _ webhook.Defaulter = &OpenTelemetryCollector{} +func (c Webhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { + otelcol, ok := obj.(*v1alpha1.OpenTelemetryCollector) + if !ok { + return nil, fmt.Errorf("expected an OpenTelemetryCollector, received %T", obj) + } + return c.validate(otelcol) +} -// Default implements webhook.Defaulter so a webhook will be registered for the type. -func (r *OpenTelemetryCollector) Default() { - opentelemetrycollectorlog.Info("default", "name", r.Name) +func (c Webhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { + otelcol, ok := newObj.(*v1alpha1.OpenTelemetryCollector) + if !ok { + return nil, fmt.Errorf("expected an OpenTelemetryCollector, received %T", newObj) + } + return c.validate(otelcol) +} +func (c Webhook) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { + otelcol, ok := obj.(*v1alpha1.OpenTelemetryCollector) + if !ok || otelcol == nil { + return nil, fmt.Errorf("expected an OpenTelemetryCollector, received %T", obj) + } + return c.validate(otelcol) +} + +func (c Webhook) defaulter(r *v1alpha1.OpenTelemetryCollector) error { if len(r.Spec.Mode) == 0 { - r.Spec.Mode = ModeDeployment + r.Spec.Mode = v1alpha1.ModeDeployment } if len(r.Spec.UpgradeStrategy) == 0 { - r.Spec.UpgradeStrategy = UpgradeStrategyAutomatic + r.Spec.UpgradeStrategy = v1alpha1.UpgradeStrategyAutomatic } if r.Labels == nil { @@ -73,7 +109,7 @@ func (r *OpenTelemetryCollector) Default() { if r.Spec.MaxReplicas != nil || (r.Spec.Autoscaler != nil && r.Spec.Autoscaler.MaxReplicas != nil) { if r.Spec.Autoscaler == nil { - r.Spec.Autoscaler = &AutoscalerSpec{} + r.Spec.Autoscaler = &v1alpha1.AutoscalerSpec{} } if r.Spec.Autoscaler.MaxReplicas == nil { @@ -98,7 +134,7 @@ func (r *OpenTelemetryCollector) Default() { // not blocking node drains but preventing out-of-the-box // from disruption generated by them with replicas > 1 if r.Spec.PodDisruptionBudget == nil { - r.Spec.PodDisruptionBudget = &PodDisruptionBudgetSpec{ + r.Spec.PodDisruptionBudget = &v1alpha1.PodDisruptionBudgetSpec{ MaxUnavailable: &intstr.IntOrString{ Type: intstr.Int, IntVal: 1, @@ -106,85 +142,64 @@ func (r *OpenTelemetryCollector) Default() { } } - if r.Spec.Ingress.Type == IngressTypeRoute && r.Spec.Ingress.Route.Termination == "" { - r.Spec.Ingress.Route.Termination = TLSRouteTerminationTypeEdge + if r.Spec.Ingress.Type == v1alpha1.IngressTypeRoute && r.Spec.Ingress.Route.Termination == "" { + r.Spec.Ingress.Route.Termination = v1alpha1.TLSRouteTerminationTypeEdge } - if r.Spec.Ingress.Type == IngressTypeNginx && r.Spec.Ingress.RuleType == "" { - r.Spec.Ingress.RuleType = IngressRuleTypePath + if r.Spec.Ingress.Type == v1alpha1.IngressTypeNginx && r.Spec.Ingress.RuleType == "" { + r.Spec.Ingress.RuleType = v1alpha1.IngressRuleTypePath } // If someone upgrades to a later version without upgrading their CRD they will not have a management state set. // This results in a default state of unmanaged preventing reconciliation from continuing. if len(r.Spec.ManagementState) == 0 { - r.Spec.ManagementState = ManagementStateManaged + r.Spec.ManagementState = v1alpha1.ManagementStateManaged } + return nil } -// +kubebuilder:webhook:verbs=create;update,path=/validate-opentelemetry-io-v1alpha1-opentelemetrycollector,mutating=false,failurePolicy=fail,groups=opentelemetry.io,resources=opentelemetrycollectors,versions=v1alpha1,name=vopentelemetrycollectorcreateupdate.kb.io,sideEffects=none,admissionReviewVersions=v1 -// +kubebuilder:webhook:verbs=delete,path=/validate-opentelemetry-io-v1alpha1-opentelemetrycollector,mutating=false,failurePolicy=ignore,groups=opentelemetry.io,resources=opentelemetrycollectors,versions=v1alpha1,name=vopentelemetrycollectordelete.kb.io,sideEffects=none,admissionReviewVersions=v1 - -var _ webhook.Validator = &OpenTelemetryCollector{} - -// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. -func (r *OpenTelemetryCollector) ValidateCreate() (admission.Warnings, error) { - opentelemetrycollectorlog.Info("validate create", "name", r.Name) - return nil, r.validateCRDSpec() -} - -// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. -func (r *OpenTelemetryCollector) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { - opentelemetrycollectorlog.Info("validate update", "name", r.Name) - return nil, r.validateCRDSpec() -} - -// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. -func (r *OpenTelemetryCollector) ValidateDelete() (admission.Warnings, error) { - opentelemetrycollectorlog.Info("validate delete", "name", r.Name) - return nil, nil -} - -func (r *OpenTelemetryCollector) validateCRDSpec() error { +func (c Webhook) validate(r *v1alpha1.OpenTelemetryCollector) (admission.Warnings, error) { + warnings := admission.Warnings{} // validate volumeClaimTemplates - if r.Spec.Mode != ModeStatefulSet && len(r.Spec.VolumeClaimTemplates) > 0 { - return fmt.Errorf("the OpenTelemetry Collector mode is set to %s, which does not support the attribute 'volumeClaimTemplates'", r.Spec.Mode) + if r.Spec.Mode != v1alpha1.ModeStatefulSet && len(r.Spec.VolumeClaimTemplates) > 0 { + return warnings, fmt.Errorf("the OpenTelemetry Collector mode is set to %s, which does not support the attribute 'volumeClaimTemplates'", r.Spec.Mode) } // validate tolerations - if r.Spec.Mode == ModeSidecar && len(r.Spec.Tolerations) > 0 { - return fmt.Errorf("the OpenTelemetry Collector mode is set to %s, which does not support the attribute 'tolerations'", r.Spec.Mode) + if r.Spec.Mode == v1alpha1.ModeSidecar && len(r.Spec.Tolerations) > 0 { + return warnings, fmt.Errorf("the OpenTelemetry Collector mode is set to %s, which does not support the attribute 'tolerations'", r.Spec.Mode) } // validate priorityClassName - if r.Spec.Mode == ModeSidecar && r.Spec.PriorityClassName != "" { - return fmt.Errorf("the OpenTelemetry Collector mode is set to %s, which does not support the attribute 'priorityClassName'", r.Spec.Mode) + if r.Spec.Mode == v1alpha1.ModeSidecar && r.Spec.PriorityClassName != "" { + return warnings, fmt.Errorf("the OpenTelemetry Collector mode is set to %s, which does not support the attribute 'priorityClassName'", r.Spec.Mode) } // validate affinity - if r.Spec.Mode == ModeSidecar && r.Spec.Affinity != nil { - return fmt.Errorf("the OpenTelemetry Collector mode is set to %s, which does not support the attribute 'affinity'", r.Spec.Mode) + if r.Spec.Mode == v1alpha1.ModeSidecar && r.Spec.Affinity != nil { + return warnings, fmt.Errorf("the OpenTelemetry Collector mode is set to %s, which does not support the attribute 'affinity'", r.Spec.Mode) } - if r.Spec.Mode == ModeSidecar && len(r.Spec.AdditionalContainers) > 0 { - return fmt.Errorf("the OpenTelemetry Collector mode is set to %s, which does not support the attribute 'AdditionalContainers'", r.Spec.Mode) + if r.Spec.Mode == v1alpha1.ModeSidecar && len(r.Spec.AdditionalContainers) > 0 { + return warnings, fmt.Errorf("the OpenTelemetry Collector mode is set to %s, which does not support the attribute 'AdditionalContainers'", r.Spec.Mode) } // validate target allocation - if r.Spec.TargetAllocator.Enabled && r.Spec.Mode != ModeStatefulSet { - return fmt.Errorf("the OpenTelemetry Collector mode is set to %s, which does not support the target allocation deployment", r.Spec.Mode) + if r.Spec.TargetAllocator.Enabled && r.Spec.Mode != v1alpha1.ModeStatefulSet { + return warnings, fmt.Errorf("the OpenTelemetry Collector mode is set to %s, which does not support the target allocation deployment", r.Spec.Mode) } // validate Prometheus config for target allocation if r.Spec.TargetAllocator.Enabled { promCfg, err := ta.ConfigToPromConfig(r.Spec.Config) if err != nil { - return fmt.Errorf("the OpenTelemetry Spec Prometheus configuration is incorrect, %w", err) + return warnings, fmt.Errorf("the OpenTelemetry Spec Prometheus configuration is incorrect, %w", err) } err = ta.ValidatePromConfig(promCfg, r.Spec.TargetAllocator.Enabled, featuregate.EnableTargetAllocatorRewrite.IsEnabled()) if err != nil { - return fmt.Errorf("the OpenTelemetry Spec Prometheus configuration is incorrect, %w", err) + return warnings, fmt.Errorf("the OpenTelemetry Spec Prometheus configuration is incorrect, %w", err) } err = ta.ValidateTargetAllocatorConfig(r.Spec.TargetAllocator.PrometheusCR.Enabled, promCfg) if err != nil { - return fmt.Errorf("the OpenTelemetry Spec Prometheus configuration is incorrect, %w", err) + return warnings, fmt.Errorf("the OpenTelemetry Spec Prometheus configuration is incorrect, %w", err) } } @@ -193,106 +208,100 @@ func (r *OpenTelemetryCollector) validateCRDSpec() error { nameErrs := validation.IsValidPortName(p.Name) numErrs := validation.IsValidPortNum(int(p.Port)) if len(nameErrs) > 0 || len(numErrs) > 0 { - return fmt.Errorf("the OpenTelemetry Spec Ports configuration is incorrect, port name '%s' errors: %s, num '%d' errors: %s", + return warnings, fmt.Errorf("the OpenTelemetry Spec Ports configuration is incorrect, port name '%s' errors: %s, num '%d' errors: %s", p.Name, nameErrs, p.Port, numErrs) } } - maxReplicas := new(int32) + var maxReplicas *int32 if r.Spec.Autoscaler != nil && r.Spec.Autoscaler.MaxReplicas != nil { maxReplicas = r.Spec.Autoscaler.MaxReplicas } // check deprecated .Spec.MaxReplicas if maxReplicas is not set - if *maxReplicas == 0 { + if maxReplicas == nil && r.Spec.MaxReplicas != nil { + warnings = append(warnings, "MaxReplicas is deprecated") maxReplicas = r.Spec.MaxReplicas } - minReplicas := new(int32) + var minReplicas *int32 if r.Spec.Autoscaler != nil && r.Spec.Autoscaler.MinReplicas != nil { minReplicas = r.Spec.Autoscaler.MinReplicas } // check deprecated .Spec.MinReplicas if minReplicas is not set - if *minReplicas == 0 { + if minReplicas == nil { if r.Spec.MinReplicas != nil { + warnings = append(warnings, "MinReplicas is deprecated") minReplicas = r.Spec.MinReplicas } else { minReplicas = r.Spec.Replicas } } - if r.Spec.Ingress.Type == IngressTypeNginx && r.Spec.Mode == ModeSidecar { - return fmt.Errorf("the OpenTelemetry Spec Ingress configuration is incorrect. Ingress can only be used in combination with the modes: %s, %s, %s", - ModeDeployment, ModeDaemonSet, ModeStatefulSet, + if r.Spec.Ingress.Type == v1alpha1.IngressTypeNginx && r.Spec.Mode == v1alpha1.ModeSidecar { + return warnings, fmt.Errorf("the OpenTelemetry Spec Ingress configuration is incorrect. Ingress can only be used in combination with the modes: %s, %s, %s", + v1alpha1.ModeDeployment, v1alpha1.ModeDaemonSet, v1alpha1.ModeStatefulSet, ) } // validate autoscale with horizontal pod autoscaler if maxReplicas != nil { if *maxReplicas < int32(1) { - return fmt.Errorf("the OpenTelemetry Spec autoscale configuration is incorrect, maxReplicas should be defined and one or more") + return warnings, fmt.Errorf("the OpenTelemetry Spec autoscale configuration is incorrect, maxReplicas should be defined and one or more") } if r.Spec.Replicas != nil && *r.Spec.Replicas > *maxReplicas { - return fmt.Errorf("the OpenTelemetry Spec autoscale configuration is incorrect, replicas must not be greater than maxReplicas") + return warnings, fmt.Errorf("the OpenTelemetry Spec autoscale configuration is incorrect, replicas must not be greater than maxReplicas") } if minReplicas != nil && *minReplicas > *maxReplicas { - return fmt.Errorf("the OpenTelemetry Spec autoscale configuration is incorrect, minReplicas must not be greater than maxReplicas") + return warnings, fmt.Errorf("the OpenTelemetry Spec autoscale configuration is incorrect, minReplicas must not be greater than maxReplicas") } if minReplicas != nil && *minReplicas < int32(1) { - return fmt.Errorf("the OpenTelemetry Spec autoscale configuration is incorrect, minReplicas should be one or more") + return warnings, fmt.Errorf("the OpenTelemetry Spec autoscale configuration is incorrect, minReplicas should be one or more") } if r.Spec.Autoscaler != nil { - return checkAutoscalerSpec(r.Spec.Autoscaler) + return warnings, checkAutoscalerSpec(r.Spec.Autoscaler) } } - // validate pod disruption budget - - if r.Spec.PodDisruptionBudget != nil { - if r.Spec.PodDisruptionBudget.MaxUnavailable != nil && r.Spec.PodDisruptionBudget.MinAvailable != nil { - return fmt.Errorf("the OpenTelemetry Spec podDisruptionBudget configuration is incorrect, minAvailable and maxUnavailable are mutually exclusive") - } - } - - if r.Spec.Ingress.Type == IngressTypeNginx && r.Spec.Mode == ModeSidecar { - return fmt.Errorf("the OpenTelemetry Spec Ingress configuiration is incorrect. Ingress can only be used in combination with the modes: %s, %s, %s", - ModeDeployment, ModeDaemonSet, ModeStatefulSet, + if r.Spec.Ingress.Type == v1alpha1.IngressTypeNginx && r.Spec.Mode == v1alpha1.ModeSidecar { + return warnings, fmt.Errorf("the OpenTelemetry Spec Ingress configuiration is incorrect. Ingress can only be used in combination with the modes: %s, %s, %s", + v1alpha1.ModeDeployment, v1alpha1.ModeDaemonSet, v1alpha1.ModeStatefulSet, ) } - if r.Spec.Ingress.RuleType == IngressRuleTypeSubdomain && (r.Spec.Ingress.Hostname == "" || r.Spec.Ingress.Hostname == "*") { - return fmt.Errorf("a valid Ingress hostname has to be defined for subdomain ruleType") + if r.Spec.Ingress.RuleType == v1alpha1.IngressRuleTypeSubdomain && (r.Spec.Ingress.Hostname == "" || r.Spec.Ingress.Hostname == "*") { + return warnings, fmt.Errorf("a valid Ingress hostname has to be defined for subdomain ruleType") } if r.Spec.LivenessProbe != nil { if r.Spec.LivenessProbe.InitialDelaySeconds != nil && *r.Spec.LivenessProbe.InitialDelaySeconds < 0 { - return fmt.Errorf("the OpenTelemetry Spec LivenessProbe InitialDelaySeconds configuration is incorrect. InitialDelaySeconds should be greater than or equal to 0") + return warnings, fmt.Errorf("the OpenTelemetry Spec LivenessProbe InitialDelaySeconds configuration is incorrect. InitialDelaySeconds should be greater than or equal to 0") } if r.Spec.LivenessProbe.PeriodSeconds != nil && *r.Spec.LivenessProbe.PeriodSeconds < 1 { - return fmt.Errorf("the OpenTelemetry Spec LivenessProbe PeriodSeconds configuration is incorrect. PeriodSeconds should be greater than or equal to 1") + return warnings, fmt.Errorf("the OpenTelemetry Spec LivenessProbe PeriodSeconds configuration is incorrect. PeriodSeconds should be greater than or equal to 1") } if r.Spec.LivenessProbe.TimeoutSeconds != nil && *r.Spec.LivenessProbe.TimeoutSeconds < 1 { - return fmt.Errorf("the OpenTelemetry Spec LivenessProbe TimeoutSeconds configuration is incorrect. TimeoutSeconds should be greater than or equal to 1") + return warnings, fmt.Errorf("the OpenTelemetry Spec LivenessProbe TimeoutSeconds configuration is incorrect. TimeoutSeconds should be greater than or equal to 1") } if r.Spec.LivenessProbe.SuccessThreshold != nil && *r.Spec.LivenessProbe.SuccessThreshold < 1 { - return fmt.Errorf("the OpenTelemetry Spec LivenessProbe SuccessThreshold configuration is incorrect. SuccessThreshold should be greater than or equal to 1") + return warnings, fmt.Errorf("the OpenTelemetry Spec LivenessProbe SuccessThreshold configuration is incorrect. SuccessThreshold should be greater than or equal to 1") } if r.Spec.LivenessProbe.FailureThreshold != nil && *r.Spec.LivenessProbe.FailureThreshold < 1 { - return fmt.Errorf("the OpenTelemetry Spec LivenessProbe FailureThreshold configuration is incorrect. FailureThreshold should be greater than or equal to 1") + return warnings, fmt.Errorf("the OpenTelemetry Spec LivenessProbe FailureThreshold configuration is incorrect. FailureThreshold should be greater than or equal to 1") } if r.Spec.LivenessProbe.TerminationGracePeriodSeconds != nil && *r.Spec.LivenessProbe.TerminationGracePeriodSeconds < 1 { - return fmt.Errorf("the OpenTelemetry Spec LivenessProbe TerminationGracePeriodSeconds configuration is incorrect. TerminationGracePeriodSeconds should be greater than or equal to 1") + return warnings, fmt.Errorf("the OpenTelemetry Spec LivenessProbe TerminationGracePeriodSeconds configuration is incorrect. TerminationGracePeriodSeconds should be greater than or equal to 1") } } - return nil + return warnings, nil } -func checkAutoscalerSpec(autoscaler *AutoscalerSpec) error { +func checkAutoscalerSpec(autoscaler *v1alpha1.AutoscalerSpec) error { if autoscaler.Behavior != nil { if autoscaler.Behavior.ScaleDown != nil && autoscaler.Behavior.ScaleDown.StabilizationWindowSeconds != nil && *autoscaler.Behavior.ScaleDown.StabilizationWindowSeconds < int32(1) { @@ -332,3 +341,16 @@ func checkAutoscalerSpec(autoscaler *AutoscalerSpec) error { return nil } + +func SetupCollectorValidatingWebhookWithManager(mgr ctrl.Manager, cfg config.Config) error { + cvw := &Webhook{ + logger: mgr.GetLogger().WithValues("handler", "CollectorWebhook"), + scheme: mgr.GetScheme(), + cfg: cfg, + } + return ctrl.NewWebhookManagedBy(mgr). + For(&v1alpha1.OpenTelemetryCollector{}). + WithValidator(cvw). + WithDefaulter(cvw). + Complete() +} diff --git a/apis/v1alpha1/opentelemetrycollector_webhook_test.go b/internal/webhook/collector/webhook_test.go similarity index 55% rename from apis/v1alpha1/opentelemetrycollector_webhook_test.go rename to internal/webhook/collector/webhook_test.go index b4b4b9e2be..bce735e085 100644 --- a/apis/v1alpha1/opentelemetrycollector_webhook_test.go +++ b/internal/webhook/collector/webhook_test.go @@ -12,18 +12,30 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1alpha1 +package collectorwebhook import ( + "context" "fmt" + "os" "testing" + "github.com/go-logr/logr" "github.com/stretchr/testify/assert" autoscalingv2 "k8s.io/api/autoscaling/v2" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/client-go/kubernetes/scheme" + + "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" + "github.com/open-telemetry/opentelemetry-operator/internal/config" +) + +var ( + testScheme *runtime.Scheme = scheme.Scheme ) func TestOTELColDefaultingWebhook(t *testing.T) { @@ -31,26 +43,31 @@ func TestOTELColDefaultingWebhook(t *testing.T) { five := int32(5) defaultCPUTarget := int32(90) + if err := v1alpha1.AddToScheme(testScheme); err != nil { + fmt.Printf("failed to register scheme: %v", err) + os.Exit(1) + } + tests := []struct { name string - otelcol OpenTelemetryCollector - expected OpenTelemetryCollector + otelcol v1alpha1.OpenTelemetryCollector + expected v1alpha1.OpenTelemetryCollector }{ { name: "all fields default", - otelcol: OpenTelemetryCollector{}, - expected: OpenTelemetryCollector{ + otelcol: v1alpha1.OpenTelemetryCollector{}, + expected: v1alpha1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{ "app.kubernetes.io/managed-by": "opentelemetry-operator", }, }, - Spec: OpenTelemetryCollectorSpec{ - Mode: ModeDeployment, + Spec: v1alpha1.OpenTelemetryCollectorSpec{ + Mode: v1alpha1.ModeDeployment, Replicas: &one, - UpgradeStrategy: UpgradeStrategyAutomatic, - ManagementState: ManagementStateManaged, - PodDisruptionBudget: &PodDisruptionBudgetSpec{ + UpgradeStrategy: v1alpha1.UpgradeStrategyAutomatic, + ManagementState: v1alpha1.ManagementStateManaged, + PodDisruptionBudget: &v1alpha1.PodDisruptionBudgetSpec{ MaxUnavailable: &intstr.IntOrString{ Type: intstr.Int, IntVal: 1, @@ -61,25 +78,25 @@ func TestOTELColDefaultingWebhook(t *testing.T) { }, { name: "provided values in spec", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ - Mode: ModeSidecar, + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ + Mode: v1alpha1.ModeSidecar, Replicas: &five, UpgradeStrategy: "adhoc", }, }, - expected: OpenTelemetryCollector{ + expected: v1alpha1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{ "app.kubernetes.io/managed-by": "opentelemetry-operator", }, }, - Spec: OpenTelemetryCollectorSpec{ - Mode: ModeSidecar, + Spec: v1alpha1.OpenTelemetryCollectorSpec{ + Mode: v1alpha1.ModeSidecar, Replicas: &five, UpgradeStrategy: "adhoc", - ManagementState: ManagementStateManaged, - PodDisruptionBudget: &PodDisruptionBudgetSpec{ + ManagementState: v1alpha1.ManagementStateManaged, + PodDisruptionBudget: &v1alpha1.PodDisruptionBudgetSpec{ MaxUnavailable: &intstr.IntOrString{ Type: intstr.Int, IntVal: 1, @@ -90,26 +107,26 @@ func TestOTELColDefaultingWebhook(t *testing.T) { }, { name: "doesn't override unmanaged", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ - ManagementState: ManagementStateUnmanaged, - Mode: ModeSidecar, + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ + ManagementState: v1alpha1.ManagementStateUnmanaged, + Mode: v1alpha1.ModeSidecar, Replicas: &five, UpgradeStrategy: "adhoc", }, }, - expected: OpenTelemetryCollector{ + expected: v1alpha1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{ "app.kubernetes.io/managed-by": "opentelemetry-operator", }, }, - Spec: OpenTelemetryCollectorSpec{ - Mode: ModeSidecar, + Spec: v1alpha1.OpenTelemetryCollectorSpec{ + Mode: v1alpha1.ModeSidecar, Replicas: &five, UpgradeStrategy: "adhoc", - ManagementState: ManagementStateUnmanaged, - PodDisruptionBudget: &PodDisruptionBudgetSpec{ + ManagementState: v1alpha1.ManagementStateUnmanaged, + PodDisruptionBudget: &v1alpha1.PodDisruptionBudgetSpec{ MaxUnavailable: &intstr.IntOrString{ Type: intstr.Int, IntVal: 1, @@ -120,31 +137,31 @@ func TestOTELColDefaultingWebhook(t *testing.T) { }, { name: "Setting Autoscaler MaxReplicas", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ - Autoscaler: &AutoscalerSpec{ + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ + Autoscaler: &v1alpha1.AutoscalerSpec{ MaxReplicas: &five, MinReplicas: &one, }, }, }, - expected: OpenTelemetryCollector{ + expected: v1alpha1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{ "app.kubernetes.io/managed-by": "opentelemetry-operator", }, }, - Spec: OpenTelemetryCollectorSpec{ - Mode: ModeDeployment, + Spec: v1alpha1.OpenTelemetryCollectorSpec{ + Mode: v1alpha1.ModeDeployment, Replicas: &one, - UpgradeStrategy: UpgradeStrategyAutomatic, - ManagementState: ManagementStateManaged, - Autoscaler: &AutoscalerSpec{ + UpgradeStrategy: v1alpha1.UpgradeStrategyAutomatic, + ManagementState: v1alpha1.ManagementStateManaged, + Autoscaler: &v1alpha1.AutoscalerSpec{ TargetCPUUtilization: &defaultCPUTarget, MaxReplicas: &five, MinReplicas: &one, }, - PodDisruptionBudget: &PodDisruptionBudgetSpec{ + PodDisruptionBudget: &v1alpha1.PodDisruptionBudgetSpec{ MaxUnavailable: &intstr.IntOrString{ Type: intstr.Int, IntVal: 1, @@ -155,23 +172,23 @@ func TestOTELColDefaultingWebhook(t *testing.T) { }, { name: "MaxReplicas but no Autoscale", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ MaxReplicas: &five, }, }, - expected: OpenTelemetryCollector{ + expected: v1alpha1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{ "app.kubernetes.io/managed-by": "opentelemetry-operator", }, }, - Spec: OpenTelemetryCollectorSpec{ - Mode: ModeDeployment, + Spec: v1alpha1.OpenTelemetryCollectorSpec{ + Mode: v1alpha1.ModeDeployment, Replicas: &one, - UpgradeStrategy: UpgradeStrategyAutomatic, - ManagementState: ManagementStateManaged, - Autoscaler: &AutoscalerSpec{ + UpgradeStrategy: v1alpha1.UpgradeStrategyAutomatic, + ManagementState: v1alpha1.ManagementStateManaged, + Autoscaler: &v1alpha1.AutoscalerSpec{ TargetCPUUtilization: &defaultCPUTarget, // webhook Default adds MaxReplicas to Autoscaler because // OpenTelemetryCollector.Spec.MaxReplicas is deprecated. @@ -179,7 +196,7 @@ func TestOTELColDefaultingWebhook(t *testing.T) { MinReplicas: &one, }, MaxReplicas: &five, - PodDisruptionBudget: &PodDisruptionBudgetSpec{ + PodDisruptionBudget: &v1alpha1.PodDisruptionBudgetSpec{ MaxUnavailable: &intstr.IntOrString{ Type: intstr.Int, IntVal: 1, @@ -190,32 +207,32 @@ func TestOTELColDefaultingWebhook(t *testing.T) { }, { name: "Missing route termination", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ - Mode: ModeDeployment, - Ingress: Ingress{ - Type: IngressTypeRoute, + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ + Mode: v1alpha1.ModeDeployment, + Ingress: v1alpha1.Ingress{ + Type: v1alpha1.IngressTypeRoute, }, }, }, - expected: OpenTelemetryCollector{ + expected: v1alpha1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{ "app.kubernetes.io/managed-by": "opentelemetry-operator", }, }, - Spec: OpenTelemetryCollectorSpec{ - Mode: ModeDeployment, - ManagementState: ManagementStateManaged, - Ingress: Ingress{ - Type: IngressTypeRoute, - Route: OpenShiftRoute{ - Termination: TLSRouteTerminationTypeEdge, + Spec: v1alpha1.OpenTelemetryCollectorSpec{ + Mode: v1alpha1.ModeDeployment, + ManagementState: v1alpha1.ManagementStateManaged, + Ingress: v1alpha1.Ingress{ + Type: v1alpha1.IngressTypeRoute, + Route: v1alpha1.OpenShiftRoute{ + Termination: v1alpha1.TLSRouteTerminationTypeEdge, }, }, Replicas: &one, - UpgradeStrategy: UpgradeStrategyAutomatic, - PodDisruptionBudget: &PodDisruptionBudgetSpec{ + UpgradeStrategy: v1alpha1.UpgradeStrategyAutomatic, + PodDisruptionBudget: &v1alpha1.PodDisruptionBudgetSpec{ MaxUnavailable: &intstr.IntOrString{ Type: intstr.Int, IntVal: 1, @@ -226,10 +243,10 @@ func TestOTELColDefaultingWebhook(t *testing.T) { }, { name: "Defined PDB", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ - Mode: ModeDeployment, - PodDisruptionBudget: &PodDisruptionBudgetSpec{ + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ + Mode: v1alpha1.ModeDeployment, + PodDisruptionBudget: &v1alpha1.PodDisruptionBudgetSpec{ MinAvailable: &intstr.IntOrString{ Type: intstr.String, StrVal: "10%", @@ -237,18 +254,18 @@ func TestOTELColDefaultingWebhook(t *testing.T) { }, }, }, - expected: OpenTelemetryCollector{ + expected: v1alpha1.OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{ "app.kubernetes.io/managed-by": "opentelemetry-operator", }, }, - Spec: OpenTelemetryCollectorSpec{ - Mode: ModeDeployment, + Spec: v1alpha1.OpenTelemetryCollectorSpec{ + Mode: v1alpha1.ModeDeployment, Replicas: &one, - UpgradeStrategy: UpgradeStrategyAutomatic, - ManagementState: ManagementStateManaged, - PodDisruptionBudget: &PodDisruptionBudgetSpec{ + UpgradeStrategy: v1alpha1.UpgradeStrategyAutomatic, + ManagementState: v1alpha1.ManagementStateManaged, + PodDisruptionBudget: &v1alpha1.PodDisruptionBudgetSpec{ MinAvailable: &intstr.IntOrString{ Type: intstr.String, StrVal: "10%", @@ -261,7 +278,17 @@ func TestOTELColDefaultingWebhook(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - test.otelcol.Default() + cvw := &Webhook{ + logger: logr.Discard(), + scheme: testScheme, + cfg: config.New( + config.WithCollectorImage("collector:v0.0.0"), + config.WithTargetAllocatorImage("ta:v0.0.0"), + ), + } + ctx := context.Background() + err := cvw.Default(ctx, &test.otelcol) + assert.NoError(t, err) assert.Equal(t, test.expected, test.otelcol) }) } @@ -279,24 +306,25 @@ func TestOTELColValidatingWebhook(t *testing.T) { five := int32(5) tests := []struct { //nolint:govet - name string - otelcol OpenTelemetryCollector - expectedErr string + name string + otelcol v1alpha1.OpenTelemetryCollector + expectedErr string + expectedWarnings []string }{ { name: "valid empty spec", - otelcol: OpenTelemetryCollector{}, + otelcol: v1alpha1.OpenTelemetryCollector{}, }, { name: "valid full spec", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ - Mode: ModeStatefulSet, + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ + Mode: v1alpha1.ModeStatefulSet, MinReplicas: &one, Replicas: &three, MaxReplicas: &five, UpgradeStrategy: "adhoc", - TargetAllocator: OpenTelemetryTargetAllocator{ + TargetAllocator: v1alpha1.OpenTelemetryTargetAllocator{ Enabled: true, }, Config: `receivers: @@ -325,7 +353,7 @@ func TestOTELColValidatingWebhook(t *testing.T) { Protocol: v1.ProtocolUDP, }, }, - Autoscaler: &AutoscalerSpec{ + Autoscaler: &v1alpha1.AutoscalerSpec{ Behavior: &autoscalingv2.HorizontalPodAutoscalerBehavior{ ScaleDown: &autoscalingv2.HPAScalingRules{ StabilizationWindowSeconds: &three, @@ -336,20 +364,14 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, TargetCPUUtilization: &five, }, - PodDisruptionBudget: &PodDisruptionBudgetSpec{ - MinAvailable: &intstr.IntOrString{ - Type: intstr.Int, - IntVal: 1, - }, - }, }, }, }, { name: "invalid mode with volume claim templates", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ - Mode: ModeSidecar, + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ + Mode: v1alpha1.ModeSidecar, VolumeClaimTemplates: []v1.PersistentVolumeClaim{{}, {}}, }, }, @@ -357,9 +379,9 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid mode with tolerations", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ - Mode: ModeSidecar, + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ + Mode: v1alpha1.ModeSidecar, Tolerations: []v1.Toleration{{}, {}}, }, }, @@ -367,10 +389,10 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid mode with target allocator", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ - Mode: ModeDeployment, - TargetAllocator: OpenTelemetryTargetAllocator{ + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ + Mode: v1alpha1.ModeDeployment, + TargetAllocator: v1alpha1.OpenTelemetryTargetAllocator{ Enabled: true, }, }, @@ -379,10 +401,10 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid target allocator config", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ - Mode: ModeStatefulSet, - TargetAllocator: OpenTelemetryTargetAllocator{ + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ + Mode: v1alpha1.ModeStatefulSet, + TargetAllocator: v1alpha1.OpenTelemetryTargetAllocator{ Enabled: true, }, }, @@ -391,8 +413,8 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid port name", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ Ports: []v1.ServicePort{ { // this port name contains a non alphanumeric character, which is invalid. @@ -407,8 +429,8 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid port name, too long", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ Ports: []v1.ServicePort{ { Name: "aaaabbbbccccdddd", // len: 16, too long @@ -421,8 +443,8 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid port num", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ Ports: []v1.ServicePort{ { Name: "aaaabbbbccccddd", // len: 15 @@ -435,49 +457,53 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid max replicas", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ MaxReplicas: &zero, }, }, - expectedErr: "maxReplicas should be defined and one or more", + expectedErr: "maxReplicas should be defined and one or more", + expectedWarnings: []string{"MaxReplicas is deprecated"}, }, { name: "invalid replicas, greater than max", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ MaxReplicas: &three, Replicas: &five, }, }, - expectedErr: "replicas must not be greater than maxReplicas", + expectedErr: "replicas must not be greater than maxReplicas", + expectedWarnings: []string{"MaxReplicas is deprecated"}, }, { name: "invalid min replicas, greater than max", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ MaxReplicas: &three, MinReplicas: &five, }, }, - expectedErr: "minReplicas must not be greater than maxReplicas", + expectedErr: "minReplicas must not be greater than maxReplicas", + expectedWarnings: []string{"MaxReplicas is deprecated", "MinReplicas is deprecated"}, }, { name: "invalid min replicas, lesser than 1", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ MaxReplicas: &three, MinReplicas: &zero, }, }, - expectedErr: "minReplicas should be one or more", + expectedErr: "minReplicas should be one or more", + expectedWarnings: []string{"MaxReplicas is deprecated", "MinReplicas is deprecated"}, }, { name: "invalid autoscaler scale down", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ MaxReplicas: &three, - Autoscaler: &AutoscalerSpec{ + Autoscaler: &v1alpha1.AutoscalerSpec{ Behavior: &autoscalingv2.HorizontalPodAutoscalerBehavior{ ScaleDown: &autoscalingv2.HPAScalingRules{ StabilizationWindowSeconds: &zero, @@ -486,14 +512,15 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, }, }, - expectedErr: "scaleDown should be one or more", + expectedErr: "scaleDown should be one or more", + expectedWarnings: []string{"MaxReplicas is deprecated"}, }, { name: "invalid autoscaler scale up", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ MaxReplicas: &three, - Autoscaler: &AutoscalerSpec{ + Autoscaler: &v1alpha1.AutoscalerSpec{ Behavior: &autoscalingv2.HorizontalPodAutoscalerBehavior{ ScaleUp: &autoscalingv2.HPAScalingRules{ StabilizationWindowSeconds: &zero, @@ -502,25 +529,27 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, }, }, - expectedErr: "scaleUp should be one or more", + expectedErr: "scaleUp should be one or more", + expectedWarnings: []string{"MaxReplicas is deprecated"}, }, { name: "invalid autoscaler target cpu utilization", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ MaxReplicas: &three, - Autoscaler: &AutoscalerSpec{ + Autoscaler: &v1alpha1.AutoscalerSpec{ TargetCPUUtilization: &zero, }, }, }, - expectedErr: "targetCPUUtilization should be greater than 0 and less than 100", + expectedErr: "targetCPUUtilization should be greater than 0 and less than 100", + expectedWarnings: []string{"MaxReplicas is deprecated"}, }, { name: "autoscaler minReplicas is less than maxReplicas", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ - Autoscaler: &AutoscalerSpec{ + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ + Autoscaler: &v1alpha1.AutoscalerSpec{ MaxReplicas: &one, MinReplicas: &five, }, @@ -530,11 +559,11 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid autoscaler metric type", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ MaxReplicas: &three, - Autoscaler: &AutoscalerSpec{ - Metrics: []MetricSpec{ + Autoscaler: &v1alpha1.AutoscalerSpec{ + Metrics: []v1alpha1.MetricSpec{ { Type: autoscalingv2.ResourceMetricSourceType, }, @@ -542,15 +571,16 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, }, }, - expectedErr: "the OpenTelemetry Spec autoscale configuration is incorrect, metric type unsupported. Expected metric of source type Pod", + expectedErr: "the OpenTelemetry Spec autoscale configuration is incorrect, metric type unsupported. Expected metric of source type Pod", + expectedWarnings: []string{"MaxReplicas is deprecated"}, }, { name: "invalid pod metric average value", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ MaxReplicas: &three, - Autoscaler: &AutoscalerSpec{ - Metrics: []MetricSpec{ + Autoscaler: &v1alpha1.AutoscalerSpec{ + Metrics: []v1alpha1.MetricSpec{ { Type: autoscalingv2.PodsMetricSourceType, Pods: &autoscalingv2.PodsMetricSource{ @@ -567,15 +597,16 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, }, }, - expectedErr: "the OpenTelemetry Spec autoscale configuration is incorrect, average value should be greater than 0", + expectedErr: "the OpenTelemetry Spec autoscale configuration is incorrect, average value should be greater than 0", + expectedWarnings: []string{"MaxReplicas is deprecated"}, }, { name: "utilization target is not valid with pod metrics", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ MaxReplicas: &three, - Autoscaler: &AutoscalerSpec{ - Metrics: []MetricSpec{ + Autoscaler: &v1alpha1.AutoscalerSpec{ + Metrics: []v1alpha1.MetricSpec{ { Type: autoscalingv2.PodsMetricSourceType, Pods: &autoscalingv2.PodsMetricSource{ @@ -592,46 +623,28 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, }, }, - expectedErr: "the OpenTelemetry Spec autoscale configuration is incorrect, invalid pods target type", - }, - { - name: "pdb minAvailable and maxUnavailable have been set together", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ - MaxReplicas: &three, - PodDisruptionBudget: &PodDisruptionBudgetSpec{ - MinAvailable: &intstr.IntOrString{ - Type: intstr.Int, - IntVal: 1, - }, - MaxUnavailable: &intstr.IntOrString{ - Type: intstr.Int, - IntVal: 1, - }, - }, - }, - }, - expectedErr: "the OpenTelemetry Spec podDisruptionBudget configuration is incorrect, minAvailable and maxUnavailable are mutually exclusive", + expectedErr: "the OpenTelemetry Spec autoscale configuration is incorrect, invalid pods target type", + expectedWarnings: []string{"MaxReplicas is deprecated"}, }, { name: "invalid deployment mode incompabible with ingress settings", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ - Mode: ModeSidecar, - Ingress: Ingress{ - Type: IngressTypeNginx, + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ + Mode: v1alpha1.ModeSidecar, + Ingress: v1alpha1.Ingress{ + Type: v1alpha1.IngressTypeNginx, }, }, }, expectedErr: fmt.Sprintf("Ingress can only be used in combination with the modes: %s, %s, %s", - ModeDeployment, ModeDaemonSet, ModeStatefulSet, + v1alpha1.ModeDeployment, v1alpha1.ModeDaemonSet, v1alpha1.ModeStatefulSet, ), }, { name: "invalid mode with priorityClassName", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ - Mode: ModeSidecar, + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ + Mode: v1alpha1.ModeSidecar, PriorityClassName: "test-class", }, }, @@ -639,9 +652,9 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid mode with affinity", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ - Mode: ModeSidecar, + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ + Mode: v1alpha1.ModeSidecar, Affinity: &v1.Affinity{ NodeAffinity: &v1.NodeAffinity{ RequiredDuringSchedulingIgnoredDuringExecution: &v1.NodeSelector{ @@ -665,9 +678,9 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid InitialDelaySeconds", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ - LivenessProbe: &Probe{ + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ + LivenessProbe: &v1alpha1.Probe{ InitialDelaySeconds: &minusOne, }, }, @@ -676,9 +689,9 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid PeriodSeconds", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ - LivenessProbe: &Probe{ + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ + LivenessProbe: &v1alpha1.Probe{ PeriodSeconds: &zero, }, }, @@ -687,9 +700,9 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid TimeoutSeconds", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ - LivenessProbe: &Probe{ + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ + LivenessProbe: &v1alpha1.Probe{ TimeoutSeconds: &zero, }, }, @@ -698,9 +711,9 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid SuccessThreshold", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ - LivenessProbe: &Probe{ + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ + LivenessProbe: &v1alpha1.Probe{ SuccessThreshold: &zero, }, }, @@ -709,9 +722,9 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid FailureThreshold", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ - LivenessProbe: &Probe{ + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ + LivenessProbe: &v1alpha1.Probe{ FailureThreshold: &zero, }, }, @@ -720,9 +733,9 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid TerminationGracePeriodSeconds", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ - LivenessProbe: &Probe{ + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ + LivenessProbe: &v1alpha1.Probe{ TerminationGracePeriodSeconds: &zero64, }, }, @@ -731,9 +744,9 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid AdditionalContainers", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ - Mode: ModeSidecar, + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ + Mode: v1alpha1.ModeSidecar, AdditionalContainers: []v1.Container{ { Name: "test", @@ -745,10 +758,10 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "missing ingress hostname for subdomain ruleType", - otelcol: OpenTelemetryCollector{ - Spec: OpenTelemetryCollectorSpec{ - Ingress: Ingress{ - RuleType: IngressRuleTypeSubdomain, + otelcol: v1alpha1.OpenTelemetryCollector{ + Spec: v1alpha1.OpenTelemetryCollectorSpec{ + Ingress: v1alpha1.Ingress{ + RuleType: v1alpha1.IngressRuleTypeSubdomain, }, }, }, @@ -758,11 +771,25 @@ func TestOTELColValidatingWebhook(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - err := test.otelcol.validateCRDSpec() + cvw := &Webhook{ + logger: logr.Discard(), + scheme: testScheme, + cfg: config.New( + config.WithCollectorImage("collector:v0.0.0"), + config.WithTargetAllocatorImage("ta:v0.0.0"), + ), + } + ctx := context.Background() + warnings, err := cvw.ValidateCreate(ctx, &test.otelcol) if test.expectedErr == "" { assert.NoError(t, err) return } + if len(test.expectedWarnings) == 0 { + assert.Empty(t, warnings, test.expectedWarnings) + } else { + assert.ElementsMatch(t, warnings, test.expectedWarnings) + } assert.ErrorContains(t, err, test.expectedErr) }) } diff --git a/apis/v1alpha1/instrumentation_webhook.go b/internal/webhook/instrumentation/webhook.go similarity index 62% rename from apis/v1alpha1/instrumentation_webhook.go rename to internal/webhook/instrumentation/webhook.go index 234784dd15..3caf50d109 100644 --- a/apis/v1alpha1/instrumentation_webhook.go +++ b/internal/webhook/instrumentation/webhook.go @@ -12,20 +12,23 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1alpha1 +package instrumentation import ( + "context" "fmt" "strconv" "strings" + "github.com/go-logr/logr" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/runtime" ctrl "sigs.k8s.io/controller-runtime" - logf "sigs.k8s.io/controller-runtime/pkg/log" - "sigs.k8s.io/controller-runtime/pkg/webhook" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" + "github.com/open-telemetry/opentelemetry-operator/internal/config" ) const ( @@ -40,31 +43,65 @@ const ( envSplunkPrefix = "SPLUNK_" ) -// log is for logging in this package. -var instrumentationlog = logf.Log.WithName("instrumentation-resource") +var ( + _ admission.CustomValidator = &Webhook{} + _ admission.CustomDefaulter = &Webhook{} + initContainerDefaultLimitResources = corev1.ResourceList{ + corev1.ResourceCPU: resource.MustParse("500m"), + corev1.ResourceMemory: resource.MustParse("128Mi"), + } + initContainerDefaultRequestedResources = corev1.ResourceList{ + corev1.ResourceCPU: resource.MustParse("1m"), + corev1.ResourceMemory: resource.MustParse("128Mi"), + } +) -var initContainerDefaultLimitResources = corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("500m"), - corev1.ResourceMemory: resource.MustParse("128Mi"), +//+kubebuilder:webhook:path=/mutate-opentelemetry-io-v1alpha1-instrumentation,mutating=true,failurePolicy=fail,sideEffects=None,groups=opentelemetry.io,resources=instrumentations,verbs=create;update,versions=v1alpha1,name=minstrumentation.kb.io,admissionReviewVersions=v1 +// +kubebuilder:webhook:verbs=create;update,path=/validate-opentelemetry-io-v1alpha1-instrumentation,mutating=false,failurePolicy=fail,groups=opentelemetry.io,resources=instrumentations,versions=v1alpha1,name=vinstrumentationcreateupdate.kb.io,sideEffects=none,admissionReviewVersions=v1 +// +kubebuilder:webhook:verbs=delete,path=/validate-opentelemetry-io-v1alpha1-instrumentation,mutating=false,failurePolicy=ignore,groups=opentelemetry.io,resources=instrumentations,versions=v1alpha1,name=vinstrumentationdelete.kb.io,sideEffects=none,admissionReviewVersions=v1 + +// Webhook is isolated because there are known registration issues when a custom webhook is in the same package +// as the types. +// See here: https://github.com/kubernetes-sigs/controller-runtime/issues/780#issuecomment-713408479 +type Webhook struct { + logger logr.Logger + cfg config.Config + scheme *runtime.Scheme } -var initContainerDefaultRequestedResources = corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("1m"), - corev1.ResourceMemory: resource.MustParse("128Mi"), + +func (w Webhook) Default(ctx context.Context, obj runtime.Object) error { + instrumentation, ok := obj.(*v1alpha1.Instrumentation) + if !ok { + return fmt.Errorf("expected an Instrumentation, received %T", obj) + } + return w.defaulter(instrumentation) } -func (r *Instrumentation) SetupWebhookWithManager(mgr ctrl.Manager) error { - return ctrl.NewWebhookManagedBy(mgr). - For(r). - Complete() +func (w Webhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { + inst, ok := obj.(*v1alpha1.Instrumentation) + if !ok { + return nil, fmt.Errorf("expected an Instrumentation, received %T", obj) + } + return w.validate(inst) } -//+kubebuilder:webhook:path=/mutate-opentelemetry-io-v1alpha1-instrumentation,mutating=true,failurePolicy=fail,sideEffects=None,groups=opentelemetry.io,resources=instrumentations,verbs=create;update,versions=v1alpha1,name=minstrumentation.kb.io,admissionReviewVersions=v1 +func (w Webhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { + inst, ok := newObj.(*v1alpha1.Instrumentation) + if !ok { + return nil, fmt.Errorf("expected an Instrumentation, received %T", newObj) + } + return w.validate(inst) +} -var _ webhook.Defaulter = &Instrumentation{} +func (w Webhook) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { + inst, ok := obj.(*v1alpha1.Instrumentation) + if !ok || inst == nil { + return nil, fmt.Errorf("expected an Instrumentation, received %T", obj) + } + return w.validate(inst) +} -// Default implements webhook.Defaulter so a webhook will be registered for the type. -func (r *Instrumentation) Default() { - instrumentationlog.Info("default", "name", r.Name) +func (w Webhook) defaulter(r *v1alpha1.Instrumentation) error { if r.Labels == nil { r.Labels = map[string]string{} } @@ -73,9 +110,7 @@ func (r *Instrumentation) Default() { } if r.Spec.Java.Image == "" { - if val, ok := r.Annotations[AnnotationDefaultAutoInstrumentationJava]; ok { - r.Spec.Java.Image = val - } + r.Spec.Java.Image = w.cfg.AutoInstrumentationJavaImage() } if r.Spec.Java.Resources.Limits == nil { r.Spec.Java.Resources.Limits = corev1.ResourceList{ @@ -90,9 +125,7 @@ func (r *Instrumentation) Default() { } } if r.Spec.NodeJS.Image == "" { - if val, ok := r.Annotations[AnnotationDefaultAutoInstrumentationNodeJS]; ok { - r.Spec.NodeJS.Image = val - } + r.Spec.NodeJS.Image = w.cfg.AutoInstrumentationNodeJSImage() } if r.Spec.NodeJS.Resources.Limits == nil { r.Spec.NodeJS.Resources.Limits = corev1.ResourceList{ @@ -107,9 +140,7 @@ func (r *Instrumentation) Default() { } } if r.Spec.Python.Image == "" { - if val, ok := r.Annotations[AnnotationDefaultAutoInstrumentationPython]; ok { - r.Spec.Python.Image = val - } + r.Spec.Python.Image = w.cfg.AutoInstrumentationPythonImage() } if r.Spec.Python.Resources.Limits == nil { r.Spec.Python.Resources.Limits = corev1.ResourceList{ @@ -124,9 +155,7 @@ func (r *Instrumentation) Default() { } } if r.Spec.DotNet.Image == "" { - if val, ok := r.Annotations[AnnotationDefaultAutoInstrumentationDotNet]; ok { - r.Spec.DotNet.Image = val - } + r.Spec.DotNet.Image = w.cfg.AutoInstrumentationDotNetImage() } if r.Spec.DotNet.Resources.Limits == nil { r.Spec.DotNet.Resources.Limits = corev1.ResourceList{ @@ -141,9 +170,7 @@ func (r *Instrumentation) Default() { } } if r.Spec.Go.Image == "" { - if val, ok := r.Annotations[AnnotationDefaultAutoInstrumentationGo]; ok { - r.Spec.Go.Image = val - } + r.Spec.Go.Image = w.cfg.AutoInstrumentationGoImage() } if r.Spec.Go.Resources.Limits == nil { r.Spec.Go.Resources.Limits = corev1.ResourceList{ @@ -158,9 +185,7 @@ func (r *Instrumentation) Default() { } } if r.Spec.ApacheHttpd.Image == "" { - if val, ok := r.Annotations[AnnotationDefaultAutoInstrumentationApacheHttpd]; ok { - r.Spec.ApacheHttpd.Image = val - } + r.Spec.ApacheHttpd.Image = w.cfg.AutoInstrumentationApacheHttpdImage() } if r.Spec.ApacheHttpd.Resources.Limits == nil { r.Spec.ApacheHttpd.Resources.Limits = initContainerDefaultLimitResources @@ -175,9 +200,7 @@ func (r *Instrumentation) Default() { r.Spec.ApacheHttpd.ConfigPath = "/usr/local/apache2/conf" } if r.Spec.Nginx.Image == "" { - if val, ok := r.Annotations[AnnotationDefaultAutoInstrumentationNginx]; ok { - r.Spec.Nginx.Image = val - } + r.Spec.Nginx.Image = w.cfg.AutoInstrumentationNginxImage() } if r.Spec.Nginx.Resources.Limits == nil { r.Spec.Nginx.Resources.Limits = initContainerDefaultLimitResources @@ -188,29 +211,74 @@ func (r *Instrumentation) Default() { if r.Spec.Nginx.ConfigFile == "" { r.Spec.Nginx.ConfigFile = "/etc/nginx/nginx.conf" } + return nil } -// +kubebuilder:webhook:verbs=create;update,path=/validate-opentelemetry-io-v1alpha1-instrumentation,mutating=false,failurePolicy=fail,groups=opentelemetry.io,resources=instrumentations,versions=v1alpha1,name=vinstrumentationcreateupdate.kb.io,sideEffects=none,admissionReviewVersions=v1 -// +kubebuilder:webhook:verbs=delete,path=/validate-opentelemetry-io-v1alpha1-instrumentation,mutating=false,failurePolicy=ignore,groups=opentelemetry.io,resources=instrumentations,versions=v1alpha1,name=vinstrumentationdelete.kb.io,sideEffects=none,admissionReviewVersions=v1 - -var _ webhook.Validator = &Instrumentation{} +func (w Webhook) validate(r *v1alpha1.Instrumentation) (admission.Warnings, error) { + var warnings []string + switch r.Spec.Sampler.Type { + case "": + warnings = append(warnings, "sampler type not set") + case v1alpha1.TraceIDRatio, v1alpha1.ParentBasedTraceIDRatio: + if r.Spec.Sampler.Argument != "" { + rate, err := strconv.ParseFloat(r.Spec.Sampler.Argument, 64) + if err != nil { + return warnings, fmt.Errorf("spec.sampler.argument is not a number: %s", r.Spec.Sampler.Argument) + } + if rate < 0 || rate > 1 { + return warnings, fmt.Errorf("spec.sampler.argument should be in rage [0..1]: %s", r.Spec.Sampler.Argument) + } + } + case v1alpha1.JaegerRemote, v1alpha1.ParentBasedJaegerRemote: + // value is a comma separated list of endpoint, pollingIntervalMs, initialSamplingRate + // Example: `endpoint=http://localhost:14250,pollingIntervalMs=5000,initialSamplingRate=0.25` + if r.Spec.Sampler.Argument != "" { + err := validateJaegerRemoteSamplerArgument(r.Spec.Sampler.Argument) -// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. -func (r *Instrumentation) ValidateCreate() (admission.Warnings, error) { - instrumentationlog.Info("validate create", "name", r.Name) - return nil, r.validate() -} + if err != nil { + return warnings, fmt.Errorf("spec.sampler.argument is not a valid argument for sampler %s: %w", r.Spec.Sampler.Type, err) + } + } + case v1alpha1.AlwaysOn, v1alpha1.AlwaysOff, v1alpha1.ParentBasedAlwaysOn, v1alpha1.ParentBasedAlwaysOff, v1alpha1.XRaySampler: + default: + return warnings, fmt.Errorf("spec.sampler.type is not valid: %s", r.Spec.Sampler.Type) + } -// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. -func (r *Instrumentation) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { - instrumentationlog.Info("validate update", "name", r.Name) - return nil, r.validate() + // validate env vars + if err := w.validateEnv(r.Spec.Env); err != nil { + return warnings, err + } + if err := w.validateEnv(r.Spec.Java.Env); err != nil { + return warnings, err + } + if err := w.validateEnv(r.Spec.NodeJS.Env); err != nil { + return warnings, err + } + if err := w.validateEnv(r.Spec.Python.Env); err != nil { + return warnings, err + } + if err := w.validateEnv(r.Spec.DotNet.Env); err != nil { + return warnings, err + } + if err := w.validateEnv(r.Spec.Go.Env); err != nil { + return warnings, err + } + if err := w.validateEnv(r.Spec.ApacheHttpd.Env); err != nil { + return warnings, err + } + if err := w.validateEnv(r.Spec.Nginx.Env); err != nil { + return warnings, err + } + return warnings, nil } -// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. -func (r *Instrumentation) ValidateDelete() (admission.Warnings, error) { - instrumentationlog.Info("validate delete", "name", r.Name) - return nil, nil +func (w Webhook) validateEnv(envs []corev1.EnvVar) error { + for _, env := range envs { + if !strings.HasPrefix(env.Name, envPrefix) && !strings.HasPrefix(env.Name, envSplunkPrefix) { + return fmt.Errorf("env name should start with \"OTEL_\" or \"SPLUNK_\": %s", env.Name) + } + } + return nil } func validateJaegerRemoteSamplerArgument(argument string) error { @@ -244,68 +312,19 @@ func validateJaegerRemoteSamplerArgument(argument string) error { return nil } -func (r *Instrumentation) validate() error { - switch r.Spec.Sampler.Type { - case "": // not set, do nothing - case TraceIDRatio, ParentBasedTraceIDRatio: - if r.Spec.Sampler.Argument != "" { - rate, err := strconv.ParseFloat(r.Spec.Sampler.Argument, 64) - if err != nil { - return fmt.Errorf("spec.sampler.argument is not a number: %s", r.Spec.Sampler.Argument) - } - if rate < 0 || rate > 1 { - return fmt.Errorf("spec.sampler.argument should be in rage [0..1]: %s", r.Spec.Sampler.Argument) - } - } - case JaegerRemote, ParentBasedJaegerRemote: - // value is a comma separated list of endpoint, pollingIntervalMs, initialSamplingRate - // Example: `endpoint=http://localhost:14250,pollingIntervalMs=5000,initialSamplingRate=0.25` - if r.Spec.Sampler.Argument != "" { - err := validateJaegerRemoteSamplerArgument(r.Spec.Sampler.Argument) - - if err != nil { - return fmt.Errorf("spec.sampler.argument is not a valid argument for sampler %s: %w", r.Spec.Sampler.Type, err) - } - } - case AlwaysOn, AlwaysOff, ParentBasedAlwaysOn, ParentBasedAlwaysOff, XRaySampler: - default: - return fmt.Errorf("spec.sampler.type is not valid: %s", r.Spec.Sampler.Type) - } - - // validate env vars - if err := r.validateEnv(r.Spec.Env); err != nil { - return err - } - if err := r.validateEnv(r.Spec.Java.Env); err != nil { - return err - } - if err := r.validateEnv(r.Spec.NodeJS.Env); err != nil { - return err - } - if err := r.validateEnv(r.Spec.Python.Env); err != nil { - return err - } - if err := r.validateEnv(r.Spec.DotNet.Env); err != nil { - return err - } - if err := r.validateEnv(r.Spec.Go.Env); err != nil { - return err +func NewInstrumentationWebhook(mgr ctrl.Manager, cfg config.Config) *Webhook { + return &Webhook{ + logger: mgr.GetLogger().WithValues("handler", "InstrumentationWebhook"), + scheme: mgr.GetScheme(), + cfg: cfg, } - if err := r.validateEnv(r.Spec.ApacheHttpd.Env); err != nil { - return err - } - if err := r.validateEnv(r.Spec.Nginx.Env); err != nil { - return err - } - - return nil } -func (r *Instrumentation) validateEnv(envs []corev1.EnvVar) error { - for _, env := range envs { - if !strings.HasPrefix(env.Name, envPrefix) && !strings.HasPrefix(env.Name, envSplunkPrefix) { - return fmt.Errorf("env name should start with \"OTEL_\" or \"SPLUNK_\": %s", env.Name) - } - } - return nil +func SetupInstrumentationValidatingWebhookWithManager(mgr ctrl.Manager, cfg config.Config) error { + ivw := NewInstrumentationWebhook(mgr, cfg) + return ctrl.NewWebhookManagedBy(mgr). + For(&v1alpha1.Instrumentation{}). + WithValidator(ivw). + WithDefaulter(ivw). + Complete() } diff --git a/apis/v1alpha1/instrumentation_webhook_test.go b/internal/webhook/instrumentation/webhook_test.go similarity index 53% rename from apis/v1alpha1/instrumentation_webhook_test.go rename to internal/webhook/instrumentation/webhook_test.go index 9791a93014..0a6fa331a1 100644 --- a/apis/v1alpha1/instrumentation_webhook_test.go +++ b/internal/webhook/instrumentation/webhook_test.go @@ -12,29 +12,32 @@ // See the License for the specific language governing permissions and // limitations under the License. -package v1alpha1 +package instrumentation import ( + "context" "testing" "github.com/stretchr/testify/assert" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" + "github.com/open-telemetry/opentelemetry-operator/internal/config" ) func TestInstrumentationDefaultingWebhook(t *testing.T) { - inst := &Instrumentation{ - ObjectMeta: metav1.ObjectMeta{ - Annotations: map[string]string{ - AnnotationDefaultAutoInstrumentationJava: "java-img:1", - AnnotationDefaultAutoInstrumentationNodeJS: "nodejs-img:1", - AnnotationDefaultAutoInstrumentationPython: "python-img:1", - AnnotationDefaultAutoInstrumentationDotNet: "dotnet-img:1", - AnnotationDefaultAutoInstrumentationApacheHttpd: "apache-httpd-img:1", - AnnotationDefaultAutoInstrumentationNginx: "nginx-img:1", - }, - }, - } - inst.Default() + inst := &v1alpha1.Instrumentation{} + err := Webhook{ + cfg: config.New( + config.WithAutoInstrumentationJavaImage("java-img:1"), + config.WithAutoInstrumentationNodeJSImage("nodejs-img:1"), + config.WithAutoInstrumentationPythonImage("python-img:1"), + config.WithAutoInstrumentationDotNetImage("dotnet-img:1"), + config.WithAutoInstrumentationApacheHttpdImage("apache-httpd-img:1"), + config.WithAutoInstrumentationNginxImage("nginx-img:1"), + ), + }.Default(context.Background(), inst) + assert.NoError(t, err) assert.Equal(t, "java-img:1", inst.Spec.Java.Image) assert.Equal(t, "nodejs-img:1", inst.Spec.NodeJS.Image) assert.Equal(t, "python-img:1", inst.Spec.Python.Image) @@ -45,31 +48,34 @@ func TestInstrumentationDefaultingWebhook(t *testing.T) { func TestInstrumentationValidatingWebhook(t *testing.T) { tests := []struct { - name string - err string - inst Instrumentation + name string + err string + warnings admission.Warnings + inst v1alpha1.Instrumentation }{ { name: "all defaults", - inst: Instrumentation{ - Spec: InstrumentationSpec{}, + inst: v1alpha1.Instrumentation{ + Spec: v1alpha1.InstrumentationSpec{}, }, + warnings: []string{"sampler type not set"}, }, { name: "sampler configuration not present", - inst: Instrumentation{ - Spec: InstrumentationSpec{ - Sampler: Sampler{}, + inst: v1alpha1.Instrumentation{ + Spec: v1alpha1.InstrumentationSpec{ + Sampler: v1alpha1.Sampler{}, }, }, + warnings: []string{"sampler type not set"}, }, { name: "argument is not a number", err: "spec.sampler.argument is not a number", - inst: Instrumentation{ - Spec: InstrumentationSpec{ - Sampler: Sampler{ - Type: ParentBasedTraceIDRatio, + inst: v1alpha1.Instrumentation{ + Spec: v1alpha1.InstrumentationSpec{ + Sampler: v1alpha1.Sampler{ + Type: v1alpha1.ParentBasedTraceIDRatio, Argument: "abc", }, }, @@ -78,10 +84,10 @@ func TestInstrumentationValidatingWebhook(t *testing.T) { { name: "argument is a wrong number", err: "spec.sampler.argument should be in rage [0..1]", - inst: Instrumentation{ - Spec: InstrumentationSpec{ - Sampler: Sampler{ - Type: ParentBasedTraceIDRatio, + inst: v1alpha1.Instrumentation{ + Spec: v1alpha1.InstrumentationSpec{ + Sampler: v1alpha1.Sampler{ + Type: v1alpha1.ParentBasedTraceIDRatio, Argument: "1.99", }, }, @@ -89,10 +95,10 @@ func TestInstrumentationValidatingWebhook(t *testing.T) { }, { name: "argument is a number", - inst: Instrumentation{ - Spec: InstrumentationSpec{ - Sampler: Sampler{ - Type: ParentBasedTraceIDRatio, + inst: v1alpha1.Instrumentation{ + Spec: v1alpha1.InstrumentationSpec{ + Sampler: v1alpha1.Sampler{ + Type: v1alpha1.ParentBasedTraceIDRatio, Argument: "0.99", }, }, @@ -100,10 +106,10 @@ func TestInstrumentationValidatingWebhook(t *testing.T) { }, { name: "argument is missing", - inst: Instrumentation{ - Spec: InstrumentationSpec{ - Sampler: Sampler{ - Type: ParentBasedTraceIDRatio, + inst: v1alpha1.Instrumentation{ + Spec: v1alpha1.InstrumentationSpec{ + Sampler: v1alpha1.Sampler{ + Type: v1alpha1.ParentBasedTraceIDRatio, }, }, }, @@ -112,19 +118,20 @@ func TestInstrumentationValidatingWebhook(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { + ctx := context.Background() if test.err == "" { - warnings, err := test.inst.ValidateCreate() - assert.Nil(t, warnings) + warnings, err := Webhook{}.ValidateCreate(ctx, &test.inst) + assert.Equal(t, test.warnings, warnings) assert.Nil(t, err) - warnings, err = test.inst.ValidateUpdate(nil) - assert.Nil(t, warnings) + warnings, err = Webhook{}.ValidateUpdate(ctx, nil, &test.inst) + assert.Equal(t, test.warnings, warnings) assert.Nil(t, err) } else { - warnings, err := test.inst.ValidateCreate() - assert.Nil(t, warnings) + warnings, err := Webhook{}.ValidateCreate(ctx, &test.inst) + assert.Equal(t, test.warnings, warnings) assert.Contains(t, err.Error(), test.err) - warnings, err = test.inst.ValidateUpdate(nil) - assert.Nil(t, warnings) + warnings, err = Webhook{}.ValidateUpdate(ctx, nil, &test.inst) + assert.Equal(t, test.warnings, warnings) assert.Contains(t, err.Error(), test.err) } }) @@ -158,31 +165,32 @@ func TestInstrumentationJaegerRemote(t *testing.T) { }, } - samplers := []SamplerType{JaegerRemote, ParentBasedJaegerRemote} + samplers := []v1alpha1.SamplerType{v1alpha1.JaegerRemote, v1alpha1.ParentBasedJaegerRemote} for _, sampler := range samplers { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - inst := Instrumentation{ - Spec: InstrumentationSpec{ - Sampler: Sampler{ + inst := v1alpha1.Instrumentation{ + Spec: v1alpha1.InstrumentationSpec{ + Sampler: v1alpha1.Sampler{ Type: sampler, Argument: test.arg, }, }, } + ctx := context.Background() if test.err == "" { - warnings, err := inst.ValidateCreate() + warnings, err := Webhook{}.ValidateCreate(ctx, &inst) assert.Nil(t, warnings) assert.Nil(t, err) - warnings, err = inst.ValidateUpdate(nil) + warnings, err = Webhook{}.ValidateUpdate(ctx, nil, &inst) assert.Nil(t, warnings) assert.Nil(t, err) } else { - warnings, err := inst.ValidateCreate() + warnings, err := Webhook{}.ValidateCreate(ctx, &inst) assert.Nil(t, warnings) assert.Contains(t, err.Error(), test.err) - warnings, err = inst.ValidateUpdate(nil) + warnings, err = Webhook{}.ValidateUpdate(ctx, nil, &inst) assert.Nil(t, warnings) assert.Contains(t, err.Error(), test.err) } diff --git a/internal/webhookhandler/webhookhandler.go b/internal/webhook/sidecar/webhookhandler.go similarity index 91% rename from internal/webhookhandler/webhookhandler.go rename to internal/webhook/sidecar/webhookhandler.go index 11f166b790..dce007e3ce 100644 --- a/internal/webhookhandler/webhookhandler.go +++ b/internal/webhook/sidecar/webhookhandler.go @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Package webhookhandler contains the webhook that injects sidecars into pods. -package webhookhandler +// Package sidecar contains the webhook that injects sidecars into pods. +package sidecar import ( "context" @@ -35,7 +35,7 @@ import ( // +kubebuilder:rbac:groups=opentelemetry.io,resources=instrumentations,verbs=get;list;watch // +kubebuilder:rbac:groups="apps",resources=replicasets,verbs=get;list;watch -var _ WebhookHandler = (*podSidecarInjector)(nil) +var _ WebhookHandler = (*sidecarWebhook)(nil) // WebhookHandler is a webhook handler that analyzes new pods and injects appropriate sidecars into it. type WebhookHandler interface { @@ -43,7 +43,7 @@ type WebhookHandler interface { } // the implementation. -type podSidecarInjector struct { +type sidecarWebhook struct { client client.Client decoder *admission.Decoder logger logr.Logger @@ -58,7 +58,7 @@ type PodMutator interface { // NewWebhookHandler creates a new WebhookHandler. func NewWebhookHandler(cfg config.Config, logger logr.Logger, decoder *admission.Decoder, cl client.Client, podMutators []PodMutator) WebhookHandler { - return &podSidecarInjector{ + return &sidecarWebhook{ config: cfg, decoder: decoder, logger: logger, @@ -67,7 +67,7 @@ func NewWebhookHandler(cfg config.Config, logger logr.Logger, decoder *admission } } -func (p *podSidecarInjector) Handle(ctx context.Context, req admission.Request) admission.Response { +func (p *sidecarWebhook) Handle(ctx context.Context, req admission.Request) admission.Response { pod := corev1.Pod{} err := p.decoder.Decode(req, &pod) if err != nil { diff --git a/internal/webhookhandler/webhookhandler_suite_test.go b/internal/webhook/sidecar/webhookhandler_suite_test.go similarity index 93% rename from internal/webhookhandler/webhookhandler_suite_test.go rename to internal/webhook/sidecar/webhookhandler_suite_test.go index 5c188e7ddd..67c9c37010 100644 --- a/internal/webhookhandler/webhookhandler_suite_test.go +++ b/internal/webhook/sidecar/webhookhandler_suite_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package webhookhandler_test +package sidecar_test import ( "context" @@ -37,6 +37,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/webhook" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" + "github.com/open-telemetry/opentelemetry-operator/internal/config" + collectorwebhook "github.com/open-telemetry/opentelemetry-operator/internal/webhook/collector" // +kubebuilder:scaffold:imports ) @@ -97,7 +99,7 @@ func TestMain(m *testing.M) { os.Exit(1) } - if err = (&v1alpha1.OpenTelemetryCollector{}).SetupWebhookWithManager(mgr); err != nil { + if err = collectorwebhook.SetupCollectorValidatingWebhookWithManager(mgr, config.New()); err != nil { fmt.Printf("failed to SetupWebhookWithManager: %v", err) os.Exit(1) } diff --git a/internal/webhookhandler/webhookhandler_test.go b/internal/webhook/sidecar/webhookhandler_test.go similarity index 99% rename from internal/webhookhandler/webhookhandler_test.go rename to internal/webhook/sidecar/webhookhandler_test.go index 91aa2c3ccc..5e93358efc 100644 --- a/internal/webhookhandler/webhookhandler_test.go +++ b/internal/webhook/sidecar/webhookhandler_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package webhookhandler_test +package sidecar_test import ( "context" @@ -33,7 +33,7 @@ import ( "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/naming" - . "github.com/open-telemetry/opentelemetry-operator/internal/webhookhandler" + . "github.com/open-telemetry/opentelemetry-operator/internal/webhook/sidecar" "github.com/open-telemetry/opentelemetry-operator/pkg/sidecar" ) diff --git a/main.go b/main.go index 2f04fb0835..291d05e7fe 100644 --- a/main.go +++ b/main.go @@ -28,7 +28,6 @@ import ( monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" "github.com/spf13/pflag" colfeaturegate "go.opentelemetry.io/collector/featuregate" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" k8sruntime "k8s.io/apimachinery/pkg/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime" clientgoscheme "k8s.io/client-go/kubernetes/scheme" @@ -48,7 +47,9 @@ import ( "github.com/open-telemetry/opentelemetry-operator/controllers" "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/version" - "github.com/open-telemetry/opentelemetry-operator/internal/webhookhandler" + collectorwebhook "github.com/open-telemetry/opentelemetry-operator/internal/webhook/collector" + instrumentationwebhook "github.com/open-telemetry/opentelemetry-operator/internal/webhook/instrumentation" + sidecarwebhook "github.com/open-telemetry/opentelemetry-operator/internal/webhook/sidecar" "github.com/open-telemetry/opentelemetry-operator/pkg/autodetect" collectorupgrade "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" "github.com/open-telemetry/opentelemetry-operator/pkg/featuregate" @@ -70,7 +71,6 @@ type tlsConfig struct { func init() { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(otelv1alpha1.AddToScheme(scheme)) utilruntime.Must(routev1.AddToScheme(scheme)) utilruntime.Must(monitoringv1.AddToScheme(scheme)) @@ -248,29 +248,18 @@ func main() { } if os.Getenv("ENABLE_WEBHOOKS") != "false" { - if err = (&otelv1alpha1.OpenTelemetryCollector{}).SetupWebhookWithManager(mgr); err != nil { + if err = collectorwebhook.SetupCollectorValidatingWebhookWithManager(mgr, cfg); err != nil { setupLog.Error(err, "unable to create webhook", "webhook", "OpenTelemetryCollector") os.Exit(1) } - if err = (&otelv1alpha1.Instrumentation{ - ObjectMeta: metav1.ObjectMeta{ - Annotations: map[string]string{ - otelv1alpha1.AnnotationDefaultAutoInstrumentationJava: autoInstrumentationJava, - otelv1alpha1.AnnotationDefaultAutoInstrumentationNodeJS: autoInstrumentationNodeJS, - otelv1alpha1.AnnotationDefaultAutoInstrumentationPython: autoInstrumentationPython, - otelv1alpha1.AnnotationDefaultAutoInstrumentationDotNet: autoInstrumentationDotNet, - otelv1alpha1.AnnotationDefaultAutoInstrumentationGo: autoInstrumentationGo, - otelv1alpha1.AnnotationDefaultAutoInstrumentationApacheHttpd: autoInstrumentationApacheHttpd, - otelv1alpha1.AnnotationDefaultAutoInstrumentationNginx: autoInstrumentationNginx}, - }, - }).SetupWebhookWithManager(mgr); err != nil { + if err = instrumentationwebhook.SetupInstrumentationValidatingWebhookWithManager(mgr, cfg); err != nil { setupLog.Error(err, "unable to create webhook", "webhook", "Instrumentation") os.Exit(1) } decoder := admission.NewDecoder(mgr.GetScheme()) mgr.GetWebhookServer().Register("/mutate-v1-pod", &webhook.Admission{ - Handler: webhookhandler.NewWebhookHandler(cfg, ctrl.Log.WithName("pod-webhook"), decoder, mgr.GetClient(), - []webhookhandler.PodMutator{ + Handler: sidecarwebhook.NewWebhookHandler(cfg, ctrl.Log.WithName("pod-webhook"), decoder, mgr.GetClient(), + []sidecarwebhook.PodMutator{ sidecar.NewMutator(logger, cfg, mgr.GetClient()), instrumentation.NewMutator(logger, mgr.GetClient(), mgr.GetEventRecorderFor("opentelemetry-operator")), }), diff --git a/pkg/collector/reconcile/suite_test.go b/pkg/collector/reconcile/suite_test.go index 9feec99458..a67d4d4335 100644 --- a/pkg/collector/reconcile/suite_test.go +++ b/pkg/collector/reconcile/suite_test.go @@ -52,6 +52,7 @@ import ( "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/manifests" "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/testdata" + collectorwebhook "github.com/open-telemetry/opentelemetry-operator/internal/webhook/collector" ) var ( @@ -135,7 +136,7 @@ func TestMain(m *testing.M) { os.Exit(1) } - if err = (&v1alpha1.OpenTelemetryCollector{}).SetupWebhookWithManager(mgr); err != nil { + if err = collectorwebhook.SetupCollectorValidatingWebhookWithManager(mgr, config.New()); err != nil { fmt.Printf("failed to SetupWebhookWithManager: %v", err) os.Exit(1) } diff --git a/pkg/collector/upgrade/suite_test.go b/pkg/collector/upgrade/suite_test.go index 63c5cf4934..b99e64d6de 100644 --- a/pkg/collector/upgrade/suite_test.go +++ b/pkg/collector/upgrade/suite_test.go @@ -37,6 +37,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/webhook" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" + "github.com/open-telemetry/opentelemetry-operator/internal/config" + collectorwebhook "github.com/open-telemetry/opentelemetry-operator/internal/webhook/collector" // +kubebuilder:scaffold:imports ) @@ -48,6 +50,7 @@ var ( cancel context.CancelFunc err error cfg *rest.Config + conf = config.New() ) func TestMain(m *testing.M) { @@ -98,7 +101,7 @@ func TestMain(m *testing.M) { os.Exit(1) } - if err = (&v1alpha1.OpenTelemetryCollector{}).SetupWebhookWithManager(mgr); err != nil { + if err = collectorwebhook.SetupCollectorValidatingWebhookWithManager(mgr, conf); err != nil { fmt.Printf("failed to SetupWebhookWithManager: %v", err) os.Exit(1) } diff --git a/pkg/instrumentation/podmutator.go b/pkg/instrumentation/podmutator.go index 49f93d7067..7c122091f7 100644 --- a/pkg/instrumentation/podmutator.go +++ b/pkg/instrumentation/podmutator.go @@ -27,7 +27,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/internal/webhookhandler" + "github.com/open-telemetry/opentelemetry-operator/internal/webhook/sidecar" "github.com/open-telemetry/opentelemetry-operator/pkg/featuregate" ) @@ -191,7 +191,7 @@ func (langInsts *languageInstrumentations) setInstrumentationLanguageContainers( } } -var _ webhookhandler.PodMutator = (*instPodMutator)(nil) +var _ sidecar.PodMutator = (*instPodMutator)(nil) func NewMutator(logger logr.Logger, client client.Client, recorder record.EventRecorder) *instPodMutator { return &instPodMutator{ diff --git a/pkg/instrumentation/upgrade/upgrade.go b/pkg/instrumentation/upgrade/upgrade.go index 0b45be4fb0..33fa2e32d6 100644 --- a/pkg/instrumentation/upgrade/upgrade.go +++ b/pkg/instrumentation/upgrade/upgrade.go @@ -75,91 +75,84 @@ func (u *InstrumentationUpgrade) ManagedInstances(ctx context.Context) error { } func (u *InstrumentationUpgrade) upgrade(_ context.Context, inst v1alpha1.Instrumentation) v1alpha1.Instrumentation { - autoInstJava := inst.Annotations[v1alpha1.AnnotationDefaultAutoInstrumentationJava] + autoInstJava := u.DefaultAutoInstJava if autoInstJava != "" { if featuregate.EnableJavaAutoInstrumentationSupport.IsEnabled() { // upgrade the image only if the image matches the annotation if inst.Spec.Java.Image == autoInstJava { inst.Spec.Java.Image = u.DefaultAutoInstJava - inst.Annotations[v1alpha1.AnnotationDefaultAutoInstrumentationJava] = u.DefaultAutoInstJava } } else { u.Logger.Error(nil, "support for Java auto instrumentation is not enabled") u.Recorder.Event(inst.DeepCopy(), "Warning", "InstrumentationUpgradeRejected", "support for Java auto instrumentation is not enabled") } } - autoInstNodeJS := inst.Annotations[v1alpha1.AnnotationDefaultAutoInstrumentationNodeJS] + autoInstNodeJS := u.DefaultAutoInstNodeJS if autoInstNodeJS != "" { if featuregate.EnableNodeJSAutoInstrumentationSupport.IsEnabled() { // upgrade the image only if the image matches the annotation if inst.Spec.NodeJS.Image == autoInstNodeJS { inst.Spec.NodeJS.Image = u.DefaultAutoInstNodeJS - inst.Annotations[v1alpha1.AnnotationDefaultAutoInstrumentationNodeJS] = u.DefaultAutoInstNodeJS } } else { u.Logger.Error(nil, "support for NodeJS auto instrumentation is not enabled") u.Recorder.Event(inst.DeepCopy(), "Warning", "InstrumentationUpgradeRejected", "support for NodeJS auto instrumentation is not enabled") } } - autoInstPython := inst.Annotations[v1alpha1.AnnotationDefaultAutoInstrumentationPython] + autoInstPython := u.DefaultAutoInstNodeJS if autoInstPython != "" { if featuregate.EnablePythonAutoInstrumentationSupport.IsEnabled() { // upgrade the image only if the image matches the annotation if inst.Spec.Python.Image == autoInstPython { inst.Spec.Python.Image = u.DefaultAutoInstPython - inst.Annotations[v1alpha1.AnnotationDefaultAutoInstrumentationPython] = u.DefaultAutoInstPython } } else { u.Logger.Error(nil, "support for Python auto instrumentation is not enabled") u.Recorder.Event(inst.DeepCopy(), "Warning", "InstrumentationUpgradeRejected", "support for Python auto instrumentation is not enabled") } } - autoInstDotnet := inst.Annotations[v1alpha1.AnnotationDefaultAutoInstrumentationDotNet] + autoInstDotnet := u.DefaultAutoInstDotNet if autoInstDotnet != "" { if featuregate.EnableDotnetAutoInstrumentationSupport.IsEnabled() { // upgrade the image only if the image matches the annotation if inst.Spec.DotNet.Image == autoInstDotnet { inst.Spec.DotNet.Image = u.DefaultAutoInstDotNet - inst.Annotations[v1alpha1.AnnotationDefaultAutoInstrumentationDotNet] = u.DefaultAutoInstDotNet } } else { u.Logger.Error(nil, "support for .NET auto instrumentation is not enabled") u.Recorder.Event(inst.DeepCopy(), "Warning", "InstrumentationUpgradeRejected", "support for .NET auto instrumentation is not enabled") } } - autoInstGo := inst.Annotations[v1alpha1.AnnotationDefaultAutoInstrumentationGo] + autoInstGo := u.DefaultAutoInstGo if autoInstGo != "" { if featuregate.EnableGoAutoInstrumentationSupport.IsEnabled() { // upgrade the image only if the image matches the annotation if inst.Spec.Go.Image == autoInstGo { inst.Spec.Go.Image = u.DefaultAutoInstGo - inst.Annotations[v1alpha1.AnnotationDefaultAutoInstrumentationGo] = u.DefaultAutoInstGo } } else { u.Logger.Error(nil, "support for Go auto instrumentation is not enabled") u.Recorder.Event(inst.DeepCopy(), "Warning", "InstrumentationUpgradeRejected", "support for Go auto instrumentation is not enabled") } } - autoInstApacheHttpd := inst.Annotations[v1alpha1.AnnotationDefaultAutoInstrumentationApacheHttpd] + autoInstApacheHttpd := u.DefaultAutoInstApacheHttpd if autoInstApacheHttpd != "" { if featuregate.EnableApacheHTTPAutoInstrumentationSupport.IsEnabled() { // upgrade the image only if the image matches the annotation if inst.Spec.ApacheHttpd.Image == autoInstApacheHttpd { inst.Spec.ApacheHttpd.Image = u.DefaultAutoInstApacheHttpd - inst.Annotations[v1alpha1.AnnotationDefaultAutoInstrumentationApacheHttpd] = u.DefaultAutoInstApacheHttpd } } else { u.Logger.Error(nil, "support for Apache HTTPD auto instrumentation is not enabled") u.Recorder.Event(inst.DeepCopy(), "Warning", "InstrumentationUpgradeRejected", "support for Apache HTTPD auto instrumentation is not enabled") } } - autoInstNginx := inst.Annotations[v1alpha1.AnnotationDefaultAutoInstrumentationNginx] + autoInstNginx := u.DefaultAutoInstNginx if autoInstNginx != "" { if featuregate.EnableNginxAutoInstrumentationSupport.IsEnabled() { // upgrade the image only if the image matches the annotation if inst.Spec.Nginx.Image == autoInstNginx { inst.Spec.Nginx.Image = u.DefaultAutoInstNginx - inst.Annotations[v1alpha1.AnnotationDefaultAutoInstrumentationNginx] = u.DefaultAutoInstNginx } } else { u.Logger.Error(nil, "support for Nginx auto instrumentation is not enabled") diff --git a/pkg/instrumentation/upgrade/upgrade_test.go b/pkg/instrumentation/upgrade/upgrade_test.go index f8d989810b..4a36478a0c 100644 --- a/pkg/instrumentation/upgrade/upgrade_test.go +++ b/pkg/instrumentation/upgrade/upgrade_test.go @@ -28,6 +28,8 @@ import ( "k8s.io/apimachinery/pkg/types" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" + "github.com/open-telemetry/opentelemetry-operator/internal/config" + instrumentationwebhook "github.com/open-telemetry/opentelemetry-operator/internal/webhook/instrumentation" "github.com/open-telemetry/opentelemetry-operator/pkg/featuregate" ) @@ -62,15 +64,6 @@ func TestUpgrade(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: "my-inst", Namespace: nsName, - Annotations: map[string]string{ - v1alpha1.AnnotationDefaultAutoInstrumentationJava: "java:1", - v1alpha1.AnnotationDefaultAutoInstrumentationNodeJS: "nodejs:1", - v1alpha1.AnnotationDefaultAutoInstrumentationPython: "python:1", - v1alpha1.AnnotationDefaultAutoInstrumentationDotNet: "dotnet:1", - v1alpha1.AnnotationDefaultAutoInstrumentationGo: "go:1", - v1alpha1.AnnotationDefaultAutoInstrumentationApacheHttpd: "apache-httpd:1", - v1alpha1.AnnotationDefaultAutoInstrumentationNginx: "nginx:1", - }, }, Spec: v1alpha1.InstrumentationSpec{ Sampler: v1alpha1.Sampler{ @@ -78,7 +71,17 @@ func TestUpgrade(t *testing.T) { }, }, } - inst.Default() + err = instrumentationwebhook.NewInstrumentationWebhook(nil, + config.New( + config.WithAutoInstrumentationJavaImage("java-img:1"), + config.WithAutoInstrumentationNodeJSImage("nodejs-img:1"), + config.WithAutoInstrumentationPythonImage("python-img:1"), + config.WithAutoInstrumentationDotNetImage("dotnet-img:1"), + config.WithAutoInstrumentationApacheHttpdImage("apache-httpd-img:1"), + config.WithAutoInstrumentationNginxImage("nginx-img:1"), + ), + ).Default(context.Background(), inst) + assert.NotNil(t, err) assert.Equal(t, "java:1", inst.Spec.Java.Image) assert.Equal(t, "nodejs:1", inst.Spec.NodeJS.Image) assert.Equal(t, "python:1", inst.Spec.Python.Image) @@ -109,18 +112,11 @@ func TestUpgrade(t *testing.T) { Name: "my-inst", }, &updated) require.NoError(t, err) - assert.Equal(t, "java:2", updated.Annotations[v1alpha1.AnnotationDefaultAutoInstrumentationJava]) assert.Equal(t, "java:2", updated.Spec.Java.Image) - assert.Equal(t, "nodejs:2", updated.Annotations[v1alpha1.AnnotationDefaultAutoInstrumentationNodeJS]) assert.Equal(t, "nodejs:2", updated.Spec.NodeJS.Image) - assert.Equal(t, "python:2", updated.Annotations[v1alpha1.AnnotationDefaultAutoInstrumentationPython]) assert.Equal(t, "python:2", updated.Spec.Python.Image) - assert.Equal(t, "dotnet:2", updated.Annotations[v1alpha1.AnnotationDefaultAutoInstrumentationDotNet]) assert.Equal(t, "dotnet:2", updated.Spec.DotNet.Image) - assert.Equal(t, "go:2", updated.Annotations[v1alpha1.AnnotationDefaultAutoInstrumentationGo]) assert.Equal(t, "go:2", updated.Spec.Go.Image) - assert.Equal(t, "apache-httpd:2", updated.Annotations[v1alpha1.AnnotationDefaultAutoInstrumentationApacheHttpd]) assert.Equal(t, "apache-httpd:2", updated.Spec.ApacheHttpd.Image) - assert.Equal(t, "nginx:2", updated.Annotations[v1alpha1.AnnotationDefaultAutoInstrumentationNginx]) assert.Equal(t, "nginx:2", updated.Spec.Nginx.Image) } diff --git a/pkg/sidecar/podmutator.go b/pkg/sidecar/podmutator.go index 7f1956e4dd..e94c8be468 100644 --- a/pkg/sidecar/podmutator.go +++ b/pkg/sidecar/podmutator.go @@ -28,7 +28,7 @@ import ( "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" "github.com/open-telemetry/opentelemetry-operator/internal/config" - "github.com/open-telemetry/opentelemetry-operator/internal/webhookhandler" + "github.com/open-telemetry/opentelemetry-operator/internal/webhook/sidecar" ) var ( @@ -43,7 +43,7 @@ type sidecarPodMutator struct { config config.Config } -var _ webhookhandler.PodMutator = (*sidecarPodMutator)(nil) +var _ sidecar.PodMutator = (*sidecarPodMutator)(nil) func NewMutator(logger logr.Logger, config config.Config, client client.Client) *sidecarPodMutator { return &sidecarPodMutator{ From 225e8eb8c236e6952a42b0a2596f209d4172fe1c Mon Sep 17 00:00:00 2001 From: Jacob Aronoff Date: Wed, 11 Oct 2023 12:46:21 -0400 Subject: [PATCH 02/15] moves webhook manifest --- config/webhook/manifests.yaml | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/config/webhook/manifests.yaml b/config/webhook/manifests.yaml index d9adaf855a..310e18215b 100644 --- a/config/webhook/manifests.yaml +++ b/config/webhook/manifests.yaml @@ -10,9 +10,9 @@ webhooks: service: name: webhook-service namespace: system - path: /mutate-opentelemetry-io-v1alpha1-instrumentation + path: /mutate-opentelemetry-io-v1alpha1-opentelemetrycollector failurePolicy: Fail - name: minstrumentation.kb.io + name: mopentelemetrycollector.kb.io rules: - apiGroups: - opentelemetry.io @@ -22,7 +22,7 @@ webhooks: - CREATE - UPDATE resources: - - instrumentations + - opentelemetrycollectors sideEffects: None - admissionReviewVersions: - v1 @@ -30,9 +30,9 @@ webhooks: service: name: webhook-service namespace: system - path: /mutate-opentelemetry-io-v1alpha1-opentelemetrycollector + path: /mutate-opentelemetry-io-v1alpha1-instrumentation failurePolicy: Fail - name: mopentelemetrycollector.kb.io + name: minstrumentation.kb.io rules: - apiGroups: - opentelemetry.io @@ -42,7 +42,7 @@ webhooks: - CREATE - UPDATE resources: - - opentelemetrycollectors + - instrumentations sideEffects: None - admissionReviewVersions: - v1 @@ -76,9 +76,9 @@ webhooks: service: name: webhook-service namespace: system - path: /validate-opentelemetry-io-v1alpha1-instrumentation + path: /validate-opentelemetry-io-v1alpha1-opentelemetrycollector failurePolicy: Fail - name: vinstrumentationcreateupdate.kb.io + name: vopentelemetrycollectorcreateupdate.kb.io rules: - apiGroups: - opentelemetry.io @@ -88,7 +88,7 @@ webhooks: - CREATE - UPDATE resources: - - instrumentations + - opentelemetrycollectors sideEffects: None - admissionReviewVersions: - v1 @@ -96,9 +96,9 @@ webhooks: service: name: webhook-service namespace: system - path: /validate-opentelemetry-io-v1alpha1-instrumentation + path: /validate-opentelemetry-io-v1alpha1-opentelemetrycollector failurePolicy: Ignore - name: vinstrumentationdelete.kb.io + name: vopentelemetrycollectordelete.kb.io rules: - apiGroups: - opentelemetry.io @@ -107,7 +107,7 @@ webhooks: operations: - DELETE resources: - - instrumentations + - opentelemetrycollectors sideEffects: None - admissionReviewVersions: - v1 @@ -115,9 +115,9 @@ webhooks: service: name: webhook-service namespace: system - path: /validate-opentelemetry-io-v1alpha1-opentelemetrycollector + path: /validate-opentelemetry-io-v1alpha1-instrumentation failurePolicy: Fail - name: vopentelemetrycollectorcreateupdate.kb.io + name: vinstrumentationcreateupdate.kb.io rules: - apiGroups: - opentelemetry.io @@ -127,7 +127,7 @@ webhooks: - CREATE - UPDATE resources: - - opentelemetrycollectors + - instrumentations sideEffects: None - admissionReviewVersions: - v1 @@ -135,9 +135,9 @@ webhooks: service: name: webhook-service namespace: system - path: /validate-opentelemetry-io-v1alpha1-opentelemetrycollector + path: /validate-opentelemetry-io-v1alpha1-instrumentation failurePolicy: Ignore - name: vopentelemetrycollectordelete.kb.io + name: vinstrumentationdelete.kb.io rules: - apiGroups: - opentelemetry.io @@ -146,5 +146,5 @@ webhooks: operations: - DELETE resources: - - opentelemetrycollectors + - instrumentations sideEffects: None From ed0c651cc12b0a594dd926ef4eb002eeb025fc8d Mon Sep 17 00:00:00 2001 From: Jacob Aronoff Date: Wed, 11 Oct 2023 12:50:50 -0400 Subject: [PATCH 03/15] rename --- controllers/suite_test.go | 2 +- internal/webhook/collector/webhook.go | 2 +- internal/webhook/instrumentation/webhook.go | 4 ++-- internal/webhook/sidecar/webhookhandler_suite_test.go | 2 +- main.go | 4 ++-- pkg/collector/reconcile/suite_test.go | 2 +- pkg/collector/upgrade/suite_test.go | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/controllers/suite_test.go b/controllers/suite_test.go index 6e71aacabc..bc2797d64f 100644 --- a/controllers/suite_test.go +++ b/controllers/suite_test.go @@ -126,7 +126,7 @@ func TestMain(m *testing.M) { os.Exit(1) } - if err = collectorwebhook.SetupCollectorValidatingWebhookWithManager(mgr, config.New()); err != nil { + if err = collectorwebhook.SetupWebhook(mgr, config.New()); err != nil { fmt.Printf("failed to SetupWebhookWithManager: %v", err) os.Exit(1) } diff --git a/internal/webhook/collector/webhook.go b/internal/webhook/collector/webhook.go index f267eea25b..2224ba85c7 100644 --- a/internal/webhook/collector/webhook.go +++ b/internal/webhook/collector/webhook.go @@ -342,7 +342,7 @@ func checkAutoscalerSpec(autoscaler *v1alpha1.AutoscalerSpec) error { return nil } -func SetupCollectorValidatingWebhookWithManager(mgr ctrl.Manager, cfg config.Config) error { +func SetupWebhook(mgr ctrl.Manager, cfg config.Config) error { cvw := &Webhook{ logger: mgr.GetLogger().WithValues("handler", "CollectorWebhook"), scheme: mgr.GetScheme(), diff --git a/internal/webhook/instrumentation/webhook.go b/internal/webhook/instrumentation/webhook.go index 3caf50d109..d6d7054f11 100644 --- a/internal/webhook/instrumentation/webhook.go +++ b/internal/webhook/instrumentation/webhook.go @@ -56,7 +56,7 @@ var ( } ) -//+kubebuilder:webhook:path=/mutate-opentelemetry-io-v1alpha1-instrumentation,mutating=true,failurePolicy=fail,sideEffects=None,groups=opentelemetry.io,resources=instrumentations,verbs=create;update,versions=v1alpha1,name=minstrumentation.kb.io,admissionReviewVersions=v1 +// +kubebuilder:webhook:path=/mutate-opentelemetry-io-v1alpha1-instrumentation,mutating=true,failurePolicy=fail,sideEffects=None,groups=opentelemetry.io,resources=instrumentations,verbs=create;update,versions=v1alpha1,name=minstrumentation.kb.io,admissionReviewVersions=v1 // +kubebuilder:webhook:verbs=create;update,path=/validate-opentelemetry-io-v1alpha1-instrumentation,mutating=false,failurePolicy=fail,groups=opentelemetry.io,resources=instrumentations,versions=v1alpha1,name=vinstrumentationcreateupdate.kb.io,sideEffects=none,admissionReviewVersions=v1 // +kubebuilder:webhook:verbs=delete,path=/validate-opentelemetry-io-v1alpha1-instrumentation,mutating=false,failurePolicy=ignore,groups=opentelemetry.io,resources=instrumentations,versions=v1alpha1,name=vinstrumentationdelete.kb.io,sideEffects=none,admissionReviewVersions=v1 @@ -320,7 +320,7 @@ func NewInstrumentationWebhook(mgr ctrl.Manager, cfg config.Config) *Webhook { } } -func SetupInstrumentationValidatingWebhookWithManager(mgr ctrl.Manager, cfg config.Config) error { +func SetupWebhook(mgr ctrl.Manager, cfg config.Config) error { ivw := NewInstrumentationWebhook(mgr, cfg) return ctrl.NewWebhookManagedBy(mgr). For(&v1alpha1.Instrumentation{}). diff --git a/internal/webhook/sidecar/webhookhandler_suite_test.go b/internal/webhook/sidecar/webhookhandler_suite_test.go index 67c9c37010..19f620cf61 100644 --- a/internal/webhook/sidecar/webhookhandler_suite_test.go +++ b/internal/webhook/sidecar/webhookhandler_suite_test.go @@ -99,7 +99,7 @@ func TestMain(m *testing.M) { os.Exit(1) } - if err = collectorwebhook.SetupCollectorValidatingWebhookWithManager(mgr, config.New()); err != nil { + if err = collectorwebhook.SetupWebhook(mgr, config.New()); err != nil { fmt.Printf("failed to SetupWebhookWithManager: %v", err) os.Exit(1) } diff --git a/main.go b/main.go index 291d05e7fe..9c65e1474a 100644 --- a/main.go +++ b/main.go @@ -248,11 +248,11 @@ func main() { } if os.Getenv("ENABLE_WEBHOOKS") != "false" { - if err = collectorwebhook.SetupCollectorValidatingWebhookWithManager(mgr, cfg); err != nil { + if err = collectorwebhook.SetupWebhook(mgr, cfg); err != nil { setupLog.Error(err, "unable to create webhook", "webhook", "OpenTelemetryCollector") os.Exit(1) } - if err = instrumentationwebhook.SetupInstrumentationValidatingWebhookWithManager(mgr, cfg); err != nil { + if err = instrumentationwebhook.SetupWebhook(mgr, cfg); err != nil { setupLog.Error(err, "unable to create webhook", "webhook", "Instrumentation") os.Exit(1) } diff --git a/pkg/collector/reconcile/suite_test.go b/pkg/collector/reconcile/suite_test.go index a67d4d4335..315f434dd7 100644 --- a/pkg/collector/reconcile/suite_test.go +++ b/pkg/collector/reconcile/suite_test.go @@ -136,7 +136,7 @@ func TestMain(m *testing.M) { os.Exit(1) } - if err = collectorwebhook.SetupCollectorValidatingWebhookWithManager(mgr, config.New()); err != nil { + if err = collectorwebhook.SetupWebhook(mgr, config.New()); err != nil { fmt.Printf("failed to SetupWebhookWithManager: %v", err) os.Exit(1) } diff --git a/pkg/collector/upgrade/suite_test.go b/pkg/collector/upgrade/suite_test.go index b99e64d6de..dcafd906a9 100644 --- a/pkg/collector/upgrade/suite_test.go +++ b/pkg/collector/upgrade/suite_test.go @@ -101,7 +101,7 @@ func TestMain(m *testing.M) { os.Exit(1) } - if err = collectorwebhook.SetupCollectorValidatingWebhookWithManager(mgr, conf); err != nil { + if err = collectorwebhook.SetupWebhook(mgr, conf); err != nil { fmt.Printf("failed to SetupWebhookWithManager: %v", err) os.Exit(1) } From 191deeccc826d906bc14689acc666815a1290393 Mon Sep 17 00:00:00 2001 From: Jacob Aronoff Date: Wed, 11 Oct 2023 13:08:18 -0400 Subject: [PATCH 04/15] generate --- apis/v1alpha1/zz_generated.deepcopy.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apis/v1alpha1/zz_generated.deepcopy.go b/apis/v1alpha1/zz_generated.deepcopy.go index bd1c11e449..b99c43312f 100644 --- a/apis/v1alpha1/zz_generated.deepcopy.go +++ b/apis/v1alpha1/zz_generated.deepcopy.go @@ -24,7 +24,7 @@ import ( "k8s.io/api/core/v1" networkingv1 "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" + runtime "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/intstr" ) From af75d3e4f9314d0dd839453e36d5b2f8363477bf Mon Sep 17 00:00:00 2001 From: Jacob Aronoff Date: Wed, 11 Oct 2023 14:05:01 -0400 Subject: [PATCH 05/15] Add back annotations --- internal/config/main.go | 1 + internal/webhook/instrumentation/webhook.go | 35 +++++++++------ pkg/constants/env.go | 9 ++++ pkg/instrumentation/upgrade/upgrade.go | 50 +++++++++++---------- pkg/instrumentation/upgrade/upgrade_test.go | 19 ++++---- 5 files changed, 69 insertions(+), 45 deletions(-) diff --git a/internal/config/main.go b/internal/config/main.go index 951340136b..3c2c594143 100644 --- a/internal/config/main.go +++ b/internal/config/main.go @@ -85,6 +85,7 @@ func New(opts ...Option) Config { autoInstrumentationNodeJSImage: o.autoInstrumentationNodeJSImage, autoInstrumentationPythonImage: o.autoInstrumentationPythonImage, autoInstrumentationDotNetImage: o.autoInstrumentationDotNetImage, + autoInstrumentationGoImage: o.autoInstrumentationGoImage, autoInstrumentationApacheHttpdImage: o.autoInstrumentationApacheHttpdImage, autoInstrumentationNginxImage: o.autoInstrumentationNginxImage, labelsFilter: o.labelsFilter, diff --git a/internal/webhook/instrumentation/webhook.go b/internal/webhook/instrumentation/webhook.go index d6d7054f11..e7c3633d18 100644 --- a/internal/webhook/instrumentation/webhook.go +++ b/internal/webhook/instrumentation/webhook.go @@ -29,18 +29,12 @@ import ( "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" "github.com/open-telemetry/opentelemetry-operator/internal/config" + "github.com/open-telemetry/opentelemetry-operator/pkg/constants" ) const ( - AnnotationDefaultAutoInstrumentationJava = "instrumentation.opentelemetry.io/default-auto-instrumentation-java-image" - AnnotationDefaultAutoInstrumentationNodeJS = "instrumentation.opentelemetry.io/default-auto-instrumentation-nodejs-image" - AnnotationDefaultAutoInstrumentationPython = "instrumentation.opentelemetry.io/default-auto-instrumentation-python-image" - AnnotationDefaultAutoInstrumentationDotNet = "instrumentation.opentelemetry.io/default-auto-instrumentation-dotnet-image" - AnnotationDefaultAutoInstrumentationGo = "instrumentation.opentelemetry.io/default-auto-instrumentation-go-image" - AnnotationDefaultAutoInstrumentationApacheHttpd = "instrumentation.opentelemetry.io/default-auto-instrumentation-apache-httpd-image" - AnnotationDefaultAutoInstrumentationNginx = "instrumentation.opentelemetry.io/default-auto-instrumentation-nginx-image" - envPrefix = "OTEL_" - envSplunkPrefix = "SPLUNK_" + envPrefix = "OTEL_" + envSplunkPrefix = "SPLUNK_" ) var ( @@ -211,6 +205,17 @@ func (w Webhook) defaulter(r *v1alpha1.Instrumentation) error { if r.Spec.Nginx.ConfigFile == "" { r.Spec.Nginx.ConfigFile = "/etc/nginx/nginx.conf" } + // Set the defaulting annotations + if r.Annotations == nil { + r.Annotations = map[string]string{} + } + r.Annotations[constants.AnnotationDefaultAutoInstrumentationJava] = w.cfg.AutoInstrumentationJavaImage() + r.Annotations[constants.AnnotationDefaultAutoInstrumentationNodeJS] = w.cfg.AutoInstrumentationNodeJSImage() + r.Annotations[constants.AnnotationDefaultAutoInstrumentationPython] = w.cfg.AutoInstrumentationPythonImage() + r.Annotations[constants.AnnotationDefaultAutoInstrumentationDotNet] = w.cfg.AutoInstrumentationDotNetImage() + r.Annotations[constants.AnnotationDefaultAutoInstrumentationGo] = w.cfg.AutoInstrumentationGoImage() + r.Annotations[constants.AnnotationDefaultAutoInstrumentationApacheHttpd] = w.cfg.AutoInstrumentationApacheHttpdImage() + r.Annotations[constants.AnnotationDefaultAutoInstrumentationNginx] = w.cfg.AutoInstrumentationNginxImage() return nil } @@ -312,16 +317,20 @@ func validateJaegerRemoteSamplerArgument(argument string) error { return nil } -func NewInstrumentationWebhook(mgr ctrl.Manager, cfg config.Config) *Webhook { +func NewInstrumentationWebhook(logger logr.Logger, scheme *runtime.Scheme, cfg config.Config) *Webhook { return &Webhook{ - logger: mgr.GetLogger().WithValues("handler", "InstrumentationWebhook"), - scheme: mgr.GetScheme(), + logger: logger, + scheme: scheme, cfg: cfg, } } func SetupWebhook(mgr ctrl.Manager, cfg config.Config) error { - ivw := NewInstrumentationWebhook(mgr, cfg) + ivw := NewInstrumentationWebhook( + mgr.GetLogger().WithValues("handler", "InstrumentationWebhook"), + mgr.GetScheme(), + cfg, + ) return ctrl.NewWebhookManagedBy(mgr). For(&v1alpha1.Instrumentation{}). WithValidator(ivw). diff --git a/pkg/constants/env.go b/pkg/constants/env.go index 0c4070905c..93f0e98bf6 100644 --- a/pkg/constants/env.go +++ b/pkg/constants/env.go @@ -22,6 +22,15 @@ const ( EnvOTELTracesSampler = "OTEL_TRACES_SAMPLER" EnvOTELTracesSamplerArg = "OTEL_TRACES_SAMPLER_ARG" + InstrumentationPrefix = "instrumentation.opentelemetry.io/" + AnnotationDefaultAutoInstrumentationJava = InstrumentationPrefix + "default-auto-instrumentation-java-image" + AnnotationDefaultAutoInstrumentationNodeJS = InstrumentationPrefix + "default-auto-instrumentation-nodejs-image" + AnnotationDefaultAutoInstrumentationPython = InstrumentationPrefix + "default-auto-instrumentation-python-image" + AnnotationDefaultAutoInstrumentationDotNet = InstrumentationPrefix + "default-auto-instrumentation-dotnet-image" + AnnotationDefaultAutoInstrumentationGo = InstrumentationPrefix + "default-auto-instrumentation-go-image" + AnnotationDefaultAutoInstrumentationApacheHttpd = InstrumentationPrefix + "default-auto-instrumentation-apache-httpd-image" + AnnotationDefaultAutoInstrumentationNginx = InstrumentationPrefix + "default-auto-instrumentation-nginx-image" + EnvPodName = "OTEL_RESOURCE_ATTRIBUTES_POD_NAME" EnvPodUID = "OTEL_RESOURCE_ATTRIBUTES_POD_UID" EnvNodeName = "OTEL_RESOURCE_ATTRIBUTES_NODE_NAME" diff --git a/pkg/instrumentation/upgrade/upgrade.go b/pkg/instrumentation/upgrade/upgrade.go index 33fa2e32d6..5f955df5b4 100644 --- a/pkg/instrumentation/upgrade/upgrade.go +++ b/pkg/instrumentation/upgrade/upgrade.go @@ -24,6 +24,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" + "github.com/open-telemetry/opentelemetry-operator/pkg/constants" "github.com/open-telemetry/opentelemetry-operator/pkg/featuregate" ) @@ -61,7 +62,7 @@ func (u *InstrumentationUpgrade) ManagedInstances(ctx context.Context) error { upgraded := u.upgrade(ctx, toUpgrade) if !reflect.DeepEqual(upgraded, toUpgrade) { // use update instead of patch because the patch does not upgrade annotations - if err := u.Client.Update(ctx, &upgraded); err != nil { + if err := u.Client.Update(ctx, upgraded); err != nil { u.Logger.Error(err, "failed to apply changes to instance", "name", upgraded.Name, "namespace", upgraded.Namespace) continue } @@ -74,90 +75,91 @@ func (u *InstrumentationUpgrade) ManagedInstances(ctx context.Context) error { return nil } -func (u *InstrumentationUpgrade) upgrade(_ context.Context, inst v1alpha1.Instrumentation) v1alpha1.Instrumentation { - autoInstJava := u.DefaultAutoInstJava +func (u *InstrumentationUpgrade) upgrade(_ context.Context, inst v1alpha1.Instrumentation) *v1alpha1.Instrumentation { + upgraded := inst.DeepCopy() + autoInstJava := upgraded.Annotations[constants.AnnotationDefaultAutoInstrumentationJava] if autoInstJava != "" { if featuregate.EnableJavaAutoInstrumentationSupport.IsEnabled() { // upgrade the image only if the image matches the annotation if inst.Spec.Java.Image == autoInstJava { - inst.Spec.Java.Image = u.DefaultAutoInstJava + upgraded.Spec.Java.Image = u.DefaultAutoInstJava } } else { u.Logger.Error(nil, "support for Java auto instrumentation is not enabled") - u.Recorder.Event(inst.DeepCopy(), "Warning", "InstrumentationUpgradeRejected", "support for Java auto instrumentation is not enabled") + u.Recorder.Event(upgraded, "Warning", "InstrumentationUpgradeRejected", "support for Java auto instrumentation is not enabled") } } - autoInstNodeJS := u.DefaultAutoInstNodeJS + autoInstNodeJS := upgraded.Annotations[constants.AnnotationDefaultAutoInstrumentationNodeJS] if autoInstNodeJS != "" { if featuregate.EnableNodeJSAutoInstrumentationSupport.IsEnabled() { // upgrade the image only if the image matches the annotation if inst.Spec.NodeJS.Image == autoInstNodeJS { - inst.Spec.NodeJS.Image = u.DefaultAutoInstNodeJS + upgraded.Spec.NodeJS.Image = u.DefaultAutoInstNodeJS } } else { u.Logger.Error(nil, "support for NodeJS auto instrumentation is not enabled") - u.Recorder.Event(inst.DeepCopy(), "Warning", "InstrumentationUpgradeRejected", "support for NodeJS auto instrumentation is not enabled") + u.Recorder.Event(upgraded, "Warning", "InstrumentationUpgradeRejected", "support for NodeJS auto instrumentation is not enabled") } } - autoInstPython := u.DefaultAutoInstNodeJS + autoInstPython := upgraded.Annotations[constants.AnnotationDefaultAutoInstrumentationPython] if autoInstPython != "" { if featuregate.EnablePythonAutoInstrumentationSupport.IsEnabled() { // upgrade the image only if the image matches the annotation if inst.Spec.Python.Image == autoInstPython { - inst.Spec.Python.Image = u.DefaultAutoInstPython + upgraded.Spec.Python.Image = u.DefaultAutoInstPython } } else { u.Logger.Error(nil, "support for Python auto instrumentation is not enabled") - u.Recorder.Event(inst.DeepCopy(), "Warning", "InstrumentationUpgradeRejected", "support for Python auto instrumentation is not enabled") + u.Recorder.Event(upgraded, "Warning", "InstrumentationUpgradeRejected", "support for Python auto instrumentation is not enabled") } } - autoInstDotnet := u.DefaultAutoInstDotNet + autoInstDotnet := upgraded.Annotations[constants.AnnotationDefaultAutoInstrumentationDotNet] if autoInstDotnet != "" { if featuregate.EnableDotnetAutoInstrumentationSupport.IsEnabled() { // upgrade the image only if the image matches the annotation if inst.Spec.DotNet.Image == autoInstDotnet { - inst.Spec.DotNet.Image = u.DefaultAutoInstDotNet + upgraded.Spec.DotNet.Image = u.DefaultAutoInstDotNet } } else { u.Logger.Error(nil, "support for .NET auto instrumentation is not enabled") - u.Recorder.Event(inst.DeepCopy(), "Warning", "InstrumentationUpgradeRejected", "support for .NET auto instrumentation is not enabled") + u.Recorder.Event(upgraded, "Warning", "InstrumentationUpgradeRejected", "support for .NET auto instrumentation is not enabled") } } - autoInstGo := u.DefaultAutoInstGo + autoInstGo := upgraded.Annotations[constants.AnnotationDefaultAutoInstrumentationGo] if autoInstGo != "" { if featuregate.EnableGoAutoInstrumentationSupport.IsEnabled() { // upgrade the image only if the image matches the annotation if inst.Spec.Go.Image == autoInstGo { - inst.Spec.Go.Image = u.DefaultAutoInstGo + upgraded.Spec.Go.Image = u.DefaultAutoInstGo } } else { u.Logger.Error(nil, "support for Go auto instrumentation is not enabled") - u.Recorder.Event(inst.DeepCopy(), "Warning", "InstrumentationUpgradeRejected", "support for Go auto instrumentation is not enabled") + u.Recorder.Event(upgraded, "Warning", "InstrumentationUpgradeRejected", "support for Go auto instrumentation is not enabled") } } - autoInstApacheHttpd := u.DefaultAutoInstApacheHttpd + autoInstApacheHttpd := upgraded.Annotations[constants.AnnotationDefaultAutoInstrumentationApacheHttpd] if autoInstApacheHttpd != "" { if featuregate.EnableApacheHTTPAutoInstrumentationSupport.IsEnabled() { // upgrade the image only if the image matches the annotation if inst.Spec.ApacheHttpd.Image == autoInstApacheHttpd { - inst.Spec.ApacheHttpd.Image = u.DefaultAutoInstApacheHttpd + upgraded.Spec.ApacheHttpd.Image = u.DefaultAutoInstApacheHttpd } } else { u.Logger.Error(nil, "support for Apache HTTPD auto instrumentation is not enabled") - u.Recorder.Event(inst.DeepCopy(), "Warning", "InstrumentationUpgradeRejected", "support for Apache HTTPD auto instrumentation is not enabled") + u.Recorder.Event(upgraded, "Warning", "InstrumentationUpgradeRejected", "support for Apache HTTPD auto instrumentation is not enabled") } } - autoInstNginx := u.DefaultAutoInstNginx + autoInstNginx := upgraded.Annotations[constants.AnnotationDefaultAutoInstrumentationNginx] if autoInstNginx != "" { if featuregate.EnableNginxAutoInstrumentationSupport.IsEnabled() { // upgrade the image only if the image matches the annotation if inst.Spec.Nginx.Image == autoInstNginx { - inst.Spec.Nginx.Image = u.DefaultAutoInstNginx + upgraded.Spec.Nginx.Image = u.DefaultAutoInstNginx } } else { u.Logger.Error(nil, "support for Nginx auto instrumentation is not enabled") - u.Recorder.Event(inst.DeepCopy(), "Warning", "InstrumentationUpgradeRejected", "support for Nginx auto instrumentation is not enabled") + u.Recorder.Event(upgraded, "Warning", "InstrumentationUpgradeRejected", "support for Nginx auto instrumentation is not enabled") } } - return inst + return upgraded } diff --git a/pkg/instrumentation/upgrade/upgrade_test.go b/pkg/instrumentation/upgrade/upgrade_test.go index 4a36478a0c..2677682f36 100644 --- a/pkg/instrumentation/upgrade/upgrade_test.go +++ b/pkg/instrumentation/upgrade/upgrade_test.go @@ -71,17 +71,20 @@ func TestUpgrade(t *testing.T) { }, }, } - err = instrumentationwebhook.NewInstrumentationWebhook(nil, + err = instrumentationwebhook.NewInstrumentationWebhook( + logr.Discard(), + testScheme, config.New( - config.WithAutoInstrumentationJavaImage("java-img:1"), - config.WithAutoInstrumentationNodeJSImage("nodejs-img:1"), - config.WithAutoInstrumentationPythonImage("python-img:1"), - config.WithAutoInstrumentationDotNetImage("dotnet-img:1"), - config.WithAutoInstrumentationApacheHttpdImage("apache-httpd-img:1"), - config.WithAutoInstrumentationNginxImage("nginx-img:1"), + config.WithAutoInstrumentationJavaImage("java:1"), + config.WithAutoInstrumentationNodeJSImage("nodejs:1"), + config.WithAutoInstrumentationPythonImage("python:1"), + config.WithAutoInstrumentationDotNetImage("dotnet:1"), + config.WithAutoInstrumentationGoImage("go:1"), + config.WithAutoInstrumentationApacheHttpdImage("apache-httpd:1"), + config.WithAutoInstrumentationNginxImage("nginx:1"), ), ).Default(context.Background(), inst) - assert.NotNil(t, err) + assert.Nil(t, err) assert.Equal(t, "java:1", inst.Spec.Java.Image) assert.Equal(t, "nodejs:1", inst.Spec.NodeJS.Image) assert.Equal(t, "python:1", inst.Spec.Python.Image) From 38fc1f35cc5fbe3811234992e8cd5607c0758758 Mon Sep 17 00:00:00 2001 From: Jacob Aronoff Date: Wed, 11 Oct 2023 15:22:58 -0400 Subject: [PATCH 06/15] Fix tests, simplify code --- .../sidecar/webhookhandler_suite_test.go | 4 +- pkg/instrumentation/upgrade/upgrade.go | 138 ++++++++---------- pkg/instrumentation/upgrade/upgrade_test.go | 8 + 3 files changed, 67 insertions(+), 83 deletions(-) diff --git a/internal/webhook/sidecar/webhookhandler_suite_test.go b/internal/webhook/sidecar/webhookhandler_suite_test.go index 19f620cf61..827dfc5bd6 100644 --- a/internal/webhook/sidecar/webhookhandler_suite_test.go +++ b/internal/webhook/sidecar/webhookhandler_suite_test.go @@ -57,9 +57,9 @@ func TestMain(m *testing.M) { defer cancel() testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, + CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")}, WebhookInstallOptions: envtest.WebhookInstallOptions{ - Paths: []string{filepath.Join("..", "..", "config", "webhook")}, + Paths: []string{filepath.Join("..", "..", "..", "config", "webhook")}, }, } cfg, err = testEnv.Start() diff --git a/pkg/instrumentation/upgrade/upgrade.go b/pkg/instrumentation/upgrade/upgrade.go index 5f955df5b4..7a95204037 100644 --- a/pkg/instrumentation/upgrade/upgrade.go +++ b/pkg/instrumentation/upgrade/upgrade.go @@ -20,6 +20,7 @@ import ( "reflect" "github.com/go-logr/logr" + featuregate2 "go.opentelemetry.io/collector/featuregate" "k8s.io/client-go/tools/record" "sigs.k8s.io/controller-runtime/pkg/client" @@ -28,6 +29,18 @@ import ( "github.com/open-telemetry/opentelemetry-operator/pkg/featuregate" ) +var ( + annotationToGate = map[string]*featuregate2.Gate{ + constants.AnnotationDefaultAutoInstrumentationJava: featuregate.EnableJavaAutoInstrumentationSupport, + constants.AnnotationDefaultAutoInstrumentationNodeJS: featuregate.EnableNodeJSAutoInstrumentationSupport, + constants.AnnotationDefaultAutoInstrumentationPython: featuregate.EnablePythonAutoInstrumentationSupport, + constants.AnnotationDefaultAutoInstrumentationDotNet: featuregate.EnableDotnetAutoInstrumentationSupport, + constants.AnnotationDefaultAutoInstrumentationGo: featuregate.EnableGoAutoInstrumentationSupport, + constants.AnnotationDefaultAutoInstrumentationApacheHttpd: featuregate.EnableApacheHTTPAutoInstrumentationSupport, + constants.AnnotationDefaultAutoInstrumentationNginx: featuregate.EnableNginxAutoInstrumentationSupport, + } +) + type InstrumentationUpgrade struct { Client client.Client Logger logr.Logger @@ -77,88 +90,51 @@ func (u *InstrumentationUpgrade) ManagedInstances(ctx context.Context) error { func (u *InstrumentationUpgrade) upgrade(_ context.Context, inst v1alpha1.Instrumentation) *v1alpha1.Instrumentation { upgraded := inst.DeepCopy() - autoInstJava := upgraded.Annotations[constants.AnnotationDefaultAutoInstrumentationJava] - if autoInstJava != "" { - if featuregate.EnableJavaAutoInstrumentationSupport.IsEnabled() { - // upgrade the image only if the image matches the annotation - if inst.Spec.Java.Image == autoInstJava { - upgraded.Spec.Java.Image = u.DefaultAutoInstJava - } - } else { - u.Logger.Error(nil, "support for Java auto instrumentation is not enabled") - u.Recorder.Event(upgraded, "Warning", "InstrumentationUpgradeRejected", "support for Java auto instrumentation is not enabled") - } - } - autoInstNodeJS := upgraded.Annotations[constants.AnnotationDefaultAutoInstrumentationNodeJS] - if autoInstNodeJS != "" { - if featuregate.EnableNodeJSAutoInstrumentationSupport.IsEnabled() { - // upgrade the image only if the image matches the annotation - if inst.Spec.NodeJS.Image == autoInstNodeJS { - upgraded.Spec.NodeJS.Image = u.DefaultAutoInstNodeJS - } - } else { - u.Logger.Error(nil, "support for NodeJS auto instrumentation is not enabled") - u.Recorder.Event(upgraded, "Warning", "InstrumentationUpgradeRejected", "support for NodeJS auto instrumentation is not enabled") - } - } - autoInstPython := upgraded.Annotations[constants.AnnotationDefaultAutoInstrumentationPython] - if autoInstPython != "" { - if featuregate.EnablePythonAutoInstrumentationSupport.IsEnabled() { - // upgrade the image only if the image matches the annotation - if inst.Spec.Python.Image == autoInstPython { - upgraded.Spec.Python.Image = u.DefaultAutoInstPython - } - } else { - u.Logger.Error(nil, "support for Python auto instrumentation is not enabled") - u.Recorder.Event(upgraded, "Warning", "InstrumentationUpgradeRejected", "support for Python auto instrumentation is not enabled") - } - } - autoInstDotnet := upgraded.Annotations[constants.AnnotationDefaultAutoInstrumentationDotNet] - if autoInstDotnet != "" { - if featuregate.EnableDotnetAutoInstrumentationSupport.IsEnabled() { - // upgrade the image only if the image matches the annotation - if inst.Spec.DotNet.Image == autoInstDotnet { - upgraded.Spec.DotNet.Image = u.DefaultAutoInstDotNet - } - } else { - u.Logger.Error(nil, "support for .NET auto instrumentation is not enabled") - u.Recorder.Event(upgraded, "Warning", "InstrumentationUpgradeRejected", "support for .NET auto instrumentation is not enabled") - } - } - autoInstGo := upgraded.Annotations[constants.AnnotationDefaultAutoInstrumentationGo] - if autoInstGo != "" { - if featuregate.EnableGoAutoInstrumentationSupport.IsEnabled() { - // upgrade the image only if the image matches the annotation - if inst.Spec.Go.Image == autoInstGo { - upgraded.Spec.Go.Image = u.DefaultAutoInstGo - } - } else { - u.Logger.Error(nil, "support for Go auto instrumentation is not enabled") - u.Recorder.Event(upgraded, "Warning", "InstrumentationUpgradeRejected", "support for Go auto instrumentation is not enabled") - } - } - autoInstApacheHttpd := upgraded.Annotations[constants.AnnotationDefaultAutoInstrumentationApacheHttpd] - if autoInstApacheHttpd != "" { - if featuregate.EnableApacheHTTPAutoInstrumentationSupport.IsEnabled() { - // upgrade the image only if the image matches the annotation - if inst.Spec.ApacheHttpd.Image == autoInstApacheHttpd { - upgraded.Spec.ApacheHttpd.Image = u.DefaultAutoInstApacheHttpd - } - } else { - u.Logger.Error(nil, "support for Apache HTTPD auto instrumentation is not enabled") - u.Recorder.Event(upgraded, "Warning", "InstrumentationUpgradeRejected", "support for Apache HTTPD auto instrumentation is not enabled") - } - } - autoInstNginx := upgraded.Annotations[constants.AnnotationDefaultAutoInstrumentationNginx] - if autoInstNginx != "" { - if featuregate.EnableNginxAutoInstrumentationSupport.IsEnabled() { - // upgrade the image only if the image matches the annotation - if inst.Spec.Nginx.Image == autoInstNginx { - upgraded.Spec.Nginx.Image = u.DefaultAutoInstNginx + for annotation, gate := range annotationToGate { + autoInst := upgraded.Annotations[annotation] + if autoInst != "" { + if gate.IsEnabled() { + switch annotation { + case constants.AnnotationDefaultAutoInstrumentationJava: + if inst.Spec.Java.Image == autoInst { + upgraded.Spec.Java.Image = u.DefaultAutoInstJava + upgraded.Annotations[constants.AnnotationDefaultAutoInstrumentationJava] = u.DefaultAutoInstJava + } + case constants.AnnotationDefaultAutoInstrumentationNodeJS: + if inst.Spec.NodeJS.Image == autoInst { + upgraded.Spec.NodeJS.Image = u.DefaultAutoInstNodeJS + upgraded.Annotations[constants.AnnotationDefaultAutoInstrumentationNodeJS] = u.DefaultAutoInstNodeJS + } + case constants.AnnotationDefaultAutoInstrumentationPython: + if inst.Spec.Python.Image == autoInst { + upgraded.Spec.Python.Image = u.DefaultAutoInstPython + upgraded.Annotations[constants.AnnotationDefaultAutoInstrumentationPython] = u.DefaultAutoInstPython + } + case constants.AnnotationDefaultAutoInstrumentationDotNet: + if inst.Spec.DotNet.Image == autoInst { + upgraded.Spec.DotNet.Image = u.DefaultAutoInstDotNet + upgraded.Annotations[constants.AnnotationDefaultAutoInstrumentationDotNet] = u.DefaultAutoInstDotNet + } + case constants.AnnotationDefaultAutoInstrumentationGo: + if inst.Spec.Go.Image == autoInst { + upgraded.Spec.Go.Image = u.DefaultAutoInstGo + upgraded.Annotations[constants.AnnotationDefaultAutoInstrumentationGo] = u.DefaultAutoInstGo + } + case constants.AnnotationDefaultAutoInstrumentationApacheHttpd: + if inst.Spec.ApacheHttpd.Image == autoInst { + upgraded.Spec.ApacheHttpd.Image = u.DefaultAutoInstApacheHttpd + upgraded.Annotations[constants.AnnotationDefaultAutoInstrumentationApacheHttpd] = u.DefaultAutoInstApacheHttpd + } + case constants.AnnotationDefaultAutoInstrumentationNginx: + if inst.Spec.Nginx.Image == autoInst { + upgraded.Spec.Nginx.Image = u.DefaultAutoInstNginx + upgraded.Annotations[constants.AnnotationDefaultAutoInstrumentationNginx] = u.DefaultAutoInstNginx + } + } + } else { + u.Logger.Error(nil, "autoinstrumentation not enabled for this language", "flag", gate.ID()) + u.Recorder.Event(upgraded, "Warning", "InstrumentationUpgradeRejected", fmt.Sprintf("support for is not enabled for %s", gate.ID())) } - } else { - u.Logger.Error(nil, "support for Nginx auto instrumentation is not enabled") - u.Recorder.Event(upgraded, "Warning", "InstrumentationUpgradeRejected", "support for Nginx auto instrumentation is not enabled") } } return upgraded diff --git a/pkg/instrumentation/upgrade/upgrade_test.go b/pkg/instrumentation/upgrade/upgrade_test.go index 2677682f36..49562463a4 100644 --- a/pkg/instrumentation/upgrade/upgrade_test.go +++ b/pkg/instrumentation/upgrade/upgrade_test.go @@ -30,6 +30,7 @@ import ( "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" "github.com/open-telemetry/opentelemetry-operator/internal/config" instrumentationwebhook "github.com/open-telemetry/opentelemetry-operator/internal/webhook/instrumentation" + "github.com/open-telemetry/opentelemetry-operator/pkg/constants" "github.com/open-telemetry/opentelemetry-operator/pkg/featuregate" ) @@ -115,11 +116,18 @@ func TestUpgrade(t *testing.T) { Name: "my-inst", }, &updated) require.NoError(t, err) + assert.Equal(t, "java:2", updated.Annotations[constants.AnnotationDefaultAutoInstrumentationJava]) assert.Equal(t, "java:2", updated.Spec.Java.Image) + assert.Equal(t, "nodejs:2", updated.Annotations[constants.AnnotationDefaultAutoInstrumentationNodeJS]) assert.Equal(t, "nodejs:2", updated.Spec.NodeJS.Image) + assert.Equal(t, "python:2", updated.Annotations[constants.AnnotationDefaultAutoInstrumentationPython]) assert.Equal(t, "python:2", updated.Spec.Python.Image) + assert.Equal(t, "dotnet:2", updated.Annotations[constants.AnnotationDefaultAutoInstrumentationDotNet]) assert.Equal(t, "dotnet:2", updated.Spec.DotNet.Image) + assert.Equal(t, "go:2", updated.Annotations[constants.AnnotationDefaultAutoInstrumentationGo]) assert.Equal(t, "go:2", updated.Spec.Go.Image) + assert.Equal(t, "apache-httpd:2", updated.Annotations[constants.AnnotationDefaultAutoInstrumentationApacheHttpd]) assert.Equal(t, "apache-httpd:2", updated.Spec.ApacheHttpd.Image) + assert.Equal(t, "nginx:2", updated.Annotations[constants.AnnotationDefaultAutoInstrumentationNginx]) assert.Equal(t, "nginx:2", updated.Spec.Nginx.Image) } From 567045069919f4a4874444688c9bf6488ead6016 Mon Sep 17 00:00:00 2001 From: Jacob Aronoff Date: Wed, 11 Oct 2023 15:35:28 -0400 Subject: [PATCH 07/15] naming --- pkg/instrumentation/upgrade/upgrade.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/instrumentation/upgrade/upgrade.go b/pkg/instrumentation/upgrade/upgrade.go index 7a95204037..d9dbec6c6f 100644 --- a/pkg/instrumentation/upgrade/upgrade.go +++ b/pkg/instrumentation/upgrade/upgrade.go @@ -30,7 +30,7 @@ import ( ) var ( - annotationToGate = map[string]*featuregate2.Gate{ + defaultAnnotationToGate = map[string]*featuregate2.Gate{ constants.AnnotationDefaultAutoInstrumentationJava: featuregate.EnableJavaAutoInstrumentationSupport, constants.AnnotationDefaultAutoInstrumentationNodeJS: featuregate.EnableNodeJSAutoInstrumentationSupport, constants.AnnotationDefaultAutoInstrumentationPython: featuregate.EnablePythonAutoInstrumentationSupport, @@ -90,7 +90,7 @@ func (u *InstrumentationUpgrade) ManagedInstances(ctx context.Context) error { func (u *InstrumentationUpgrade) upgrade(_ context.Context, inst v1alpha1.Instrumentation) *v1alpha1.Instrumentation { upgraded := inst.DeepCopy() - for annotation, gate := range annotationToGate { + for annotation, gate := range defaultAnnotationToGate { autoInst := upgraded.Annotations[annotation] if autoInst != "" { if gate.IsEnabled() { @@ -98,37 +98,37 @@ func (u *InstrumentationUpgrade) upgrade(_ context.Context, inst v1alpha1.Instru case constants.AnnotationDefaultAutoInstrumentationJava: if inst.Spec.Java.Image == autoInst { upgraded.Spec.Java.Image = u.DefaultAutoInstJava - upgraded.Annotations[constants.AnnotationDefaultAutoInstrumentationJava] = u.DefaultAutoInstJava + upgraded.Annotations[annotation] = u.DefaultAutoInstJava } case constants.AnnotationDefaultAutoInstrumentationNodeJS: if inst.Spec.NodeJS.Image == autoInst { upgraded.Spec.NodeJS.Image = u.DefaultAutoInstNodeJS - upgraded.Annotations[constants.AnnotationDefaultAutoInstrumentationNodeJS] = u.DefaultAutoInstNodeJS + upgraded.Annotations[annotation] = u.DefaultAutoInstNodeJS } case constants.AnnotationDefaultAutoInstrumentationPython: if inst.Spec.Python.Image == autoInst { upgraded.Spec.Python.Image = u.DefaultAutoInstPython - upgraded.Annotations[constants.AnnotationDefaultAutoInstrumentationPython] = u.DefaultAutoInstPython + upgraded.Annotations[annotation] = u.DefaultAutoInstPython } case constants.AnnotationDefaultAutoInstrumentationDotNet: if inst.Spec.DotNet.Image == autoInst { upgraded.Spec.DotNet.Image = u.DefaultAutoInstDotNet - upgraded.Annotations[constants.AnnotationDefaultAutoInstrumentationDotNet] = u.DefaultAutoInstDotNet + upgraded.Annotations[annotation] = u.DefaultAutoInstDotNet } case constants.AnnotationDefaultAutoInstrumentationGo: if inst.Spec.Go.Image == autoInst { upgraded.Spec.Go.Image = u.DefaultAutoInstGo - upgraded.Annotations[constants.AnnotationDefaultAutoInstrumentationGo] = u.DefaultAutoInstGo + upgraded.Annotations[annotation] = u.DefaultAutoInstGo } case constants.AnnotationDefaultAutoInstrumentationApacheHttpd: if inst.Spec.ApacheHttpd.Image == autoInst { upgraded.Spec.ApacheHttpd.Image = u.DefaultAutoInstApacheHttpd - upgraded.Annotations[constants.AnnotationDefaultAutoInstrumentationApacheHttpd] = u.DefaultAutoInstApacheHttpd + upgraded.Annotations[annotation] = u.DefaultAutoInstApacheHttpd } case constants.AnnotationDefaultAutoInstrumentationNginx: if inst.Spec.Nginx.Image == autoInst { upgraded.Spec.Nginx.Image = u.DefaultAutoInstNginx - upgraded.Annotations[constants.AnnotationDefaultAutoInstrumentationNginx] = u.DefaultAutoInstNginx + upgraded.Annotations[annotation] = u.DefaultAutoInstNginx } } } else { From 5206f9690bf5efd9717bd20a3931520efb86dea9 Mon Sep 17 00:00:00 2001 From: Jacob Aronoff Date: Wed, 11 Oct 2023 15:51:30 -0400 Subject: [PATCH 08/15] fix borked test --- cmd/operator-opamp-bridge/agent/agent_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/operator-opamp-bridge/agent/agent_test.go b/cmd/operator-opamp-bridge/agent/agent_test.go index 6c561f3bd5..9c8ca4a702 100644 --- a/cmd/operator-opamp-bridge/agent/agent_test.go +++ b/cmd/operator-opamp-bridge/agent/agent_test.go @@ -195,7 +195,7 @@ func TestAgent_onMessage(t *testing.T) { }, }, status: &protobufs.RemoteConfigStatus{ - LastRemoteConfigHash: []byte("good/testnamespace405"), + LastRemoteConfigHash: []byte("good/testnamespace401"), Status: protobufs.RemoteConfigStatuses_RemoteConfigStatuses_APPLIED, }, }, From 3078a2e56b004bc25a39f7d1c103c9740a6584c9 Mon Sep 17 00:00:00 2001 From: Jacob Aronoff Date: Thu, 12 Oct 2023 11:20:43 -0400 Subject: [PATCH 09/15] FIX TESTS --- config/manager/kustomization.yaml | 6 + kuttl-test-upgrade.yaml | 2 +- tests/e2e-upgrade/upgrade-test/00-assert.yaml | 9 +- .../e2e-upgrade/upgrade-test/00-install.yaml | 2 +- .../opentelemetry-operator-v0.49.0.yaml | 2732 ------ .../opentelemetry-operator-v0.86.0.yaml | 8558 +++++++++++++++++ 6 files changed, 8571 insertions(+), 2738 deletions(-) delete mode 100644 tests/e2e-upgrade/upgrade-test/opentelemetry-operator-v0.49.0.yaml create mode 100644 tests/e2e-upgrade/upgrade-test/opentelemetry-operator-v0.86.0.yaml diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index 5c5f0b84cb..dc4d5229f4 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -1,2 +1,8 @@ resources: - manager.yaml +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +images: +- name: controller + newName: ghcr.io/jacob.aronoff/opentelemetry-operator/opentelemetry-operator + newTag: e2e diff --git a/kuttl-test-upgrade.yaml b/kuttl-test-upgrade.yaml index 8066df5164..0c4f7e7d8b 100644 --- a/kuttl-test-upgrade.yaml +++ b/kuttl-test-upgrade.yaml @@ -12,7 +12,7 @@ apiVersion: kuttl.dev/v1beta1 kind: TestSuite commands: - - command: kubectl apply -f ./tests/e2e-upgrade/upgrade-test/opentelemetry-operator-v0.49.0.yaml + - command: kubectl apply -f ./tests/e2e-upgrade/upgrade-test/opentelemetry-operator-v0.86.0.yaml - command: go run hack/check-operator-ready.go testDirs: - ./tests/e2e-upgrade/ diff --git a/tests/e2e-upgrade/upgrade-test/00-assert.yaml b/tests/e2e-upgrade/upgrade-test/00-assert.yaml index 50736de4aa..d5c2c3825e 100644 --- a/tests/e2e-upgrade/upgrade-test/00-assert.yaml +++ b/tests/e2e-upgrade/upgrade-test/00-assert.yaml @@ -3,10 +3,11 @@ kind: Deployment metadata: name: simplest-collector annotations: - operatorVersion: "v0.49.0" + operatorVersion: "v0.86.0" spec: - selector: - matchLabels: - app.kubernetes.io/version: latest + template: + metadata: + labels: + app.kubernetes.io/version: latest status: readyReplicas: 1 diff --git a/tests/e2e-upgrade/upgrade-test/00-install.yaml b/tests/e2e-upgrade/upgrade-test/00-install.yaml index 4dab8bdc69..9ae9054a40 100644 --- a/tests/e2e-upgrade/upgrade-test/00-install.yaml +++ b/tests/e2e-upgrade/upgrade-test/00-install.yaml @@ -3,7 +3,7 @@ kind: OpenTelemetryCollector metadata: name: simplest annotations: - operatorVersion: "v0.49.0" + operatorVersion: "v0.86.0" spec: replicas: 1 config: | diff --git a/tests/e2e-upgrade/upgrade-test/opentelemetry-operator-v0.49.0.yaml b/tests/e2e-upgrade/upgrade-test/opentelemetry-operator-v0.49.0.yaml deleted file mode 100644 index 750fe9ca5e..0000000000 --- a/tests/e2e-upgrade/upgrade-test/opentelemetry-operator-v0.49.0.yaml +++ /dev/null @@ -1,2732 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - labels: - app.kubernetes.io/name: opentelemetry-operator - control-plane: controller-manager - name: opentelemetry-operator-system ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.8.0 - creationTimestamp: null - labels: - app.kubernetes.io/name: opentelemetry-operator - name: instrumentations.opentelemetry.io -spec: - group: opentelemetry.io - names: - kind: Instrumentation - listKind: InstrumentationList - plural: instrumentations - shortNames: - - otelinst - - otelinsts - singular: instrumentation - scope: Namespaced - versions: - - additionalPrinterColumns: - - jsonPath: .metadata.creationTimestamp - name: Age - type: date - - jsonPath: .spec.exporter.endpoint - name: Endpoint - type: string - - jsonPath: .spec.sampler.type - name: Sampler - type: string - - jsonPath: .spec.sampler.argument - name: Sampler Arg - type: string - name: v1alpha1 - schema: - openAPIV3Schema: - description: Instrumentation is the spec for OpenTelemetry instrumentation. - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - description: InstrumentationSpec defines the desired state of OpenTelemetry SDK and instrumentation. - properties: - env: - description: 'Env defines common env vars. There are four layers for env vars'' definitions and the precedence order is: `original container env vars` > `language specific env vars` > `common env vars` > `instrument spec configs'' vars`. If the former var had been defined, then the other vars would be ignored.' - items: - description: EnvVar represents an environment variable present in a Container. - properties: - name: - description: Name of the environment variable. Must be a C_IDENTIFIER. - type: string - value: - description: 'Variable references $(VAR_NAME) are expanded using the previously defined environment variables in the container and any service environment variables. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "".' - type: string - valueFrom: - description: Source for the environment variable's value. Cannot be used if value is not empty. - properties: - configMapKeyRef: - description: Selects a key of a ConfigMap. - properties: - key: - description: The key to select. - type: string - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - optional: - description: Specify whether the ConfigMap or its key must be defined - type: boolean - required: - - key - type: object - fieldRef: - description: 'Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['''']`, `metadata.annotations['''']`, spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs.' - properties: - apiVersion: - description: Version of the schema the FieldPath is written in terms of, defaults to "v1". - type: string - fieldPath: - description: Path of the field to select in the specified API version. - type: string - required: - - fieldPath - type: object - resourceFieldRef: - description: 'Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported.' - properties: - containerName: - description: 'Container name: required for volumes, optional for env vars' - type: string - divisor: - anyOf: - - type: integer - - type: string - description: Specifies the output format of the exposed resources, defaults to "1" - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - resource: - description: 'Required: resource to select' - type: string - required: - - resource - type: object - secretKeyRef: - description: Selects a key of a secret in the pod's namespace - properties: - key: - description: The key of the secret to select from. Must be a valid secret key. - type: string - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - optional: - description: Specify whether the Secret or its key must be defined - type: boolean - required: - - key - type: object - type: object - required: - - name - type: object - type: array - exporter: - description: Exporter defines exporter configuration. - properties: - endpoint: - description: Endpoint is address of the collector with OTLP endpoint. - type: string - type: object - java: - description: Java defines configuration for java auto-instrumentation. - properties: - env: - description: 'Env defines java specific env vars. There are four layers for env vars'' definitions and the precedence order is: `original container env vars` > `language specific env vars` > `common env vars` > `instrument spec configs'' vars`. If the former var had been defined, then the other vars would be ignored.' - items: - description: EnvVar represents an environment variable present in a Container. - properties: - name: - description: Name of the environment variable. Must be a C_IDENTIFIER. - type: string - value: - description: 'Variable references $(VAR_NAME) are expanded using the previously defined environment variables in the container and any service environment variables. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "".' - type: string - valueFrom: - description: Source for the environment variable's value. Cannot be used if value is not empty. - properties: - configMapKeyRef: - description: Selects a key of a ConfigMap. - properties: - key: - description: The key to select. - type: string - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - optional: - description: Specify whether the ConfigMap or its key must be defined - type: boolean - required: - - key - type: object - fieldRef: - description: 'Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['''']`, `metadata.annotations['''']`, spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs.' - properties: - apiVersion: - description: Version of the schema the FieldPath is written in terms of, defaults to "v1". - type: string - fieldPath: - description: Path of the field to select in the specified API version. - type: string - required: - - fieldPath - type: object - resourceFieldRef: - description: 'Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported.' - properties: - containerName: - description: 'Container name: required for volumes, optional for env vars' - type: string - divisor: - anyOf: - - type: integer - - type: string - description: Specifies the output format of the exposed resources, defaults to "1" - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - resource: - description: 'Required: resource to select' - type: string - required: - - resource - type: object - secretKeyRef: - description: Selects a key of a secret in the pod's namespace - properties: - key: - description: The key of the secret to select from. Must be a valid secret key. - type: string - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - optional: - description: Specify whether the Secret or its key must be defined - type: boolean - required: - - key - type: object - type: object - required: - - name - type: object - type: array - image: - description: Image is a container image with javaagent auto-instrumentation JAR. - type: string - type: object - nodejs: - description: NodeJS defines configuration for nodejs auto-instrumentation. - properties: - env: - description: 'Env defines nodejs specific env vars. There are four layers for env vars'' definitions and the precedence order is: `original container env vars` > `language specific env vars` > `common env vars` > `instrument spec configs'' vars`. If the former var had been defined, then the other vars would be ignored.' - items: - description: EnvVar represents an environment variable present in a Container. - properties: - name: - description: Name of the environment variable. Must be a C_IDENTIFIER. - type: string - value: - description: 'Variable references $(VAR_NAME) are expanded using the previously defined environment variables in the container and any service environment variables. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "".' - type: string - valueFrom: - description: Source for the environment variable's value. Cannot be used if value is not empty. - properties: - configMapKeyRef: - description: Selects a key of a ConfigMap. - properties: - key: - description: The key to select. - type: string - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - optional: - description: Specify whether the ConfigMap or its key must be defined - type: boolean - required: - - key - type: object - fieldRef: - description: 'Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['''']`, `metadata.annotations['''']`, spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs.' - properties: - apiVersion: - description: Version of the schema the FieldPath is written in terms of, defaults to "v1". - type: string - fieldPath: - description: Path of the field to select in the specified API version. - type: string - required: - - fieldPath - type: object - resourceFieldRef: - description: 'Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported.' - properties: - containerName: - description: 'Container name: required for volumes, optional for env vars' - type: string - divisor: - anyOf: - - type: integer - - type: string - description: Specifies the output format of the exposed resources, defaults to "1" - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - resource: - description: 'Required: resource to select' - type: string - required: - - resource - type: object - secretKeyRef: - description: Selects a key of a secret in the pod's namespace - properties: - key: - description: The key of the secret to select from. Must be a valid secret key. - type: string - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - optional: - description: Specify whether the Secret or its key must be defined - type: boolean - required: - - key - type: object - type: object - required: - - name - type: object - type: array - image: - description: Image is a container image with NodeJS SDK and auto-instrumentation. - type: string - type: object - propagators: - description: Propagators defines inter-process context propagation configuration. - items: - description: Propagator represents the propagation type. - enum: - - tracecontext - - baggage - - b3 - - b3multi - - jaeger - - xray - - ottrace - - none - type: string - type: array - python: - description: Python defines configuration for python auto-instrumentation. - properties: - env: - description: 'Env defines python specific env vars. There are four layers for env vars'' definitions and the precedence order is: `original container env vars` > `language specific env vars` > `common env vars` > `instrument spec configs'' vars`. If the former var had been defined, then the other vars would be ignored.' - items: - description: EnvVar represents an environment variable present in a Container. - properties: - name: - description: Name of the environment variable. Must be a C_IDENTIFIER. - type: string - value: - description: 'Variable references $(VAR_NAME) are expanded using the previously defined environment variables in the container and any service environment variables. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "".' - type: string - valueFrom: - description: Source for the environment variable's value. Cannot be used if value is not empty. - properties: - configMapKeyRef: - description: Selects a key of a ConfigMap. - properties: - key: - description: The key to select. - type: string - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - optional: - description: Specify whether the ConfigMap or its key must be defined - type: boolean - required: - - key - type: object - fieldRef: - description: 'Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['''']`, `metadata.annotations['''']`, spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs.' - properties: - apiVersion: - description: Version of the schema the FieldPath is written in terms of, defaults to "v1". - type: string - fieldPath: - description: Path of the field to select in the specified API version. - type: string - required: - - fieldPath - type: object - resourceFieldRef: - description: 'Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported.' - properties: - containerName: - description: 'Container name: required for volumes, optional for env vars' - type: string - divisor: - anyOf: - - type: integer - - type: string - description: Specifies the output format of the exposed resources, defaults to "1" - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - resource: - description: 'Required: resource to select' - type: string - required: - - resource - type: object - secretKeyRef: - description: Selects a key of a secret in the pod's namespace - properties: - key: - description: The key of the secret to select from. Must be a valid secret key. - type: string - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - optional: - description: Specify whether the Secret or its key must be defined - type: boolean - required: - - key - type: object - type: object - required: - - name - type: object - type: array - image: - description: Image is a container image with Python SDK and auto-instrumentation. - type: string - type: object - resource: - description: Resource defines the configuration for the resource attributes, as defined by the OpenTelemetry specification. - properties: - addK8sUIDAttributes: - description: AddK8sUIDAttributes defines whether K8s UID attributes should be collected (e.g. k8s.deployment.uid). - type: boolean - resourceAttributes: - additionalProperties: - type: string - description: 'Attributes defines attributes that are added to the resource. For example environment: dev' - type: object - type: object - sampler: - description: Sampler defines sampling configuration. - properties: - argument: - description: Argument defines sampler argument. The value depends on the sampler type. For instance for parentbased_traceidratio sampler type it is a number in range [0..1] e.g. 0.25. - type: string - type: - description: Type defines sampler type. The value can be for instance parentbased_always_on, parentbased_always_off, parentbased_traceidratio... - enum: - - always_on - - always_off - - traceidratio - - parentbased_always_on - - parentbased_always_off - - parentbased_traceidratio - - jaeger_remote - - xray - type: string - type: object - type: object - status: - description: InstrumentationStatus defines status of the instrumentation. - type: object - type: object - served: true - storage: true - subresources: - status: {} -status: - acceptedNames: - kind: "" - plural: "" - conditions: [] - storedVersions: [] ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - cert-manager.io/inject-ca-from: opentelemetry-operator-system/opentelemetry-operator-serving-cert - controller-gen.kubebuilder.io/version: v0.8.0 - labels: - app.kubernetes.io/name: opentelemetry-operator - name: opentelemetrycollectors.opentelemetry.io -spec: - group: opentelemetry.io - names: - kind: OpenTelemetryCollector - listKind: OpenTelemetryCollectorList - plural: opentelemetrycollectors - shortNames: - - otelcol - - otelcols - singular: opentelemetrycollector - scope: Namespaced - versions: - - additionalPrinterColumns: - - description: Deployment Mode - jsonPath: .spec.mode - name: Mode - type: string - - description: OpenTelemetry Version - jsonPath: .status.version - name: Version - type: string - - jsonPath: .metadata.creationTimestamp - name: Age - type: date - name: v1alpha1 - schema: - openAPIV3Schema: - description: OpenTelemetryCollector is the Schema for the opentelemetrycollectors API. - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - description: OpenTelemetryCollectorSpec defines the desired state of OpenTelemetryCollector. - properties: - args: - additionalProperties: - type: string - description: Args is the set of arguments to pass to the OpenTelemetry Collector binary - type: object - config: - description: Config is the raw JSON to be used as the collector's configuration. Refer to the OpenTelemetry Collector documentation for details. - type: string - env: - description: ENV vars to set on the OpenTelemetry Collector's Pods. These can then in certain cases be consumed in the config file for the Collector. - items: - description: EnvVar represents an environment variable present in a Container. - properties: - name: - description: Name of the environment variable. Must be a C_IDENTIFIER. - type: string - value: - description: 'Variable references $(VAR_NAME) are expanded using the previously defined environment variables in the container and any service environment variables. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "".' - type: string - valueFrom: - description: Source for the environment variable's value. Cannot be used if value is not empty. - properties: - configMapKeyRef: - description: Selects a key of a ConfigMap. - properties: - key: - description: The key to select. - type: string - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - optional: - description: Specify whether the ConfigMap or its key must be defined - type: boolean - required: - - key - type: object - fieldRef: - description: 'Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['''']`, `metadata.annotations['''']`, spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs.' - properties: - apiVersion: - description: Version of the schema the FieldPath is written in terms of, defaults to "v1". - type: string - fieldPath: - description: Path of the field to select in the specified API version. - type: string - required: - - fieldPath - type: object - resourceFieldRef: - description: 'Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported.' - properties: - containerName: - description: 'Container name: required for volumes, optional for env vars' - type: string - divisor: - anyOf: - - type: integer - - type: string - description: Specifies the output format of the exposed resources, defaults to "1" - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - resource: - description: 'Required: resource to select' - type: string - required: - - resource - type: object - secretKeyRef: - description: Selects a key of a secret in the pod's namespace - properties: - key: - description: The key of the secret to select from. Must be a valid secret key. - type: string - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - optional: - description: Specify whether the Secret or its key must be defined - type: boolean - required: - - key - type: object - type: object - required: - - name - type: object - type: array - envFrom: - description: List of sources to populate environment variables on the OpenTelemetry Collector's Pods. These can then in certain cases be consumed in the config file for the Collector. - items: - description: EnvFromSource represents the source of a set of ConfigMaps - properties: - configMapRef: - description: The ConfigMap to select from - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - optional: - description: Specify whether the ConfigMap must be defined - type: boolean - type: object - prefix: - description: An optional identifier to prepend to each key in the ConfigMap. Must be a C_IDENTIFIER. - type: string - secretRef: - description: The Secret to select from - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - optional: - description: Specify whether the Secret must be defined - type: boolean - type: object - type: object - type: array - hostNetwork: - description: HostNetwork indicates if the pod should run in the host networking namespace. - type: boolean - image: - description: Image indicates the container image to use for the OpenTelemetry Collector. - type: string - imagePullPolicy: - description: ImagePullPolicy indicates the pull policy to be used for retrieving the container image (Always, Never, IfNotPresent) - type: string - maxReplicas: - description: MaxReplicas sets an upper bound to the autoscaling feature. If MaxReplicas is set autoscaling is enabled. - format: int32 - type: integer - mode: - description: Mode represents how the collector should be deployed (deployment, daemonset, statefulset or sidecar) - enum: - - daemonset - - deployment - - sidecar - - statefulset - type: string - nodeSelector: - additionalProperties: - type: string - description: NodeSelector to schedule OpenTelemetry Collector pods. This is only relevant to daemonset, statefulset, and deployment mode - type: object - podAnnotations: - additionalProperties: - type: string - description: PodAnnotations is the set of annotations that will be attached to Collector and Target Allocator pods. - type: object - podSecurityContext: - description: PodSecurityContext holds pod-level security attributes and common container settings. Some fields are also present in container.securityContext. Field values of container.securityContext take precedence over field values of PodSecurityContext. - properties: - fsGroup: - description: "A special supplemental group that applies to all containers in a pod. Some volume types allow the Kubelet to change the ownership of that volume to be owned by the pod: \n 1. The owning GID will be the FSGroup 2. The setgid bit is set (new files created in the volume will be owned by FSGroup) 3. The permission bits are OR'd with rw-rw---- \n If unset, the Kubelet will not modify the ownership and permissions of any volume. Note that this field cannot be set when spec.os.name is windows." - format: int64 - type: integer - fsGroupChangePolicy: - description: 'fsGroupChangePolicy defines behavior of changing ownership and permission of the volume before being exposed inside Pod. This field will only apply to volume types which support fsGroup based ownership(and permissions). It will have no effect on ephemeral volume types such as: secret, configmaps and emptydir. Valid values are "OnRootMismatch" and "Always". If not specified, "Always" is used. Note that this field cannot be set when spec.os.name is windows.' - type: string - runAsGroup: - description: The GID to run the entrypoint of the container process. Uses runtime default if unset. May also be set in SecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence for that container. Note that this field cannot be set when spec.os.name is windows. - format: int64 - type: integer - runAsNonRoot: - description: Indicates that the container must run as a non-root user. If true, the Kubelet will validate the image at runtime to ensure that it does not run as UID 0 (root) and fail to start the container if it does. If unset or false, no such validation will be performed. May also be set in SecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence. - type: boolean - runAsUser: - description: The UID to run the entrypoint of the container process. Defaults to user specified in image metadata if unspecified. May also be set in SecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence for that container. Note that this field cannot be set when spec.os.name is windows. - format: int64 - type: integer - seLinuxOptions: - description: The SELinux context to be applied to all containers. If unspecified, the container runtime will allocate a random SELinux context for each container. May also be set in SecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence for that container. Note that this field cannot be set when spec.os.name is windows. - properties: - level: - description: Level is SELinux level label that applies to the container. - type: string - role: - description: Role is a SELinux role label that applies to the container. - type: string - type: - description: Type is a SELinux type label that applies to the container. - type: string - user: - description: User is a SELinux user label that applies to the container. - type: string - type: object - seccompProfile: - description: The seccomp options to use by the containers in this pod. Note that this field cannot be set when spec.os.name is windows. - properties: - localhostProfile: - description: localhostProfile indicates a profile defined in a file on the node should be used. The profile must be preconfigured on the node to work. Must be a descending path, relative to the kubelet's configured seccomp profile location. Must only be set if type is "Localhost". - type: string - type: - description: "type indicates which kind of seccomp profile will be applied. Valid options are: \n Localhost - a profile defined in a file on the node should be used. RuntimeDefault - the container runtime default profile should be used. Unconfined - no profile should be applied." - type: string - required: - - type - type: object - supplementalGroups: - description: A list of groups applied to the first process run in each container, in addition to the container's primary GID. If unspecified, no groups will be added to any container. Note that this field cannot be set when spec.os.name is windows. - items: - format: int64 - type: integer - type: array - sysctls: - description: Sysctls hold a list of namespaced sysctls used for the pod. Pods with unsupported sysctls (by the container runtime) might fail to launch. Note that this field cannot be set when spec.os.name is windows. - items: - description: Sysctl defines a kernel parameter to be set - properties: - name: - description: Name of a property to set - type: string - value: - description: Value of a property to set - type: string - required: - - name - - value - type: object - type: array - windowsOptions: - description: The Windows specific settings applied to all containers. If unspecified, the options within a container's SecurityContext will be used. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence. Note that this field cannot be set when spec.os.name is linux. - properties: - gmsaCredentialSpec: - description: GMSACredentialSpec is where the GMSA admission webhook (https://github.com/kubernetes-sigs/windows-gmsa) inlines the contents of the GMSA credential spec named by the GMSACredentialSpecName field. - type: string - gmsaCredentialSpecName: - description: GMSACredentialSpecName is the name of the GMSA credential spec to use. - type: string - hostProcess: - description: HostProcess determines if a container should be run as a 'Host Process' container. This field is alpha-level and will only be honored by components that enable the WindowsHostProcessContainers feature flag. Setting this field without the feature flag will result in errors when validating the Pod. All of a Pod's containers must have the same effective HostProcess value (it is not allowed to have a mix of HostProcess containers and non-HostProcess containers). In addition, if HostProcess is true then HostNetwork must also be set to true. - type: boolean - runAsUserName: - description: The UserName in Windows to run the entrypoint of the container process. Defaults to the user specified in image metadata if unspecified. May also be set in PodSecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence. - type: string - type: object - type: object - ports: - description: Ports allows a set of ports to be exposed by the underlying v1.Service. By default, the operator will attempt to infer the required ports by parsing the .Spec.Config property but this property can be used to open aditional ports that can't be inferred by the operator, like for custom receivers. - items: - description: ServicePort contains information on service's port. - properties: - appProtocol: - description: The application protocol for this port. This field follows standard Kubernetes label syntax. Un-prefixed names are reserved for IANA standard service names (as per RFC-6335 and http://www.iana.org/assignments/service-names). Non-standard protocols should use prefixed names such as mycompany.com/my-custom-protocol. - type: string - name: - description: The name of this port within the service. This must be a DNS_LABEL. All ports within a ServiceSpec must have unique names. When considering the endpoints for a Service, this must match the 'name' field in the EndpointPort. Optional if only one ServicePort is defined on this service. - type: string - nodePort: - description: 'The port on each node on which this service is exposed when type is NodePort or LoadBalancer. Usually assigned by the system. If a value is specified, in-range, and not in use it will be used, otherwise the operation will fail. If not specified, a port will be allocated if this Service requires one. If this field is specified when creating a Service which does not need it, creation will fail. This field will be wiped when updating a Service to no longer need it (e.g. changing type from NodePort to ClusterIP). More info: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport' - format: int32 - type: integer - port: - description: The port that will be exposed by this service. - format: int32 - type: integer - protocol: - default: TCP - description: The IP protocol for this port. Supports "TCP", "UDP", and "SCTP". Default is TCP. - type: string - targetPort: - anyOf: - - type: integer - - type: string - description: 'Number or name of the port to access on the pods targeted by the service. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME. If this is a string, it will be looked up as a named port in the target Pod''s container ports. If this is not specified, the value of the ''port'' field is used (an identity map). This field is ignored for services with clusterIP=None, and should be omitted or set equal to the ''port'' field. More info: https://kubernetes.io/docs/concepts/services-networking/service/#defining-a-service' - x-kubernetes-int-or-string: true - required: - - port - type: object - type: array - x-kubernetes-list-type: atomic - replicas: - description: Replicas is the number of pod instances for the underlying OpenTelemetry Collector - format: int32 - type: integer - resources: - description: Resources to set on the OpenTelemetry Collector pods. - properties: - limits: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' - type: object - requests: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' - type: object - type: object - securityContext: - description: SecurityContext will be set as the container security context. - properties: - allowPrivilegeEscalation: - description: 'AllowPrivilegeEscalation controls whether a process can gain more privileges than its parent process. This bool directly controls if the no_new_privs flag will be set on the container process. AllowPrivilegeEscalation is true always when the container is: 1) run as Privileged 2) has CAP_SYS_ADMIN Note that this field cannot be set when spec.os.name is windows.' - type: boolean - capabilities: - description: The capabilities to add/drop when running containers. Defaults to the default set of capabilities granted by the container runtime. Note that this field cannot be set when spec.os.name is windows. - properties: - add: - description: Added capabilities - items: - description: Capability represent POSIX capabilities type - type: string - type: array - drop: - description: Removed capabilities - items: - description: Capability represent POSIX capabilities type - type: string - type: array - type: object - privileged: - description: Run container in privileged mode. Processes in privileged containers are essentially equivalent to root on the host. Defaults to false. Note that this field cannot be set when spec.os.name is windows. - type: boolean - procMount: - description: procMount denotes the type of proc mount to use for the containers. The default is DefaultProcMount which uses the container runtime defaults for readonly paths and masked paths. This requires the ProcMountType feature flag to be enabled. Note that this field cannot be set when spec.os.name is windows. - type: string - readOnlyRootFilesystem: - description: Whether this container has a read-only root filesystem. Default is false. Note that this field cannot be set when spec.os.name is windows. - type: boolean - runAsGroup: - description: The GID to run the entrypoint of the container process. Uses runtime default if unset. May also be set in PodSecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence. Note that this field cannot be set when spec.os.name is windows. - format: int64 - type: integer - runAsNonRoot: - description: Indicates that the container must run as a non-root user. If true, the Kubelet will validate the image at runtime to ensure that it does not run as UID 0 (root) and fail to start the container if it does. If unset or false, no such validation will be performed. May also be set in PodSecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence. - type: boolean - runAsUser: - description: The UID to run the entrypoint of the container process. Defaults to user specified in image metadata if unspecified. May also be set in PodSecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence. Note that this field cannot be set when spec.os.name is windows. - format: int64 - type: integer - seLinuxOptions: - description: The SELinux context to be applied to the container. If unspecified, the container runtime will allocate a random SELinux context for each container. May also be set in PodSecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence. Note that this field cannot be set when spec.os.name is windows. - properties: - level: - description: Level is SELinux level label that applies to the container. - type: string - role: - description: Role is a SELinux role label that applies to the container. - type: string - type: - description: Type is a SELinux type label that applies to the container. - type: string - user: - description: User is a SELinux user label that applies to the container. - type: string - type: object - seccompProfile: - description: The seccomp options to use by this container. If seccomp options are provided at both the pod & container level, the container options override the pod options. Note that this field cannot be set when spec.os.name is windows. - properties: - localhostProfile: - description: localhostProfile indicates a profile defined in a file on the node should be used. The profile must be preconfigured on the node to work. Must be a descending path, relative to the kubelet's configured seccomp profile location. Must only be set if type is "Localhost". - type: string - type: - description: "type indicates which kind of seccomp profile will be applied. Valid options are: \n Localhost - a profile defined in a file on the node should be used. RuntimeDefault - the container runtime default profile should be used. Unconfined - no profile should be applied." - type: string - required: - - type - type: object - windowsOptions: - description: The Windows specific settings applied to all containers. If unspecified, the options from the PodSecurityContext will be used. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence. Note that this field cannot be set when spec.os.name is linux. - properties: - gmsaCredentialSpec: - description: GMSACredentialSpec is where the GMSA admission webhook (https://github.com/kubernetes-sigs/windows-gmsa) inlines the contents of the GMSA credential spec named by the GMSACredentialSpecName field. - type: string - gmsaCredentialSpecName: - description: GMSACredentialSpecName is the name of the GMSA credential spec to use. - type: string - hostProcess: - description: HostProcess determines if a container should be run as a 'Host Process' container. This field is alpha-level and will only be honored by components that enable the WindowsHostProcessContainers feature flag. Setting this field without the feature flag will result in errors when validating the Pod. All of a Pod's containers must have the same effective HostProcess value (it is not allowed to have a mix of HostProcess containers and non-HostProcess containers). In addition, if HostProcess is true then HostNetwork must also be set to true. - type: boolean - runAsUserName: - description: The UserName in Windows to run the entrypoint of the container process. Defaults to the user specified in image metadata if unspecified. May also be set in PodSecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence. - type: string - type: object - type: object - serviceAccount: - description: ServiceAccount indicates the name of an existing service account to use with this instance. - type: string - targetAllocator: - description: TargetAllocator indicates a value which determines whether to spawn a target allocation resource or not. - properties: - enabled: - description: Enabled indicates whether to use a target allocation mechanism for Prometheus targets or not. - type: boolean - image: - description: Image indicates the container image to use for the OpenTelemetry TargetAllocator. - type: string - type: object - tolerations: - description: Toleration to schedule OpenTelemetry Collector pods. This is only relevant to daemonset, statefulset, and deployment mode - items: - description: The pod this Toleration is attached to tolerates any taint that matches the triple using the matching operator . - properties: - effect: - description: Effect indicates the taint effect to match. Empty means match all taint effects. When specified, allowed values are NoSchedule, PreferNoSchedule and NoExecute. - type: string - key: - description: Key is the taint key that the toleration applies to. Empty means match all taint keys. If the key is empty, operator must be Exists; this combination means to match all values and all keys. - type: string - operator: - description: Operator represents a key's relationship to the value. Valid operators are Exists and Equal. Defaults to Equal. Exists is equivalent to wildcard for value, so that a pod can tolerate all taints of a particular category. - type: string - tolerationSeconds: - description: TolerationSeconds represents the period of time the toleration (which must be of effect NoExecute, otherwise this field is ignored) tolerates the taint. By default, it is not set, which means tolerate the taint forever (do not evict). Zero and negative values will be treated as 0 (evict immediately) by the system. - format: int64 - type: integer - value: - description: Value is the taint value the toleration matches to. If the operator is Exists, the value should be empty, otherwise just a regular string. - type: string - type: object - type: array - upgradeStrategy: - description: UpgradeStrategy represents how the operator will handle upgrades to the CR when a newer version of the operator is deployed - enum: - - automatic - - none - type: string - volumeClaimTemplates: - description: VolumeClaimTemplates will provide stable storage using PersistentVolumes. Only available when the mode=statefulset. - items: - description: PersistentVolumeClaim is a user's request for and claim to a persistent volume - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata' - properties: - annotations: - additionalProperties: - type: string - type: object - finalizers: - items: - type: string - type: array - labels: - additionalProperties: - type: string - type: object - name: - type: string - namespace: - type: string - type: object - spec: - description: 'Spec defines the desired characteristics of a volume requested by a pod author. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims' - properties: - accessModes: - description: 'AccessModes contains the desired access modes the volume should have. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1' - items: - type: string - type: array - dataSource: - description: 'This field can be used to specify either: * An existing VolumeSnapshot object (snapshot.storage.k8s.io/VolumeSnapshot) * An existing PVC (PersistentVolumeClaim) If the provisioner or an external controller can support the specified data source, it will create a new volume based on the contents of the specified data source. If the AnyVolumeDataSource feature gate is enabled, this field will always have the same contents as the DataSourceRef field.' - properties: - apiGroup: - description: APIGroup is the group for the resource being referenced. If APIGroup is not specified, the specified Kind must be in the core API group. For any other third-party types, APIGroup is required. - type: string - kind: - description: Kind is the type of resource being referenced - type: string - name: - description: Name is the name of resource being referenced - type: string - required: - - kind - - name - type: object - dataSourceRef: - description: 'Specifies the object from which to populate the volume with data, if a non-empty volume is desired. This may be any local object from a non-empty API group (non core object) or a PersistentVolumeClaim object. When this field is specified, volume binding will only succeed if the type of the specified object matches some installed volume populator or dynamic provisioner. This field will replace the functionality of the DataSource field and as such if both fields are non-empty, they must have the same value. For backwards compatibility, both fields (DataSource and DataSourceRef) will be set to the same value automatically if one of them is empty and the other is non-empty. There are two important differences between DataSource and DataSourceRef: * While DataSource only allows two specific types of objects, DataSourceRef allows any non-core object, as well as PersistentVolumeClaim objects. * While DataSource ignores disallowed values (dropping them), DataSourceRef preserves all values, and generates an error if a disallowed value is specified. (Alpha) Using this field requires the AnyVolumeDataSource feature gate to be enabled.' - properties: - apiGroup: - description: APIGroup is the group for the resource being referenced. If APIGroup is not specified, the specified Kind must be in the core API group. For any other third-party types, APIGroup is required. - type: string - kind: - description: Kind is the type of resource being referenced - type: string - name: - description: Name is the name of resource being referenced - type: string - required: - - kind - - name - type: object - resources: - description: 'Resources represents the minimum resources the volume should have. If RecoverVolumeExpansionFailure feature is enabled users are allowed to specify resource requirements that are lower than previous value but must still be higher than capacity recorded in the status field of the claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources' - properties: - limits: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' - type: object - requests: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' - type: object - type: object - selector: - description: A label query over volumes to consider for binding. - properties: - matchExpressions: - description: matchExpressions is a list of label selector requirements. The requirements are ANDed. - items: - description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. - properties: - key: - description: key is the label key that the selector applies to. - type: string - operator: - description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist. - type: string - values: - description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchLabels: - additionalProperties: - type: string - description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. - type: object - type: object - storageClassName: - description: 'Name of the StorageClass required by the claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1' - type: string - volumeMode: - description: volumeMode defines what type of volume is required by the claim. Value of Filesystem is implied when not included in claim spec. - type: string - volumeName: - description: VolumeName is the binding reference to the PersistentVolume backing this claim. - type: string - type: object - status: - description: 'Status represents the current information/status of a persistent volume claim. Read-only. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims' - properties: - accessModes: - description: 'AccessModes contains the actual access modes the volume backing the PVC has. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1' - items: - type: string - type: array - allocatedResources: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: The storage resource within AllocatedResources tracks the capacity allocated to a PVC. It may be larger than the actual capacity when a volume expansion operation is requested. For storage quota, the larger value from allocatedResources and PVC.spec.resources is used. If allocatedResources is not set, PVC.spec.resources alone is used for quota calculation. If a volume expansion capacity request is lowered, allocatedResources is only lowered if there are no expansion operations in progress and if the actual volume capacity is equal or lower than the requested capacity. This is an alpha field and requires enabling RecoverVolumeExpansionFailure feature. - type: object - capacity: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: Represents the actual resources of the underlying volume. - type: object - conditions: - description: Current Condition of persistent volume claim. If underlying persistent volume is being resized then the Condition will be set to 'ResizeStarted'. - items: - description: PersistentVolumeClaimCondition contails details about state of pvc - properties: - lastProbeTime: - description: Last time we probed the condition. - format: date-time - type: string - lastTransitionTime: - description: Last time the condition transitioned from one status to another. - format: date-time - type: string - message: - description: Human-readable message indicating details about last transition. - type: string - reason: - description: Unique, this should be a short, machine understandable string that gives the reason for condition's last transition. If it reports "ResizeStarted" that means the underlying persistent volume is being resized. - type: string - status: - type: string - type: - description: PersistentVolumeClaimConditionType is a valid value of PersistentVolumeClaimCondition.Type - type: string - required: - - status - - type - type: object - type: array - phase: - description: Phase represents the current phase of PersistentVolumeClaim. - type: string - resizeStatus: - description: ResizeStatus stores status of resize operation. ResizeStatus is not set by default but when expansion is complete resizeStatus is set to empty string by resize controller or kubelet. This is an alpha field and requires enabling RecoverVolumeExpansionFailure feature. - type: string - type: object - type: object - type: array - x-kubernetes-list-type: atomic - volumeMounts: - description: VolumeMounts represents the mount points to use in the underlying collector deployment(s) - items: - description: VolumeMount describes a mounting of a Volume within a container. - properties: - mountPath: - description: Path within the container at which the volume should be mounted. Must not contain ':'. - type: string - mountPropagation: - description: mountPropagation determines how mounts are propagated from the host to container and the other way around. When not set, MountPropagationNone is used. This field is beta in 1.10. - type: string - name: - description: This must match the Name of a Volume. - type: string - readOnly: - description: Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false. - type: boolean - subPath: - description: Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root). - type: string - subPathExpr: - description: Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root). SubPathExpr and SubPath are mutually exclusive. - type: string - required: - - mountPath - - name - type: object - type: array - x-kubernetes-list-type: atomic - volumes: - description: Volumes represents which volumes to use in the underlying collector deployment(s). - items: - description: Volume represents a named volume in a pod that may be accessed by any container in the pod. - properties: - awsElasticBlockStore: - description: 'AWSElasticBlockStore represents an AWS Disk resource that is attached to a kubelet''s host machine and then exposed to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore' - properties: - fsType: - description: 'Filesystem type of the volume that you want to mount. Tip: Ensure that the filesystem type is supported by the host operating system. Examples: "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified. More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore TODO: how do we prevent errors in the filesystem from compromising the machine' - type: string - partition: - description: 'The partition in the volume that you want to mount. If omitted, the default is to mount by volume name. Examples: For volume /dev/sda1, you specify the partition as "1". Similarly, the volume partition for /dev/sda is "0" (or you can leave the property empty).' - format: int32 - type: integer - readOnly: - description: 'Specify "true" to force and set the ReadOnly property in VolumeMounts to "true". If omitted, the default is "false". More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore' - type: boolean - volumeID: - description: 'Unique ID of the persistent disk resource in AWS (Amazon EBS volume). More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore' - type: string - required: - - volumeID - type: object - azureDisk: - description: AzureDisk represents an Azure Data Disk mount on the host and bind mount to the pod. - properties: - cachingMode: - description: 'Host Caching mode: None, Read Only, Read Write.' - type: string - diskName: - description: The Name of the data disk in the blob storage - type: string - diskURI: - description: The URI the data disk in the blob storage - type: string - fsType: - description: Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified. - type: string - kind: - description: 'Expected values Shared: multiple blob disks per storage account Dedicated: single blob disk per storage account Managed: azure managed data disk (only in managed availability set). defaults to shared' - type: string - readOnly: - description: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts. - type: boolean - required: - - diskName - - diskURI - type: object - azureFile: - description: AzureFile represents an Azure File Service mount on the host and bind mount to the pod. - properties: - readOnly: - description: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts. - type: boolean - secretName: - description: the name of secret that contains Azure Storage Account Name and Key - type: string - shareName: - description: Share Name - type: string - required: - - secretName - - shareName - type: object - cephfs: - description: CephFS represents a Ceph FS mount on the host that shares a pod's lifetime - properties: - monitors: - description: 'Required: Monitors is a collection of Ceph monitors More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it' - items: - type: string - type: array - path: - description: 'Optional: Used as the mounted root, rather than the full Ceph tree, default is /' - type: string - readOnly: - description: 'Optional: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts. More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it' - type: boolean - secretFile: - description: 'Optional: SecretFile is the path to key ring for User, default is /etc/ceph/user.secret More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it' - type: string - secretRef: - description: 'Optional: SecretRef is reference to the authentication secret for User, default is empty. More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it' - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - user: - description: 'Optional: User is the rados user name, default is admin More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it' - type: string - required: - - monitors - type: object - cinder: - description: 'Cinder represents a cinder volume attached and mounted on kubelets host machine. More info: https://examples.k8s.io/mysql-cinder-pd/README.md' - properties: - fsType: - description: 'Filesystem type to mount. Must be a filesystem type supported by the host operating system. Examples: "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified. More info: https://examples.k8s.io/mysql-cinder-pd/README.md' - type: string - readOnly: - description: 'Optional: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts. More info: https://examples.k8s.io/mysql-cinder-pd/README.md' - type: boolean - secretRef: - description: 'Optional: points to a secret object containing parameters used to connect to OpenStack.' - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - volumeID: - description: 'volume id used to identify the volume in cinder. More info: https://examples.k8s.io/mysql-cinder-pd/README.md' - type: string - required: - - volumeID - type: object - configMap: - description: ConfigMap represents a configMap that should populate this volume - properties: - defaultMode: - description: 'Optional: mode bits used to set permissions on created files by default. Must be an octal value between 0000 and 0777 or a decimal value between 0 and 511. YAML accepts both octal and decimal values, JSON requires decimal values for mode bits. Defaults to 0644. Directories within the path are not affected by this setting. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.' - format: int32 - type: integer - items: - description: If unspecified, each key-value pair in the Data field of the referenced ConfigMap will be projected into the volume as a file whose name is the key and content is the value. If specified, the listed keys will be projected into the specified paths, and unlisted keys will not be present. If a key is specified which is not present in the ConfigMap, the volume setup will error unless it is marked optional. Paths must be relative and may not contain the '..' path or start with '..'. - items: - description: Maps a string key to a path within a volume. - properties: - key: - description: The key to project. - type: string - mode: - description: 'Optional: mode bits used to set permissions on this file. Must be an octal value between 0000 and 0777 or a decimal value between 0 and 511. YAML accepts both octal and decimal values, JSON requires decimal values for mode bits. If not specified, the volume defaultMode will be used. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.' - format: int32 - type: integer - path: - description: The relative path of the file to map the key to. May not be an absolute path. May not contain the path element '..'. May not start with the string '..'. - type: string - required: - - key - - path - type: object - type: array - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - optional: - description: Specify whether the ConfigMap or its keys must be defined - type: boolean - type: object - csi: - description: CSI (Container Storage Interface) represents ephemeral storage that is handled by certain external CSI drivers (Beta feature). - properties: - driver: - description: Driver is the name of the CSI driver that handles this volume. Consult with your admin for the correct name as registered in the cluster. - type: string - fsType: - description: Filesystem type to mount. Ex. "ext4", "xfs", "ntfs". If not provided, the empty value is passed to the associated CSI driver which will determine the default filesystem to apply. - type: string - nodePublishSecretRef: - description: NodePublishSecretRef is a reference to the secret object containing sensitive information to pass to the CSI driver to complete the CSI NodePublishVolume and NodeUnpublishVolume calls. This field is optional, and may be empty if no secret is required. If the secret object contains more than one secret, all secret references are passed. - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - readOnly: - description: Specifies a read-only configuration for the volume. Defaults to false (read/write). - type: boolean - volumeAttributes: - additionalProperties: - type: string - description: VolumeAttributes stores driver-specific properties that are passed to the CSI driver. Consult your driver's documentation for supported values. - type: object - required: - - driver - type: object - downwardAPI: - description: DownwardAPI represents downward API about the pod that should populate this volume - properties: - defaultMode: - description: 'Optional: mode bits to use on created files by default. Must be a Optional: mode bits used to set permissions on created files by default. Must be an octal value between 0000 and 0777 or a decimal value between 0 and 511. YAML accepts both octal and decimal values, JSON requires decimal values for mode bits. Defaults to 0644. Directories within the path are not affected by this setting. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.' - format: int32 - type: integer - items: - description: Items is a list of downward API volume file - items: - description: DownwardAPIVolumeFile represents information to create the file containing the pod field - properties: - fieldRef: - description: 'Required: Selects a field of the pod: only annotations, labels, name and namespace are supported.' - properties: - apiVersion: - description: Version of the schema the FieldPath is written in terms of, defaults to "v1". - type: string - fieldPath: - description: Path of the field to select in the specified API version. - type: string - required: - - fieldPath - type: object - mode: - description: 'Optional: mode bits used to set permissions on this file, must be an octal value between 0000 and 0777 or a decimal value between 0 and 511. YAML accepts both octal and decimal values, JSON requires decimal values for mode bits. If not specified, the volume defaultMode will be used. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.' - format: int32 - type: integer - path: - description: 'Required: Path is the relative path name of the file to be created. Must not be absolute or contain the ''..'' path. Must be utf-8 encoded. The first item of the relative path must not start with ''..''' - type: string - resourceFieldRef: - description: 'Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported.' - properties: - containerName: - description: 'Container name: required for volumes, optional for env vars' - type: string - divisor: - anyOf: - - type: integer - - type: string - description: Specifies the output format of the exposed resources, defaults to "1" - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - resource: - description: 'Required: resource to select' - type: string - required: - - resource - type: object - required: - - path - type: object - type: array - type: object - emptyDir: - description: 'EmptyDir represents a temporary directory that shares a pod''s lifetime. More info: https://kubernetes.io/docs/concepts/storage/volumes#emptydir' - properties: - medium: - description: 'What type of storage medium should back this directory. The default is "" which means to use the node''s default medium. Must be an empty string (default) or Memory. More info: https://kubernetes.io/docs/concepts/storage/volumes#emptydir' - type: string - sizeLimit: - anyOf: - - type: integer - - type: string - description: 'Total amount of local storage required for this EmptyDir volume. The size limit is also applicable for memory medium. The maximum usage on memory medium EmptyDir would be the minimum value between the SizeLimit specified here and the sum of memory limits of all containers in a pod. The default is nil which means that the limit is undefined. More info: http://kubernetes.io/docs/user-guide/volumes#emptydir' - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - type: object - ephemeral: - description: "Ephemeral represents a volume that is handled by a cluster storage driver. The volume's lifecycle is tied to the pod that defines it - it will be created before the pod starts, and deleted when the pod is removed. \n Use this if: a) the volume is only needed while the pod runs, b) features of normal volumes like restoring from snapshot or capacity tracking are needed, c) the storage driver is specified through a storage class, and d) the storage driver supports dynamic volume provisioning through a PersistentVolumeClaim (see EphemeralVolumeSource for more information on the connection between this volume type and PersistentVolumeClaim). \n Use PersistentVolumeClaim or one of the vendor-specific APIs for volumes that persist for longer than the lifecycle of an individual pod. \n Use CSI for light-weight local ephemeral volumes if the CSI driver is meant to be used that way - see the documentation of the driver for more information. \n A pod can use both types of ephemeral volumes and persistent volumes at the same time." - properties: - volumeClaimTemplate: - description: "Will be used to create a stand-alone PVC to provision the volume. The pod in which this EphemeralVolumeSource is embedded will be the owner of the PVC, i.e. the PVC will be deleted together with the pod. The name of the PVC will be `-` where `` is the name from the `PodSpec.Volumes` array entry. Pod validation will reject the pod if the concatenated name is not valid for a PVC (for example, too long). \n An existing PVC with that name that is not owned by the pod will *not* be used for the pod to avoid using an unrelated volume by mistake. Starting the pod is then blocked until the unrelated PVC is removed. If such a pre-created PVC is meant to be used by the pod, the PVC has to updated with an owner reference to the pod once the pod exists. Normally this should not be necessary, but it may be useful when manually reconstructing a broken cluster. \n This field is read-only and no changes will be made by Kubernetes to the PVC after it has been created. \n Required, must not be nil." - properties: - metadata: - description: May contain labels and annotations that will be copied into the PVC when creating it. No other fields are allowed and will be rejected during validation. - properties: - annotations: - additionalProperties: - type: string - type: object - finalizers: - items: - type: string - type: array - labels: - additionalProperties: - type: string - type: object - name: - type: string - namespace: - type: string - type: object - spec: - description: The specification for the PersistentVolumeClaim. The entire content is copied unchanged into the PVC that gets created from this template. The same fields as in a PersistentVolumeClaim are also valid here. - properties: - accessModes: - description: 'AccessModes contains the desired access modes the volume should have. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1' - items: - type: string - type: array - dataSource: - description: 'This field can be used to specify either: * An existing VolumeSnapshot object (snapshot.storage.k8s.io/VolumeSnapshot) * An existing PVC (PersistentVolumeClaim) If the provisioner or an external controller can support the specified data source, it will create a new volume based on the contents of the specified data source. If the AnyVolumeDataSource feature gate is enabled, this field will always have the same contents as the DataSourceRef field.' - properties: - apiGroup: - description: APIGroup is the group for the resource being referenced. If APIGroup is not specified, the specified Kind must be in the core API group. For any other third-party types, APIGroup is required. - type: string - kind: - description: Kind is the type of resource being referenced - type: string - name: - description: Name is the name of resource being referenced - type: string - required: - - kind - - name - type: object - dataSourceRef: - description: 'Specifies the object from which to populate the volume with data, if a non-empty volume is desired. This may be any local object from a non-empty API group (non core object) or a PersistentVolumeClaim object. When this field is specified, volume binding will only succeed if the type of the specified object matches some installed volume populator or dynamic provisioner. This field will replace the functionality of the DataSource field and as such if both fields are non-empty, they must have the same value. For backwards compatibility, both fields (DataSource and DataSourceRef) will be set to the same value automatically if one of them is empty and the other is non-empty. There are two important differences between DataSource and DataSourceRef: * While DataSource only allows two specific types of objects, DataSourceRef allows any non-core object, as well as PersistentVolumeClaim objects. * While DataSource ignores disallowed values (dropping them), DataSourceRef preserves all values, and generates an error if a disallowed value is specified. (Alpha) Using this field requires the AnyVolumeDataSource feature gate to be enabled.' - properties: - apiGroup: - description: APIGroup is the group for the resource being referenced. If APIGroup is not specified, the specified Kind must be in the core API group. For any other third-party types, APIGroup is required. - type: string - kind: - description: Kind is the type of resource being referenced - type: string - name: - description: Name is the name of resource being referenced - type: string - required: - - kind - - name - type: object - resources: - description: 'Resources represents the minimum resources the volume should have. If RecoverVolumeExpansionFailure feature is enabled users are allowed to specify resource requirements that are lower than previous value but must still be higher than capacity recorded in the status field of the claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources' - properties: - limits: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' - type: object - requests: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' - type: object - type: object - selector: - description: A label query over volumes to consider for binding. - properties: - matchExpressions: - description: matchExpressions is a list of label selector requirements. The requirements are ANDed. - items: - description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. - properties: - key: - description: key is the label key that the selector applies to. - type: string - operator: - description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist. - type: string - values: - description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchLabels: - additionalProperties: - type: string - description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. - type: object - type: object - storageClassName: - description: 'Name of the StorageClass required by the claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1' - type: string - volumeMode: - description: volumeMode defines what type of volume is required by the claim. Value of Filesystem is implied when not included in claim spec. - type: string - volumeName: - description: VolumeName is the binding reference to the PersistentVolume backing this claim. - type: string - type: object - required: - - spec - type: object - type: object - fc: - description: FC represents a Fibre Channel resource that is attached to a kubelet's host machine and then exposed to the pod. - properties: - fsType: - description: 'Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified. TODO: how do we prevent errors in the filesystem from compromising the machine' - type: string - lun: - description: 'Optional: FC target lun number' - format: int32 - type: integer - readOnly: - description: 'Optional: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.' - type: boolean - targetWWNs: - description: 'Optional: FC target worldwide names (WWNs)' - items: - type: string - type: array - wwids: - description: 'Optional: FC volume world wide identifiers (wwids) Either wwids or combination of targetWWNs and lun must be set, but not both simultaneously.' - items: - type: string - type: array - type: object - flexVolume: - description: FlexVolume represents a generic volume resource that is provisioned/attached using an exec based plugin. - properties: - driver: - description: Driver is the name of the driver to use for this volume. - type: string - fsType: - description: Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs", "ntfs". The default filesystem depends on FlexVolume script. - type: string - options: - additionalProperties: - type: string - description: 'Optional: Extra command options if any.' - type: object - readOnly: - description: 'Optional: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.' - type: boolean - secretRef: - description: 'Optional: SecretRef is reference to the secret object containing sensitive information to pass to the plugin scripts. This may be empty if no secret object is specified. If the secret object contains more than one secret, all secrets are passed to the plugin scripts.' - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - required: - - driver - type: object - flocker: - description: Flocker represents a Flocker volume attached to a kubelet's host machine. This depends on the Flocker control service being running - properties: - datasetName: - description: Name of the dataset stored as metadata -> name on the dataset for Flocker should be considered as deprecated - type: string - datasetUUID: - description: UUID of the dataset. This is unique identifier of a Flocker dataset - type: string - type: object - gcePersistentDisk: - description: 'GCEPersistentDisk represents a GCE Disk resource that is attached to a kubelet''s host machine and then exposed to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk' - properties: - fsType: - description: 'Filesystem type of the volume that you want to mount. Tip: Ensure that the filesystem type is supported by the host operating system. Examples: "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk TODO: how do we prevent errors in the filesystem from compromising the machine' - type: string - partition: - description: 'The partition in the volume that you want to mount. If omitted, the default is to mount by volume name. Examples: For volume /dev/sda1, you specify the partition as "1". Similarly, the volume partition for /dev/sda is "0" (or you can leave the property empty). More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk' - format: int32 - type: integer - pdName: - description: 'Unique name of the PD resource in GCE. Used to identify the disk in GCE. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk' - type: string - readOnly: - description: 'ReadOnly here will force the ReadOnly setting in VolumeMounts. Defaults to false. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk' - type: boolean - required: - - pdName - type: object - gitRepo: - description: 'GitRepo represents a git repository at a particular revision. DEPRECATED: GitRepo is deprecated. To provision a container with a git repo, mount an EmptyDir into an InitContainer that clones the repo using git, then mount the EmptyDir into the Pod''s container.' - properties: - directory: - description: Target directory name. Must not contain or start with '..'. If '.' is supplied, the volume directory will be the git repository. Otherwise, if specified, the volume will contain the git repository in the subdirectory with the given name. - type: string - repository: - description: Repository URL - type: string - revision: - description: Commit hash for the specified revision. - type: string - required: - - repository - type: object - glusterfs: - description: 'Glusterfs represents a Glusterfs mount on the host that shares a pod''s lifetime. More info: https://examples.k8s.io/volumes/glusterfs/README.md' - properties: - endpoints: - description: 'EndpointsName is the endpoint name that details Glusterfs topology. More info: https://examples.k8s.io/volumes/glusterfs/README.md#create-a-pod' - type: string - path: - description: 'Path is the Glusterfs volume path. More info: https://examples.k8s.io/volumes/glusterfs/README.md#create-a-pod' - type: string - readOnly: - description: 'ReadOnly here will force the Glusterfs volume to be mounted with read-only permissions. Defaults to false. More info: https://examples.k8s.io/volumes/glusterfs/README.md#create-a-pod' - type: boolean - required: - - endpoints - - path - type: object - hostPath: - description: 'HostPath represents a pre-existing file or directory on the host machine that is directly exposed to the container. This is generally used for system agents or other privileged things that are allowed to see the host machine. Most containers will NOT need this. More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath --- TODO(jonesdl) We need to restrict who can use host directory mounts and who can/can not mount host directories as read/write.' - properties: - path: - description: 'Path of the directory on the host. If the path is a symlink, it will follow the link to the real path. More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath' - type: string - type: - description: 'Type for HostPath Volume Defaults to "" More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath' - type: string - required: - - path - type: object - iscsi: - description: 'ISCSI represents an ISCSI Disk resource that is attached to a kubelet''s host machine and then exposed to the pod. More info: https://examples.k8s.io/volumes/iscsi/README.md' - properties: - chapAuthDiscovery: - description: whether support iSCSI Discovery CHAP authentication - type: boolean - chapAuthSession: - description: whether support iSCSI Session CHAP authentication - type: boolean - fsType: - description: 'Filesystem type of the volume that you want to mount. Tip: Ensure that the filesystem type is supported by the host operating system. Examples: "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified. More info: https://kubernetes.io/docs/concepts/storage/volumes#iscsi TODO: how do we prevent errors in the filesystem from compromising the machine' - type: string - initiatorName: - description: Custom iSCSI Initiator Name. If initiatorName is specified with iscsiInterface simultaneously, new iSCSI interface : will be created for the connection. - type: string - iqn: - description: Target iSCSI Qualified Name. - type: string - iscsiInterface: - description: iSCSI Interface Name that uses an iSCSI transport. Defaults to 'default' (tcp). - type: string - lun: - description: iSCSI Target Lun number. - format: int32 - type: integer - portals: - description: iSCSI Target Portal List. The portal is either an IP or ip_addr:port if the port is other than default (typically TCP ports 860 and 3260). - items: - type: string - type: array - readOnly: - description: ReadOnly here will force the ReadOnly setting in VolumeMounts. Defaults to false. - type: boolean - secretRef: - description: CHAP Secret for iSCSI target and initiator authentication - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - targetPortal: - description: iSCSI Target Portal. The Portal is either an IP or ip_addr:port if the port is other than default (typically TCP ports 860 and 3260). - type: string - required: - - iqn - - lun - - targetPortal - type: object - name: - description: 'Volume''s name. Must be a DNS_LABEL and unique within the pod. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' - type: string - nfs: - description: 'NFS represents an NFS mount on the host that shares a pod''s lifetime More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs' - properties: - path: - description: 'Path that is exported by the NFS server. More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs' - type: string - readOnly: - description: 'ReadOnly here will force the NFS export to be mounted with read-only permissions. Defaults to false. More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs' - type: boolean - server: - description: 'Server is the hostname or IP address of the NFS server. More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs' - type: string - required: - - path - - server - type: object - persistentVolumeClaim: - description: 'PersistentVolumeClaimVolumeSource represents a reference to a PersistentVolumeClaim in the same namespace. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims' - properties: - claimName: - description: 'ClaimName is the name of a PersistentVolumeClaim in the same namespace as the pod using this volume. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims' - type: string - readOnly: - description: Will force the ReadOnly setting in VolumeMounts. Default false. - type: boolean - required: - - claimName - type: object - photonPersistentDisk: - description: PhotonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine - properties: - fsType: - description: Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified. - type: string - pdID: - description: ID that identifies Photon Controller persistent disk - type: string - required: - - pdID - type: object - portworxVolume: - description: PortworxVolume represents a portworx volume attached and mounted on kubelets host machine - properties: - fsType: - description: FSType represents the filesystem type to mount Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs". Implicitly inferred to be "ext4" if unspecified. - type: string - readOnly: - description: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts. - type: boolean - volumeID: - description: VolumeID uniquely identifies a Portworx volume - type: string - required: - - volumeID - type: object - projected: - description: Items for all in one resources secrets, configmaps, and downward API - properties: - defaultMode: - description: Mode bits used to set permissions on created files by default. Must be an octal value between 0000 and 0777 or a decimal value between 0 and 511. YAML accepts both octal and decimal values, JSON requires decimal values for mode bits. Directories within the path are not affected by this setting. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set. - format: int32 - type: integer - sources: - description: list of volume projections - items: - description: Projection that may be projected along with other supported volume types - properties: - configMap: - description: information about the configMap data to project - properties: - items: - description: If unspecified, each key-value pair in the Data field of the referenced ConfigMap will be projected into the volume as a file whose name is the key and content is the value. If specified, the listed keys will be projected into the specified paths, and unlisted keys will not be present. If a key is specified which is not present in the ConfigMap, the volume setup will error unless it is marked optional. Paths must be relative and may not contain the '..' path or start with '..'. - items: - description: Maps a string key to a path within a volume. - properties: - key: - description: The key to project. - type: string - mode: - description: 'Optional: mode bits used to set permissions on this file. Must be an octal value between 0000 and 0777 or a decimal value between 0 and 511. YAML accepts both octal and decimal values, JSON requires decimal values for mode bits. If not specified, the volume defaultMode will be used. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.' - format: int32 - type: integer - path: - description: The relative path of the file to map the key to. May not be an absolute path. May not contain the path element '..'. May not start with the string '..'. - type: string - required: - - key - - path - type: object - type: array - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - optional: - description: Specify whether the ConfigMap or its keys must be defined - type: boolean - type: object - downwardAPI: - description: information about the downwardAPI data to project - properties: - items: - description: Items is a list of DownwardAPIVolume file - items: - description: DownwardAPIVolumeFile represents information to create the file containing the pod field - properties: - fieldRef: - description: 'Required: Selects a field of the pod: only annotations, labels, name and namespace are supported.' - properties: - apiVersion: - description: Version of the schema the FieldPath is written in terms of, defaults to "v1". - type: string - fieldPath: - description: Path of the field to select in the specified API version. - type: string - required: - - fieldPath - type: object - mode: - description: 'Optional: mode bits used to set permissions on this file, must be an octal value between 0000 and 0777 or a decimal value between 0 and 511. YAML accepts both octal and decimal values, JSON requires decimal values for mode bits. If not specified, the volume defaultMode will be used. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.' - format: int32 - type: integer - path: - description: 'Required: Path is the relative path name of the file to be created. Must not be absolute or contain the ''..'' path. Must be utf-8 encoded. The first item of the relative path must not start with ''..''' - type: string - resourceFieldRef: - description: 'Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported.' - properties: - containerName: - description: 'Container name: required for volumes, optional for env vars' - type: string - divisor: - anyOf: - - type: integer - - type: string - description: Specifies the output format of the exposed resources, defaults to "1" - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - resource: - description: 'Required: resource to select' - type: string - required: - - resource - type: object - required: - - path - type: object - type: array - type: object - secret: - description: information about the secret data to project - properties: - items: - description: If unspecified, each key-value pair in the Data field of the referenced Secret will be projected into the volume as a file whose name is the key and content is the value. If specified, the listed keys will be projected into the specified paths, and unlisted keys will not be present. If a key is specified which is not present in the Secret, the volume setup will error unless it is marked optional. Paths must be relative and may not contain the '..' path or start with '..'. - items: - description: Maps a string key to a path within a volume. - properties: - key: - description: The key to project. - type: string - mode: - description: 'Optional: mode bits used to set permissions on this file. Must be an octal value between 0000 and 0777 or a decimal value between 0 and 511. YAML accepts both octal and decimal values, JSON requires decimal values for mode bits. If not specified, the volume defaultMode will be used. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.' - format: int32 - type: integer - path: - description: The relative path of the file to map the key to. May not be an absolute path. May not contain the path element '..'. May not start with the string '..'. - type: string - required: - - key - - path - type: object - type: array - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - optional: - description: Specify whether the Secret or its key must be defined - type: boolean - type: object - serviceAccountToken: - description: information about the serviceAccountToken data to project - properties: - audience: - description: Audience is the intended audience of the token. A recipient of a token must identify itself with an identifier specified in the audience of the token, and otherwise should reject the token. The audience defaults to the identifier of the apiserver. - type: string - expirationSeconds: - description: ExpirationSeconds is the requested duration of validity of the service account token. As the token approaches expiration, the kubelet volume plugin will proactively rotate the service account token. The kubelet will start trying to rotate the token if the token is older than 80 percent of its time to live or if the token is older than 24 hours.Defaults to 1 hour and must be at least 10 minutes. - format: int64 - type: integer - path: - description: Path is the path relative to the mount point of the file to project the token into. - type: string - required: - - path - type: object - type: object - type: array - type: object - quobyte: - description: Quobyte represents a Quobyte mount on the host that shares a pod's lifetime - properties: - group: - description: Group to map volume access to Default is no group - type: string - readOnly: - description: ReadOnly here will force the Quobyte volume to be mounted with read-only permissions. Defaults to false. - type: boolean - registry: - description: Registry represents a single or multiple Quobyte Registry services specified as a string as host:port pair (multiple entries are separated with commas) which acts as the central registry for volumes - type: string - tenant: - description: Tenant owning the given Quobyte volume in the Backend Used with dynamically provisioned Quobyte volumes, value is set by the plugin - type: string - user: - description: User to map volume access to Defaults to serivceaccount user - type: string - volume: - description: Volume is a string that references an already created Quobyte volume by name. - type: string - required: - - registry - - volume - type: object - rbd: - description: 'RBD represents a Rados Block Device mount on the host that shares a pod''s lifetime. More info: https://examples.k8s.io/volumes/rbd/README.md' - properties: - fsType: - description: 'Filesystem type of the volume that you want to mount. Tip: Ensure that the filesystem type is supported by the host operating system. Examples: "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified. More info: https://kubernetes.io/docs/concepts/storage/volumes#rbd TODO: how do we prevent errors in the filesystem from compromising the machine' - type: string - image: - description: 'The rados image name. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it' - type: string - keyring: - description: 'Keyring is the path to key ring for RBDUser. Default is /etc/ceph/keyring. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it' - type: string - monitors: - description: 'A collection of Ceph monitors. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it' - items: - type: string - type: array - pool: - description: 'The rados pool name. Default is rbd. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it' - type: string - readOnly: - description: 'ReadOnly here will force the ReadOnly setting in VolumeMounts. Defaults to false. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it' - type: boolean - secretRef: - description: 'SecretRef is name of the authentication secret for RBDUser. If provided overrides keyring. Default is nil. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it' - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - user: - description: 'The rados user name. Default is admin. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it' - type: string - required: - - image - - monitors - type: object - scaleIO: - description: ScaleIO represents a ScaleIO persistent volume attached and mounted on Kubernetes nodes. - properties: - fsType: - description: Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs", "ntfs". Default is "xfs". - type: string - gateway: - description: The host address of the ScaleIO API Gateway. - type: string - protectionDomain: - description: The name of the ScaleIO Protection Domain for the configured storage. - type: string - readOnly: - description: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts. - type: boolean - secretRef: - description: SecretRef references to the secret for ScaleIO user and other sensitive information. If this is not provided, Login operation will fail. - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - sslEnabled: - description: Flag to enable/disable SSL communication with Gateway, default false - type: boolean - storageMode: - description: Indicates whether the storage for a volume should be ThickProvisioned or ThinProvisioned. Default is ThinProvisioned. - type: string - storagePool: - description: The ScaleIO Storage Pool associated with the protection domain. - type: string - system: - description: The name of the storage system as configured in ScaleIO. - type: string - volumeName: - description: The name of a volume already created in the ScaleIO system that is associated with this volume source. - type: string - required: - - gateway - - secretRef - - system - type: object - secret: - description: 'Secret represents a secret that should populate this volume. More info: https://kubernetes.io/docs/concepts/storage/volumes#secret' - properties: - defaultMode: - description: 'Optional: mode bits used to set permissions on created files by default. Must be an octal value between 0000 and 0777 or a decimal value between 0 and 511. YAML accepts both octal and decimal values, JSON requires decimal values for mode bits. Defaults to 0644. Directories within the path are not affected by this setting. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.' - format: int32 - type: integer - items: - description: If unspecified, each key-value pair in the Data field of the referenced Secret will be projected into the volume as a file whose name is the key and content is the value. If specified, the listed keys will be projected into the specified paths, and unlisted keys will not be present. If a key is specified which is not present in the Secret, the volume setup will error unless it is marked optional. Paths must be relative and may not contain the '..' path or start with '..'. - items: - description: Maps a string key to a path within a volume. - properties: - key: - description: The key to project. - type: string - mode: - description: 'Optional: mode bits used to set permissions on this file. Must be an octal value between 0000 and 0777 or a decimal value between 0 and 511. YAML accepts both octal and decimal values, JSON requires decimal values for mode bits. If not specified, the volume defaultMode will be used. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.' - format: int32 - type: integer - path: - description: The relative path of the file to map the key to. May not be an absolute path. May not contain the path element '..'. May not start with the string '..'. - type: string - required: - - key - - path - type: object - type: array - optional: - description: Specify whether the Secret or its keys must be defined - type: boolean - secretName: - description: 'Name of the secret in the pod''s namespace to use. More info: https://kubernetes.io/docs/concepts/storage/volumes#secret' - type: string - type: object - storageos: - description: StorageOS represents a StorageOS volume attached and mounted on Kubernetes nodes. - properties: - fsType: - description: Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified. - type: string - readOnly: - description: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts. - type: boolean - secretRef: - description: SecretRef specifies the secret to use for obtaining the StorageOS API credentials. If not specified, default values will be attempted. - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - volumeName: - description: VolumeName is the human-readable name of the StorageOS volume. Volume names are only unique within a namespace. - type: string - volumeNamespace: - description: VolumeNamespace specifies the scope of the volume within StorageOS. If no namespace is specified then the Pod's namespace will be used. This allows the Kubernetes name scoping to be mirrored within StorageOS for tighter integration. Set VolumeName to any name to override the default behaviour. Set to "default" if you are not using namespaces within StorageOS. Namespaces that do not pre-exist within StorageOS will be created. - type: string - type: object - vsphereVolume: - description: VsphereVolume represents a vSphere volume attached and mounted on kubelets host machine - properties: - fsType: - description: Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified. - type: string - storagePolicyID: - description: Storage Policy Based Management (SPBM) profile ID associated with the StoragePolicyName. - type: string - storagePolicyName: - description: Storage Policy Based Management (SPBM) profile name. - type: string - volumePath: - description: Path that identifies vSphere volume vmdk - type: string - required: - - volumePath - type: object - required: - - name - type: object - type: array - x-kubernetes-list-type: atomic - type: object - status: - description: OpenTelemetryCollectorStatus defines the observed state of OpenTelemetryCollector. - properties: - messages: - description: 'Messages about actions performed by the operator on this resource. Deprecated: use Kubernetes events instead.' - items: - type: string - type: array - x-kubernetes-list-type: atomic - replicas: - description: 'Replicas is currently not being set and might be removed in the next version. Deprecated: use "OpenTelemetryCollector.Status.Scale.Replicas" instead.' - format: int32 - type: integer - scale: - description: Scale is the OpenTelemetryCollector's scale subresource status. - properties: - replicas: - description: The total number non-terminated pods targeted by this OpenTelemetryCollector's deployment or statefulSet. - format: int32 - type: integer - selector: - description: The selector used to match the OpenTelemetryCollector's deployment or statefulSet pods. - type: string - type: object - version: - description: Version of the managed OpenTelemetry Collector (operand) - type: string - type: object - type: object - served: true - storage: true - subresources: - scale: - labelSelectorPath: .status.scale.selector - specReplicasPath: .spec.replicas - statusReplicasPath: .status.scale.replicas - status: {} -status: - acceptedNames: - kind: "" - plural: "" - conditions: [] - storedVersions: [] ---- -apiVersion: v1 -kind: ServiceAccount -metadata: - labels: - app.kubernetes.io/name: opentelemetry-operator - name: opentelemetry-operator-controller-manager - namespace: opentelemetry-operator-system ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - labels: - app.kubernetes.io/name: opentelemetry-operator - name: opentelemetry-operator-leader-election-role - namespace: opentelemetry-operator-system -rules: -- apiGroups: - - "" - resources: - - configmaps - verbs: - - get - - list - - watch - - create - - update - - patch - - delete -- apiGroups: - - "" - resources: - - configmaps/status - verbs: - - get - - update - - patch -- apiGroups: - - "" - resources: - - events - verbs: - - create - - patch ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - creationTimestamp: null - labels: - app.kubernetes.io/name: opentelemetry-operator - name: opentelemetry-operator-manager-role -rules: -- apiGroups: - - "" - resources: - - configmaps - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - "" - resources: - - events - verbs: - - create - - patch -- apiGroups: - - "" - resources: - - namespaces - verbs: - - list - - watch -- apiGroups: - - "" - resources: - - serviceaccounts - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - "" - resources: - - services - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - apps - resources: - - daemonsets - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - apps - resources: - - deployments - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - apps - resources: - - replicasets - verbs: - - get - - list - - watch -- apiGroups: - - apps - resources: - - statefulsets - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - autoscaling - resources: - - horizontalpodautoscalers - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - coordination.k8s.io - resources: - - leases - verbs: - - create - - get - - list - - update -- apiGroups: - - opentelemetry.io - resources: - - instrumentations - verbs: - - get - - list - - patch - - update - - watch -- apiGroups: - - opentelemetry.io - resources: - - opentelemetrycollectors - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - opentelemetry.io - resources: - - opentelemetrycollectors/finalizers - verbs: - - get - - patch - - update -- apiGroups: - - opentelemetry.io - resources: - - opentelemetrycollectors/status - verbs: - - get - - patch - - update ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: opentelemetry-operator - name: opentelemetry-operator-metrics-reader -rules: -- nonResourceURLs: - - /metrics - verbs: - - get ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: opentelemetry-operator - name: opentelemetry-operator-proxy-role -rules: -- apiGroups: - - authentication.k8s.io - resources: - - tokenreviews - verbs: - - create -- apiGroups: - - authorization.k8s.io - resources: - - subjectaccessreviews - verbs: - - create ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - labels: - app.kubernetes.io/name: opentelemetry-operator - name: opentelemetry-operator-leader-election-rolebinding - namespace: opentelemetry-operator-system -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: opentelemetry-operator-leader-election-role -subjects: -- kind: ServiceAccount - name: opentelemetry-operator-controller-manager - namespace: opentelemetry-operator-system ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - labels: - app.kubernetes.io/name: opentelemetry-operator - name: opentelemetry-operator-manager-rolebinding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: opentelemetry-operator-manager-role -subjects: -- kind: ServiceAccount - name: opentelemetry-operator-controller-manager - namespace: opentelemetry-operator-system ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - labels: - app.kubernetes.io/name: opentelemetry-operator - name: opentelemetry-operator-proxy-rolebinding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: opentelemetry-operator-proxy-role -subjects: -- kind: ServiceAccount - name: opentelemetry-operator-controller-manager - namespace: opentelemetry-operator-system ---- -apiVersion: v1 -kind: Service -metadata: - labels: - app.kubernetes.io/name: opentelemetry-operator - control-plane: controller-manager - name: opentelemetry-operator-controller-manager-metrics-service - namespace: opentelemetry-operator-system -spec: - ports: - - name: https - port: 8443 - protocol: TCP - targetPort: https - selector: - app.kubernetes.io/name: opentelemetry-operator - control-plane: controller-manager ---- -apiVersion: v1 -kind: Service -metadata: - labels: - app.kubernetes.io/name: opentelemetry-operator - name: opentelemetry-operator-webhook-service - namespace: opentelemetry-operator-system -spec: - ports: - - port: 443 - protocol: TCP - targetPort: 9443 - selector: - app.kubernetes.io/name: opentelemetry-operator - control-plane: controller-manager ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - app.kubernetes.io/name: opentelemetry-operator - control-plane: controller-manager - name: opentelemetry-operator-controller-manager - namespace: opentelemetry-operator-system -spec: - replicas: 1 - selector: - matchLabels: - app.kubernetes.io/name: opentelemetry-operator - control-plane: controller-manager - template: - metadata: - labels: - app.kubernetes.io/name: opentelemetry-operator - control-plane: controller-manager - spec: - containers: - - args: - - --secure-listen-address=0.0.0.0:8443 - - --upstream=http://127.0.0.1:8080/ - - --logtostderr=true - - --v=0 - image: gcr.io/kubebuilder/kube-rbac-proxy:v0.11.0 - name: kube-rbac-proxy - ports: - - containerPort: 8443 - name: https - protocol: TCP - resources: - limits: - cpu: 500m - memory: 128Mi - requests: - cpu: 5m - memory: 64Mi - - args: - - --metrics-addr=127.0.0.1:8080 - - --enable-leader-election - image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.49.0 - livenessProbe: - httpGet: - path: /healthz - port: 8081 - initialDelaySeconds: 15 - periodSeconds: 20 - name: manager - ports: - - containerPort: 9443 - name: webhook-server - protocol: TCP - readinessProbe: - httpGet: - path: /readyz - port: 8081 - initialDelaySeconds: 5 - periodSeconds: 10 - resources: - limits: - cpu: 200m - memory: 256Mi - requests: - cpu: 100m - memory: 64Mi - volumeMounts: - - mountPath: /tmp/k8s-webhook-server/serving-certs - name: cert - readOnly: true - serviceAccountName: opentelemetry-operator-controller-manager - terminationGracePeriodSeconds: 10 - volumes: - - name: cert - secret: - defaultMode: 420 - secretName: opentelemetry-operator-controller-manager-service-cert ---- -apiVersion: cert-manager.io/v1 -kind: Certificate -metadata: - labels: - app.kubernetes.io/name: opentelemetry-operator - name: opentelemetry-operator-serving-cert - namespace: opentelemetry-operator-system -spec: - dnsNames: - - opentelemetry-operator-webhook-service.opentelemetry-operator-system.svc - - opentelemetry-operator-webhook-service.opentelemetry-operator-system.svc.cluster.local - issuerRef: - kind: Issuer - name: opentelemetry-operator-selfsigned-issuer - secretName: opentelemetry-operator-controller-manager-service-cert - subject: - organizationalUnits: - - opentelemetry-operator ---- -apiVersion: cert-manager.io/v1 -kind: Issuer -metadata: - labels: - app.kubernetes.io/name: opentelemetry-operator - name: opentelemetry-operator-selfsigned-issuer - namespace: opentelemetry-operator-system -spec: - selfSigned: {} ---- -apiVersion: admissionregistration.k8s.io/v1 -kind: MutatingWebhookConfiguration -metadata: - annotations: - cert-manager.io/inject-ca-from: opentelemetry-operator-system/opentelemetry-operator-serving-cert - labels: - app.kubernetes.io/name: opentelemetry-operator - name: opentelemetry-operator-mutating-webhook-configuration -webhooks: -- admissionReviewVersions: - - v1 - clientConfig: - service: - name: opentelemetry-operator-webhook-service - namespace: opentelemetry-operator-system - path: /mutate-opentelemetry-io-v1alpha1-instrumentation - failurePolicy: Fail - name: minstrumentation.kb.io - rules: - - apiGroups: - - opentelemetry.io - apiVersions: - - v1alpha1 - operations: - - CREATE - - UPDATE - resources: - - instrumentations - sideEffects: None -- admissionReviewVersions: - - v1 - clientConfig: - service: - name: opentelemetry-operator-webhook-service - namespace: opentelemetry-operator-system - path: /mutate-opentelemetry-io-v1alpha1-opentelemetrycollector - failurePolicy: Fail - name: mopentelemetrycollector.kb.io - rules: - - apiGroups: - - opentelemetry.io - apiVersions: - - v1alpha1 - operations: - - CREATE - - UPDATE - resources: - - opentelemetrycollectors - sideEffects: None -- admissionReviewVersions: - - v1 - clientConfig: - service: - name: opentelemetry-operator-webhook-service - namespace: opentelemetry-operator-system - path: /mutate-v1-pod - failurePolicy: Ignore - name: mpod.kb.io - rules: - - apiGroups: - - "" - apiVersions: - - v1 - operations: - - CREATE - - UPDATE - resources: - - pods - sideEffects: None ---- -apiVersion: admissionregistration.k8s.io/v1 -kind: ValidatingWebhookConfiguration -metadata: - annotations: - cert-manager.io/inject-ca-from: opentelemetry-operator-system/opentelemetry-operator-serving-cert - labels: - app.kubernetes.io/name: opentelemetry-operator - name: opentelemetry-operator-validating-webhook-configuration -webhooks: -- admissionReviewVersions: - - v1 - clientConfig: - service: - name: opentelemetry-operator-webhook-service - namespace: opentelemetry-operator-system - path: /validate-opentelemetry-io-v1alpha1-instrumentation - failurePolicy: Fail - name: vinstrumentationcreateupdate.kb.io - rules: - - apiGroups: - - opentelemetry.io - apiVersions: - - v1alpha1 - operations: - - CREATE - - UPDATE - resources: - - instrumentations - sideEffects: None -- admissionReviewVersions: - - v1 - clientConfig: - service: - name: opentelemetry-operator-webhook-service - namespace: opentelemetry-operator-system - path: /validate-opentelemetry-io-v1alpha1-instrumentation - failurePolicy: Ignore - name: vinstrumentationdelete.kb.io - rules: - - apiGroups: - - opentelemetry.io - apiVersions: - - v1alpha1 - operations: - - DELETE - resources: - - instrumentations - sideEffects: None -- admissionReviewVersions: - - v1 - clientConfig: - service: - name: opentelemetry-operator-webhook-service - namespace: opentelemetry-operator-system - path: /validate-opentelemetry-io-v1alpha1-opentelemetrycollector - failurePolicy: Fail - name: vopentelemetrycollectorcreateupdate.kb.io - rules: - - apiGroups: - - opentelemetry.io - apiVersions: - - v1alpha1 - operations: - - CREATE - - UPDATE - resources: - - opentelemetrycollectors - sideEffects: None -- admissionReviewVersions: - - v1 - clientConfig: - service: - name: opentelemetry-operator-webhook-service - namespace: opentelemetry-operator-system - path: /validate-opentelemetry-io-v1alpha1-opentelemetrycollector - failurePolicy: Ignore - name: vopentelemetrycollectordelete.kb.io - rules: - - apiGroups: - - opentelemetry.io - apiVersions: - - v1alpha1 - operations: - - DELETE - resources: - - opentelemetrycollectors - sideEffects: None diff --git a/tests/e2e-upgrade/upgrade-test/opentelemetry-operator-v0.86.0.yaml b/tests/e2e-upgrade/upgrade-test/opentelemetry-operator-v0.86.0.yaml new file mode 100644 index 0000000000..82463fa4b9 --- /dev/null +++ b/tests/e2e-upgrade/upgrade-test/opentelemetry-operator-v0.86.0.yaml @@ -0,0 +1,8558 @@ +apiVersion: v1 +kind: Namespace +metadata: + labels: + app.kubernetes.io/name: opentelemetry-operator + control-plane: controller-manager + name: opentelemetry-operator-system +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.12.0 + labels: + app.kubernetes.io/name: opentelemetry-operator + name: instrumentations.opentelemetry.io +spec: + group: opentelemetry.io + names: + kind: Instrumentation + listKind: InstrumentationList + plural: instrumentations + shortNames: + - otelinst + - otelinsts + singular: instrumentation + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + - jsonPath: .spec.exporter.endpoint + name: Endpoint + type: string + - jsonPath: .spec.sampler.type + name: Sampler + type: string + - jsonPath: .spec.sampler.argument + name: Sampler Arg + type: string + name: v1alpha1 + schema: + openAPIV3Schema: + description: Instrumentation is the spec for OpenTelemetry instrumentation. + properties: + apiVersion: + description: APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. + type: string + kind: + description: Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. + type: string + metadata: + type: object + spec: + description: InstrumentationSpec defines the desired state of OpenTelemetry + SDK and instrumentation. + properties: + apacheHttpd: + description: ApacheHttpd defines configuration for Apache HTTPD auto-instrumentation. + properties: + attrs: + description: 'Attrs defines Apache HTTPD agent specific attributes. + The precedence is: `agent default attributes` > `instrument + spec attributes` . Attributes are documented at https://github.' + items: + description: EnvVar represents an environment variable present + in a Container. + properties: + name: + description: Name of the environment variable. Must be a + C_IDENTIFIER. + type: string + value: + description: Variable references $(VAR_NAME) are expanded + using the previously defined environment variables in + the container and any service environment variables. + type: string + valueFrom: + description: Source for the environment variable's value. + Cannot be used if value is not empty. + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the ConfigMap or its + key must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + fieldRef: + description: 'Selects a field of the pod: supports metadata.name, + metadata.namespace, `metadata.labels['''']`, + `metadata.annotations['''']`, spec.nodeName, + spec.serviceAccountName, status.hostIP, status.' + properties: + apiVersion: + description: Version of the schema the FieldPath + is written in terms of, defaults to "v1". + type: string + fieldPath: + description: Path of the field to select in the + specified API version. + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + resourceFieldRef: + description: 'Selects a resource of the container: only + resources limits and requests (limits.cpu, limits.memory, + limits.ephemeral-storage, requests.cpu, requests.memory + and requests.' + properties: + containerName: + description: 'Container name: required for volumes, + optional for env vars' + type: string + divisor: + anyOf: + - type: integer + - type: string + description: Specifies the output format of the + exposed resources, defaults to "1" + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to select' + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + secretKeyRef: + description: Selects a key of a secret in the pod's + namespace + properties: + key: + description: The key of the secret to select from. Must + be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the Secret or its key + must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + type: object + required: + - name + type: object + type: array + configPath: + description: Location of Apache HTTPD server configuration. Needed + only if different from default "/usr/local/apache2/conf" + type: string + env: + description: Env defines Apache HTTPD specific env vars. + items: + description: EnvVar represents an environment variable present + in a Container. + properties: + name: + description: Name of the environment variable. Must be a + C_IDENTIFIER. + type: string + value: + description: Variable references $(VAR_NAME) are expanded + using the previously defined environment variables in + the container and any service environment variables. + type: string + valueFrom: + description: Source for the environment variable's value. + Cannot be used if value is not empty. + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the ConfigMap or its + key must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + fieldRef: + description: 'Selects a field of the pod: supports metadata.name, + metadata.namespace, `metadata.labels['''']`, + `metadata.annotations['''']`, spec.nodeName, + spec.serviceAccountName, status.hostIP, status.' + properties: + apiVersion: + description: Version of the schema the FieldPath + is written in terms of, defaults to "v1". + type: string + fieldPath: + description: Path of the field to select in the + specified API version. + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + resourceFieldRef: + description: 'Selects a resource of the container: only + resources limits and requests (limits.cpu, limits.memory, + limits.ephemeral-storage, requests.cpu, requests.memory + and requests.' + properties: + containerName: + description: 'Container name: required for volumes, + optional for env vars' + type: string + divisor: + anyOf: + - type: integer + - type: string + description: Specifies the output format of the + exposed resources, defaults to "1" + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to select' + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + secretKeyRef: + description: Selects a key of a secret in the pod's + namespace + properties: + key: + description: The key of the secret to select from. Must + be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the Secret or its key + must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + type: object + required: + - name + type: object + type: array + image: + description: Image is a container image with Apache SDK and auto-instrumentation. + type: string + resourceRequirements: + description: Resources describes the compute resource requirements. + properties: + claims: + description: "Claims lists the names of resources, defined + in spec.resourceClaims, that are used by this container. + \n This is an alpha field and requires enabling the DynamicResourceAllocation + feature gate." + items: + description: ResourceClaim references one entry in PodSpec.ResourceClaims. + properties: + name: + description: Name must match the name of one entry in + pod.spec.resourceClaims of the Pod where this field + is used. It makes that resource available inside a + container. + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Limits describes the maximum amount of compute + resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: Requests describes the minimum amount of compute + resources required. + type: object + type: object + version: + description: Apache HTTPD server version. One of 2.4 or 2.2. Default + is 2.4 + type: string + volumeLimitSize: + anyOf: + - type: integer + - type: string + description: VolumeSizeLimit defines size limit for volume used + for auto-instrumentation. The default size is 150Mi. + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + dotnet: + description: DotNet defines configuration for DotNet auto-instrumentation. + properties: + env: + description: Env defines DotNet specific env vars. + items: + description: EnvVar represents an environment variable present + in a Container. + properties: + name: + description: Name of the environment variable. Must be a + C_IDENTIFIER. + type: string + value: + description: Variable references $(VAR_NAME) are expanded + using the previously defined environment variables in + the container and any service environment variables. + type: string + valueFrom: + description: Source for the environment variable's value. + Cannot be used if value is not empty. + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the ConfigMap or its + key must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + fieldRef: + description: 'Selects a field of the pod: supports metadata.name, + metadata.namespace, `metadata.labels['''']`, + `metadata.annotations['''']`, spec.nodeName, + spec.serviceAccountName, status.hostIP, status.' + properties: + apiVersion: + description: Version of the schema the FieldPath + is written in terms of, defaults to "v1". + type: string + fieldPath: + description: Path of the field to select in the + specified API version. + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + resourceFieldRef: + description: 'Selects a resource of the container: only + resources limits and requests (limits.cpu, limits.memory, + limits.ephemeral-storage, requests.cpu, requests.memory + and requests.' + properties: + containerName: + description: 'Container name: required for volumes, + optional for env vars' + type: string + divisor: + anyOf: + - type: integer + - type: string + description: Specifies the output format of the + exposed resources, defaults to "1" + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to select' + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + secretKeyRef: + description: Selects a key of a secret in the pod's + namespace + properties: + key: + description: The key of the secret to select from. Must + be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the Secret or its key + must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + type: object + required: + - name + type: object + type: array + image: + description: Image is a container image with DotNet SDK and auto-instrumentation. + type: string + resourceRequirements: + description: Resources describes the compute resource requirements. + properties: + claims: + description: "Claims lists the names of resources, defined + in spec.resourceClaims, that are used by this container. + \n This is an alpha field and requires enabling the DynamicResourceAllocation + feature gate." + items: + description: ResourceClaim references one entry in PodSpec.ResourceClaims. + properties: + name: + description: Name must match the name of one entry in + pod.spec.resourceClaims of the Pod where this field + is used. It makes that resource available inside a + container. + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Limits describes the maximum amount of compute + resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: Requests describes the minimum amount of compute + resources required. + type: object + type: object + volumeLimitSize: + anyOf: + - type: integer + - type: string + description: VolumeSizeLimit defines size limit for volume used + for auto-instrumentation. The default size is 150Mi. + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + env: + description: Env defines common env vars. + items: + description: EnvVar represents an environment variable present in + a Container. + properties: + name: + description: Name of the environment variable. Must be a C_IDENTIFIER. + type: string + value: + description: Variable references $(VAR_NAME) are expanded using + the previously defined environment variables in the container + and any service environment variables. + type: string + valueFrom: + description: Source for the environment variable's value. Cannot + be used if value is not empty. + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + optional: + description: Specify whether the ConfigMap or its key + must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + fieldRef: + description: 'Selects a field of the pod: supports metadata.name, + metadata.namespace, `metadata.labels['''']`, `metadata.annotations['''']`, + spec.nodeName, spec.serviceAccountName, status.hostIP, + status.' + properties: + apiVersion: + description: Version of the schema the FieldPath is + written in terms of, defaults to "v1". + type: string + fieldPath: + description: Path of the field to select in the specified + API version. + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + resourceFieldRef: + description: 'Selects a resource of the container: only + resources limits and requests (limits.cpu, limits.memory, + limits.ephemeral-storage, requests.cpu, requests.memory + and requests.' + properties: + containerName: + description: 'Container name: required for volumes, + optional for env vars' + type: string + divisor: + anyOf: + - type: integer + - type: string + description: Specifies the output format of the exposed + resources, defaults to "1" + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to select' + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + secretKeyRef: + description: Selects a key of a secret in the pod's namespace + properties: + key: + description: The key of the secret to select from. Must + be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + optional: + description: Specify whether the Secret or its key must + be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + type: object + required: + - name + type: object + type: array + exporter: + description: Exporter defines exporter configuration. + properties: + endpoint: + description: Endpoint is address of the collector with OTLP endpoint. + type: string + type: object + go: + description: Go defines configuration for Go auto-instrumentation. + properties: + env: + description: Env defines Go specific env vars. + items: + description: EnvVar represents an environment variable present + in a Container. + properties: + name: + description: Name of the environment variable. Must be a + C_IDENTIFIER. + type: string + value: + description: Variable references $(VAR_NAME) are expanded + using the previously defined environment variables in + the container and any service environment variables. + type: string + valueFrom: + description: Source for the environment variable's value. + Cannot be used if value is not empty. + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the ConfigMap or its + key must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + fieldRef: + description: 'Selects a field of the pod: supports metadata.name, + metadata.namespace, `metadata.labels['''']`, + `metadata.annotations['''']`, spec.nodeName, + spec.serviceAccountName, status.hostIP, status.' + properties: + apiVersion: + description: Version of the schema the FieldPath + is written in terms of, defaults to "v1". + type: string + fieldPath: + description: Path of the field to select in the + specified API version. + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + resourceFieldRef: + description: 'Selects a resource of the container: only + resources limits and requests (limits.cpu, limits.memory, + limits.ephemeral-storage, requests.cpu, requests.memory + and requests.' + properties: + containerName: + description: 'Container name: required for volumes, + optional for env vars' + type: string + divisor: + anyOf: + - type: integer + - type: string + description: Specifies the output format of the + exposed resources, defaults to "1" + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to select' + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + secretKeyRef: + description: Selects a key of a secret in the pod's + namespace + properties: + key: + description: The key of the secret to select from. Must + be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the Secret or its key + must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + type: object + required: + - name + type: object + type: array + image: + description: Image is a container image with Go SDK and auto-instrumentation. + type: string + resourceRequirements: + description: Resources describes the compute resource requirements. + properties: + claims: + description: "Claims lists the names of resources, defined + in spec.resourceClaims, that are used by this container. + \n This is an alpha field and requires enabling the DynamicResourceAllocation + feature gate." + items: + description: ResourceClaim references one entry in PodSpec.ResourceClaims. + properties: + name: + description: Name must match the name of one entry in + pod.spec.resourceClaims of the Pod where this field + is used. It makes that resource available inside a + container. + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Limits describes the maximum amount of compute + resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: Requests describes the minimum amount of compute + resources required. + type: object + type: object + volumeLimitSize: + anyOf: + - type: integer + - type: string + description: VolumeSizeLimit defines size limit for volume used + for auto-instrumentation. The default size is 150Mi. + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + java: + description: Java defines configuration for java auto-instrumentation. + properties: + env: + description: Env defines java specific env vars. + items: + description: EnvVar represents an environment variable present + in a Container. + properties: + name: + description: Name of the environment variable. Must be a + C_IDENTIFIER. + type: string + value: + description: Variable references $(VAR_NAME) are expanded + using the previously defined environment variables in + the container and any service environment variables. + type: string + valueFrom: + description: Source for the environment variable's value. + Cannot be used if value is not empty. + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the ConfigMap or its + key must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + fieldRef: + description: 'Selects a field of the pod: supports metadata.name, + metadata.namespace, `metadata.labels['''']`, + `metadata.annotations['''']`, spec.nodeName, + spec.serviceAccountName, status.hostIP, status.' + properties: + apiVersion: + description: Version of the schema the FieldPath + is written in terms of, defaults to "v1". + type: string + fieldPath: + description: Path of the field to select in the + specified API version. + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + resourceFieldRef: + description: 'Selects a resource of the container: only + resources limits and requests (limits.cpu, limits.memory, + limits.ephemeral-storage, requests.cpu, requests.memory + and requests.' + properties: + containerName: + description: 'Container name: required for volumes, + optional for env vars' + type: string + divisor: + anyOf: + - type: integer + - type: string + description: Specifies the output format of the + exposed resources, defaults to "1" + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to select' + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + secretKeyRef: + description: Selects a key of a secret in the pod's + namespace + properties: + key: + description: The key of the secret to select from. Must + be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the Secret or its key + must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + type: object + required: + - name + type: object + type: array + image: + description: Image is a container image with javaagent auto-instrumentation + JAR. + type: string + resources: + description: Resources describes the compute resource requirements. + properties: + claims: + description: "Claims lists the names of resources, defined + in spec.resourceClaims, that are used by this container. + \n This is an alpha field and requires enabling the DynamicResourceAllocation + feature gate." + items: + description: ResourceClaim references one entry in PodSpec.ResourceClaims. + properties: + name: + description: Name must match the name of one entry in + pod.spec.resourceClaims of the Pod where this field + is used. It makes that resource available inside a + container. + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Limits describes the maximum amount of compute + resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: Requests describes the minimum amount of compute + resources required. + type: object + type: object + volumeLimitSize: + anyOf: + - type: integer + - type: string + description: VolumeSizeLimit defines size limit for volume used + for auto-instrumentation. The default size is 150Mi. + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + nginx: + description: Nginx defines configuration for Nginx auto-instrumentation. + properties: + attrs: + description: 'Attrs defines Nginx agent specific attributes. The + precedence order is: `agent default attributes` > `instrument + spec attributes` . Attributes are documented at https://github.' + items: + description: EnvVar represents an environment variable present + in a Container. + properties: + name: + description: Name of the environment variable. Must be a + C_IDENTIFIER. + type: string + value: + description: Variable references $(VAR_NAME) are expanded + using the previously defined environment variables in + the container and any service environment variables. + type: string + valueFrom: + description: Source for the environment variable's value. + Cannot be used if value is not empty. + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the ConfigMap or its + key must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + fieldRef: + description: 'Selects a field of the pod: supports metadata.name, + metadata.namespace, `metadata.labels['''']`, + `metadata.annotations['''']`, spec.nodeName, + spec.serviceAccountName, status.hostIP, status.' + properties: + apiVersion: + description: Version of the schema the FieldPath + is written in terms of, defaults to "v1". + type: string + fieldPath: + description: Path of the field to select in the + specified API version. + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + resourceFieldRef: + description: 'Selects a resource of the container: only + resources limits and requests (limits.cpu, limits.memory, + limits.ephemeral-storage, requests.cpu, requests.memory + and requests.' + properties: + containerName: + description: 'Container name: required for volumes, + optional for env vars' + type: string + divisor: + anyOf: + - type: integer + - type: string + description: Specifies the output format of the + exposed resources, defaults to "1" + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to select' + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + secretKeyRef: + description: Selects a key of a secret in the pod's + namespace + properties: + key: + description: The key of the secret to select from. Must + be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the Secret or its key + must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + type: object + required: + - name + type: object + type: array + configFile: + description: Location of Nginx configuration file. Needed only + if different from default "/etx/nginx/nginx.conf" + type: string + env: + description: Env defines Nginx specific env vars. + items: + description: EnvVar represents an environment variable present + in a Container. + properties: + name: + description: Name of the environment variable. Must be a + C_IDENTIFIER. + type: string + value: + description: Variable references $(VAR_NAME) are expanded + using the previously defined environment variables in + the container and any service environment variables. + type: string + valueFrom: + description: Source for the environment variable's value. + Cannot be used if value is not empty. + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the ConfigMap or its + key must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + fieldRef: + description: 'Selects a field of the pod: supports metadata.name, + metadata.namespace, `metadata.labels['''']`, + `metadata.annotations['''']`, spec.nodeName, + spec.serviceAccountName, status.hostIP, status.' + properties: + apiVersion: + description: Version of the schema the FieldPath + is written in terms of, defaults to "v1". + type: string + fieldPath: + description: Path of the field to select in the + specified API version. + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + resourceFieldRef: + description: 'Selects a resource of the container: only + resources limits and requests (limits.cpu, limits.memory, + limits.ephemeral-storage, requests.cpu, requests.memory + and requests.' + properties: + containerName: + description: 'Container name: required for volumes, + optional for env vars' + type: string + divisor: + anyOf: + - type: integer + - type: string + description: Specifies the output format of the + exposed resources, defaults to "1" + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to select' + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + secretKeyRef: + description: Selects a key of a secret in the pod's + namespace + properties: + key: + description: The key of the secret to select from. Must + be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the Secret or its key + must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + type: object + required: + - name + type: object + type: array + image: + description: Image is a container image with Nginx SDK and auto-instrumentation. + type: string + resourceRequirements: + description: Resources describes the compute resource requirements. + properties: + claims: + description: "Claims lists the names of resources, defined + in spec.resourceClaims, that are used by this container. + \n This is an alpha field and requires enabling the DynamicResourceAllocation + feature gate." + items: + description: ResourceClaim references one entry in PodSpec.ResourceClaims. + properties: + name: + description: Name must match the name of one entry in + pod.spec.resourceClaims of the Pod where this field + is used. It makes that resource available inside a + container. + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Limits describes the maximum amount of compute + resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: Requests describes the minimum amount of compute + resources required. + type: object + type: object + volumeLimitSize: + anyOf: + - type: integer + - type: string + description: VolumeSizeLimit defines size limit for volume used + for auto-instrumentation. The default size is 150Mi. + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + nodejs: + description: NodeJS defines configuration for nodejs auto-instrumentation. + properties: + env: + description: Env defines nodejs specific env vars. + items: + description: EnvVar represents an environment variable present + in a Container. + properties: + name: + description: Name of the environment variable. Must be a + C_IDENTIFIER. + type: string + value: + description: Variable references $(VAR_NAME) are expanded + using the previously defined environment variables in + the container and any service environment variables. + type: string + valueFrom: + description: Source for the environment variable's value. + Cannot be used if value is not empty. + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the ConfigMap or its + key must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + fieldRef: + description: 'Selects a field of the pod: supports metadata.name, + metadata.namespace, `metadata.labels['''']`, + `metadata.annotations['''']`, spec.nodeName, + spec.serviceAccountName, status.hostIP, status.' + properties: + apiVersion: + description: Version of the schema the FieldPath + is written in terms of, defaults to "v1". + type: string + fieldPath: + description: Path of the field to select in the + specified API version. + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + resourceFieldRef: + description: 'Selects a resource of the container: only + resources limits and requests (limits.cpu, limits.memory, + limits.ephemeral-storage, requests.cpu, requests.memory + and requests.' + properties: + containerName: + description: 'Container name: required for volumes, + optional for env vars' + type: string + divisor: + anyOf: + - type: integer + - type: string + description: Specifies the output format of the + exposed resources, defaults to "1" + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to select' + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + secretKeyRef: + description: Selects a key of a secret in the pod's + namespace + properties: + key: + description: The key of the secret to select from. Must + be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the Secret or its key + must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + type: object + required: + - name + type: object + type: array + image: + description: Image is a container image with NodeJS SDK and auto-instrumentation. + type: string + resourceRequirements: + description: Resources describes the compute resource requirements. + properties: + claims: + description: "Claims lists the names of resources, defined + in spec.resourceClaims, that are used by this container. + \n This is an alpha field and requires enabling the DynamicResourceAllocation + feature gate." + items: + description: ResourceClaim references one entry in PodSpec.ResourceClaims. + properties: + name: + description: Name must match the name of one entry in + pod.spec.resourceClaims of the Pod where this field + is used. It makes that resource available inside a + container. + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Limits describes the maximum amount of compute + resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: Requests describes the minimum amount of compute + resources required. + type: object + type: object + volumeLimitSize: + anyOf: + - type: integer + - type: string + description: VolumeSizeLimit defines size limit for volume used + for auto-instrumentation. The default size is 150Mi. + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + propagators: + description: Propagators defines inter-process context propagation + configuration. Values in this list will be set in the OTEL_PROPAGATORS + env var. Enum=tracecontext;baggage;b3;b3multi;jaeger;xray;ottrace;none + items: + description: Propagator represents the propagation type. + enum: + - tracecontext + - baggage + - b3 + - b3multi + - jaeger + - xray + - ottrace + - none + type: string + type: array + python: + description: Python defines configuration for python auto-instrumentation. + properties: + env: + description: Env defines python specific env vars. + items: + description: EnvVar represents an environment variable present + in a Container. + properties: + name: + description: Name of the environment variable. Must be a + C_IDENTIFIER. + type: string + value: + description: Variable references $(VAR_NAME) are expanded + using the previously defined environment variables in + the container and any service environment variables. + type: string + valueFrom: + description: Source for the environment variable's value. + Cannot be used if value is not empty. + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the ConfigMap or its + key must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + fieldRef: + description: 'Selects a field of the pod: supports metadata.name, + metadata.namespace, `metadata.labels['''']`, + `metadata.annotations['''']`, spec.nodeName, + spec.serviceAccountName, status.hostIP, status.' + properties: + apiVersion: + description: Version of the schema the FieldPath + is written in terms of, defaults to "v1". + type: string + fieldPath: + description: Path of the field to select in the + specified API version. + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + resourceFieldRef: + description: 'Selects a resource of the container: only + resources limits and requests (limits.cpu, limits.memory, + limits.ephemeral-storage, requests.cpu, requests.memory + and requests.' + properties: + containerName: + description: 'Container name: required for volumes, + optional for env vars' + type: string + divisor: + anyOf: + - type: integer + - type: string + description: Specifies the output format of the + exposed resources, defaults to "1" + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to select' + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + secretKeyRef: + description: Selects a key of a secret in the pod's + namespace + properties: + key: + description: The key of the secret to select from. Must + be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the Secret or its key + must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + type: object + required: + - name + type: object + type: array + image: + description: Image is a container image with Python SDK and auto-instrumentation. + type: string + resourceRequirements: + description: Resources describes the compute resource requirements. + properties: + claims: + description: "Claims lists the names of resources, defined + in spec.resourceClaims, that are used by this container. + \n This is an alpha field and requires enabling the DynamicResourceAllocation + feature gate." + items: + description: ResourceClaim references one entry in PodSpec.ResourceClaims. + properties: + name: + description: Name must match the name of one entry in + pod.spec.resourceClaims of the Pod where this field + is used. It makes that resource available inside a + container. + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Limits describes the maximum amount of compute + resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: Requests describes the minimum amount of compute + resources required. + type: object + type: object + volumeLimitSize: + anyOf: + - type: integer + - type: string + description: VolumeSizeLimit defines size limit for volume used + for auto-instrumentation. The default size is 150Mi. + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + resource: + description: Resource defines the configuration for the resource attributes, + as defined by the OpenTelemetry specification. + properties: + addK8sUIDAttributes: + description: AddK8sUIDAttributes defines whether K8s UID attributes + should be collected (e.g. k8s.deployment.uid). + type: boolean + resourceAttributes: + additionalProperties: + type: string + description: 'Attributes defines attributes that are added to + the resource. For example environment: dev' + type: object + type: object + sampler: + description: Sampler defines sampling configuration. + properties: + argument: + description: Argument defines sampler argument. The value depends + on the sampler type. For instance for parentbased_traceidratio + sampler type it is a number in range [0..1] e.g. 0.25. + type: string + type: + description: Type defines sampler type. The value will be set + in the OTEL_TRACES_SAMPLER env var. The value can be for instance + parentbased_always_on, parentbased_always_off, parentbased_traceidratio... + enum: + - always_on + - always_off + - traceidratio + - parentbased_always_on + - parentbased_always_off + - parentbased_traceidratio + - jaeger_remote + - xray + type: string + type: object + type: object + status: + description: InstrumentationStatus defines status of the instrumentation. + type: object + type: object + served: true + storage: true + subresources: + status: {} +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + cert-manager.io/inject-ca-from: opentelemetry-operator-system/opentelemetry-operator-serving-cert + controller-gen.kubebuilder.io/version: v0.12.0 + labels: + app.kubernetes.io/name: opentelemetry-operator + name: opentelemetrycollectors.opentelemetry.io +spec: + group: opentelemetry.io + names: + kind: OpenTelemetryCollector + listKind: OpenTelemetryCollectorList + plural: opentelemetrycollectors + shortNames: + - otelcol + - otelcols + singular: opentelemetrycollector + scope: Namespaced + versions: + - additionalPrinterColumns: + - description: Deployment Mode + jsonPath: .spec.mode + name: Mode + type: string + - description: OpenTelemetry Version + jsonPath: .status.version + name: Version + type: string + - jsonPath: .status.scale.statusReplicas + name: Ready + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + - jsonPath: .status.image + name: Image + type: string + - description: Management State + jsonPath: .spec.managementState + name: Management + type: string + name: v1alpha1 + schema: + openAPIV3Schema: + description: OpenTelemetryCollector is the Schema for the opentelemetrycollectors + API. + properties: + apiVersion: + description: APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. + type: string + kind: + description: Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. + type: string + metadata: + type: object + spec: + description: OpenTelemetryCollectorSpec defines the desired state of OpenTelemetryCollector. + properties: + additionalContainers: + description: AdditionalContainers allows injecting additional containers + into the Collector's pod definition. + items: + description: A single application container that you want to run + within a pod. + properties: + args: + description: Arguments to the entrypoint. The container image's + CMD is used if this is not provided. Variable references $(VAR_NAME) + are expanded using the container's environment. + items: + type: string + type: array + command: + description: Entrypoint array. Not executed within a shell. + The container image's ENTRYPOINT is used if this is not provided. + Variable references $(VAR_NAME) are expanded using the container's + environment. + items: + type: string + type: array + env: + description: List of environment variables to set in the container. + Cannot be updated. + items: + description: EnvVar represents an environment variable present + in a Container. + properties: + name: + description: Name of the environment variable. Must be + a C_IDENTIFIER. + type: string + value: + description: Variable references $(VAR_NAME) are expanded + using the previously defined environment variables in + the container and any service environment variables. + type: string + valueFrom: + description: Source for the environment variable's value. + Cannot be used if value is not empty. + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: + https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the ConfigMap or + its key must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + fieldRef: + description: 'Selects a field of the pod: supports + metadata.name, metadata.namespace, `metadata.labels['''']`, + `metadata.annotations['''']`, spec.nodeName, + spec.serviceAccountName, status.hostIP, status.' + properties: + apiVersion: + description: Version of the schema the FieldPath + is written in terms of, defaults to "v1". + type: string + fieldPath: + description: Path of the field to select in the + specified API version. + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + resourceFieldRef: + description: 'Selects a resource of the container: + only resources limits and requests (limits.cpu, + limits.memory, limits.ephemeral-storage, requests.cpu, + requests.memory and requests.' + properties: + containerName: + description: 'Container name: required for volumes, + optional for env vars' + type: string + divisor: + anyOf: + - type: integer + - type: string + description: Specifies the output format of the + exposed resources, defaults to "1" + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to select' + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + secretKeyRef: + description: Selects a key of a secret in the pod's + namespace + properties: + key: + description: The key of the secret to select from. Must + be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: + https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the Secret or its + key must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + type: object + required: + - name + type: object + type: array + envFrom: + description: List of sources to populate environment variables + in the container. The keys defined within a source must be + a C_IDENTIFIER. + items: + description: EnvFromSource represents the source of a set + of ConfigMaps + properties: + configMapRef: + description: The ConfigMap to select from + properties: + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the ConfigMap must be + defined + type: boolean + type: object + x-kubernetes-map-type: atomic + prefix: + description: An optional identifier to prepend to each + key in the ConfigMap. Must be a C_IDENTIFIER. + type: string + secretRef: + description: The Secret to select from + properties: + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the Secret must be defined + type: boolean + type: object + x-kubernetes-map-type: atomic + type: object + type: array + image: + description: 'Container image name. More info: https://kubernetes.' + type: string + imagePullPolicy: + description: 'Image pull policy. One of Always, Never, IfNotPresent. + Defaults to Always if :latest tag is specified, or IfNotPresent + otherwise. Cannot be updated. More info: https://kubernetes.' + type: string + lifecycle: + description: Actions that the management system should take + in response to container lifecycle events. Cannot be updated. + properties: + postStart: + description: PostStart is called immediately after a container + is created. If the handler fails, the container is terminated + and restarted according to its restart policy. + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: Command is the command line to execute + inside the container, the working directory for + the command is root ('/') in the container's + filesystem. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: Host name to connect to, defaults to + the pod IP. You probably want to set "Host" in + httpHeaders instead. + type: string + httpHeaders: + description: Custom headers to set in the request. + HTTP allows repeated headers. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name. This will + be canonicalized upon output, so case-variant + names will be understood as the same header. + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: Name or number of the port to access + on the container. Number must be in the range + 1 to 65535. Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the + host. Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: Deprecated. TCPSocket is NOT supported + as a LifecycleHandler and kept for the backward compatibility. + properties: + host: + description: 'Optional: Host name to connect to, + defaults to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: Number or name of the port to access + on the container. Number must be in the range + 1 to 65535. Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + preStop: + description: PreStop is called immediately before a container + is terminated due to an API request or management event + such as liveness/startup probe failure, preemption, resource + contention, etc. + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: Command is the command line to execute + inside the container, the working directory for + the command is root ('/') in the container's + filesystem. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: Host name to connect to, defaults to + the pod IP. You probably want to set "Host" in + httpHeaders instead. + type: string + httpHeaders: + description: Custom headers to set in the request. + HTTP allows repeated headers. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name. This will + be canonicalized upon output, so case-variant + names will be understood as the same header. + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: Name or number of the port to access + on the container. Number must be in the range + 1 to 65535. Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the + host. Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: Deprecated. TCPSocket is NOT supported + as a LifecycleHandler and kept for the backward compatibility. + properties: + host: + description: 'Optional: Host name to connect to, + defaults to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: Number or name of the port to access + on the container. Number must be in the range + 1 to 65535. Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + type: object + livenessProbe: + description: 'Periodic probe of container liveness. Container + will be restarted if the probe fails. Cannot be updated. More + info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: Command is the command line to execute + inside the container, the working directory for the + command is root ('/') in the container's filesystem. + items: + type: string + type: array + type: object + failureThreshold: + description: Minimum consecutive failures for the probe + to be considered failed after having succeeded. Defaults + to 3. Minimum value is 1. + format: int32 + type: integer + grpc: + description: GRPC specifies an action involving a GRPC port. + properties: + port: + description: Port number of the gRPC service. Number + must be in the range 1 to 65535. + format: int32 + type: integer + service: + description: Service is the name of the service to place + in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). + type: string + required: + - port + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: Host name to connect to, defaults to the + pod IP. You probably want to set "Host" in httpHeaders + instead. + type: string + httpHeaders: + description: Custom headers to set in the request. HTTP + allows repeated headers. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name. This will + be canonicalized upon output, so case-variant + names will be understood as the same header. + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: Name or number of the port to access on + the container. Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + initialDelaySeconds: + description: 'Number of seconds after the container has + started before liveness probes are initiated. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + periodSeconds: + description: How often (in seconds) to perform the probe. + Default to 10 seconds. Minimum value is 1. + format: int32 + type: integer + successThreshold: + description: Minimum consecutive successes for the probe + to be considered successful after having failed. Defaults + to 1. Must be 1 for liveness and startup. Minimum value + is 1. + format: int32 + type: integer + tcpSocket: + description: TCPSocket specifies an action involving a TCP + port. + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: Number or name of the port to access on + the container. Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + description: Optional duration in seconds the pod needs + to terminate gracefully upon probe failure. + format: int64 + type: integer + timeoutSeconds: + description: 'Number of seconds after which the probe times + out. Defaults to 1 second. Minimum value is 1. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + type: object + name: + description: Name of the container specified as a DNS_LABEL. + Each container in a pod must have a unique name (DNS_LABEL). + Cannot be updated. + type: string + ports: + description: List of ports to expose from the container. Not + specifying a port here DOES NOT prevent that port from being + exposed. Any port which is listening on the default "0.0.0. + items: + description: ContainerPort represents a network port in a + single container. + properties: + containerPort: + description: Number of port to expose on the pod's IP + address. This must be a valid port number, 0 < x < 65536. + format: int32 + type: integer + hostIP: + description: What host IP to bind the external port to. + type: string + hostPort: + description: Number of port to expose on the host. If + specified, this must be a valid port number, 0 < x < + 65536. If HostNetwork is specified, this must match + ContainerPort. Most containers do not need this. + format: int32 + type: integer + name: + description: If specified, this must be an IANA_SVC_NAME + and unique within the pod. Each named port in a pod + must have a unique name. Name for the port that can + be referred to by services. + type: string + protocol: + default: TCP + description: Protocol for port. Must be UDP, TCP, or SCTP. + Defaults to "TCP". + type: string + required: + - containerPort + type: object + type: array + x-kubernetes-list-map-keys: + - containerPort + - protocol + x-kubernetes-list-type: map + readinessProbe: + description: 'Periodic probe of container service readiness. + Container will be removed from service endpoints if the probe + fails. Cannot be updated. More info: https://kubernetes.' + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: Command is the command line to execute + inside the container, the working directory for the + command is root ('/') in the container's filesystem. + items: + type: string + type: array + type: object + failureThreshold: + description: Minimum consecutive failures for the probe + to be considered failed after having succeeded. Defaults + to 3. Minimum value is 1. + format: int32 + type: integer + grpc: + description: GRPC specifies an action involving a GRPC port. + properties: + port: + description: Port number of the gRPC service. Number + must be in the range 1 to 65535. + format: int32 + type: integer + service: + description: Service is the name of the service to place + in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). + type: string + required: + - port + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: Host name to connect to, defaults to the + pod IP. You probably want to set "Host" in httpHeaders + instead. + type: string + httpHeaders: + description: Custom headers to set in the request. HTTP + allows repeated headers. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name. This will + be canonicalized upon output, so case-variant + names will be understood as the same header. + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: Name or number of the port to access on + the container. Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + initialDelaySeconds: + description: 'Number of seconds after the container has + started before liveness probes are initiated. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + periodSeconds: + description: How often (in seconds) to perform the probe. + Default to 10 seconds. Minimum value is 1. + format: int32 + type: integer + successThreshold: + description: Minimum consecutive successes for the probe + to be considered successful after having failed. Defaults + to 1. Must be 1 for liveness and startup. Minimum value + is 1. + format: int32 + type: integer + tcpSocket: + description: TCPSocket specifies an action involving a TCP + port. + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: Number or name of the port to access on + the container. Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + description: Optional duration in seconds the pod needs + to terminate gracefully upon probe failure. + format: int64 + type: integer + timeoutSeconds: + description: 'Number of seconds after which the probe times + out. Defaults to 1 second. Minimum value is 1. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + type: object + resizePolicy: + description: Resources resize policy for the container. + items: + description: ContainerResizePolicy represents resource resize + policy for the container. + properties: + resourceName: + description: 'Name of the resource to which this resource + resize policy applies. Supported values: cpu, memory.' + type: string + restartPolicy: + description: Restart policy to apply when specified resource + is resized. If not specified, it defaults to NotRequired. + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic + resources: + description: 'Compute Resources required by this container. + Cannot be updated. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + properties: + claims: + description: "Claims lists the names of resources, defined + in spec.resourceClaims, that are used by this container. + \n This is an alpha field and requires enabling the DynamicResourceAllocation + feature gate." + items: + description: ResourceClaim references one entry in PodSpec.ResourceClaims. + properties: + name: + description: Name must match the name of one entry + in pod.spec.resourceClaims of the Pod where this + field is used. It makes that resource available + inside a container. + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Limits describes the maximum amount of compute + resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: Requests describes the minimum amount of compute + resources required. + type: object + type: object + restartPolicy: + description: RestartPolicy defines the restart behavior of individual + containers in a pod. This field may only be set for init containers, + and the only allowed value is "Always". + type: string + securityContext: + description: SecurityContext defines the security options the + container should be run with. If set, the fields of SecurityContext + override the equivalent fields of PodSecurityContext. + properties: + allowPrivilegeEscalation: + description: AllowPrivilegeEscalation controls whether a + process can gain more privileges than its parent process. + This bool directly controls if the no_new_privs flag will + be set on the container process. + type: boolean + capabilities: + description: The capabilities to add/drop when running containers. + Defaults to the default set of capabilities granted by + the container runtime. Note that this field cannot be + set when spec.os.name is windows. + properties: + add: + description: Added capabilities + items: + description: Capability represent POSIX capabilities + type + type: string + type: array + drop: + description: Removed capabilities + items: + description: Capability represent POSIX capabilities + type + type: string + type: array + type: object + privileged: + description: Run container in privileged mode. Processes + in privileged containers are essentially equivalent to + root on the host. Defaults to false. Note that this field + cannot be set when spec.os.name is windows. + type: boolean + procMount: + description: procMount denotes the type of proc mount to + use for the containers. The default is DefaultProcMount + which uses the container runtime defaults for readonly + paths and masked paths. + type: string + readOnlyRootFilesystem: + description: Whether this container has a read-only root + filesystem. Default is false. Note that this field cannot + be set when spec.os.name is windows. + type: boolean + runAsGroup: + description: The GID to run the entrypoint of the container + process. Uses runtime default if unset. May also be set + in PodSecurityContext. + format: int64 + type: integer + runAsNonRoot: + description: Indicates that the container must run as a + non-root user. + type: boolean + runAsUser: + description: The UID to run the entrypoint of the container + process. Defaults to user specified in image metadata + if unspecified. May also be set in PodSecurityContext. + format: int64 + type: integer + seLinuxOptions: + description: The SELinux context to be applied to the container. + If unspecified, the container runtime will allocate a + random SELinux context for each container. May also be + set in PodSecurityContext. + properties: + level: + description: Level is SELinux level label that applies + to the container. + type: string + role: + description: Role is a SELinux role label that applies + to the container. + type: string + type: + description: Type is a SELinux type label that applies + to the container. + type: string + user: + description: User is a SELinux user label that applies + to the container. + type: string + type: object + seccompProfile: + description: The seccomp options to use by this container. + If seccomp options are provided at both the pod & container + level, the container options override the pod options. + properties: + localhostProfile: + description: localhostProfile indicates a profile defined + in a file on the node should be used. The profile + must be preconfigured on the node to work. + type: string + type: + description: "type indicates which kind of seccomp profile + will be applied. Valid options are: \n Localhost - + a profile defined in a file on the node should be + used." + type: string + required: + - type + type: object + windowsOptions: + description: The Windows specific settings applied to all + containers. If unspecified, the options from the PodSecurityContext + will be used. + properties: + gmsaCredentialSpec: + description: GMSACredentialSpec is where the GMSA admission + webhook (https://github.com/kubernetes-sigs/windows-gmsa) + inlines the contents of the GMSA credential spec named + by the GMSACredentialSpecName field. + type: string + gmsaCredentialSpecName: + description: GMSACredentialSpecName is the name of the + GMSA credential spec to use. + type: string + hostProcess: + description: HostProcess determines if a container should + be run as a 'Host Process' container. + type: boolean + runAsUserName: + description: The UserName in Windows to run the entrypoint + of the container process. Defaults to the user specified + in image metadata if unspecified. May also be set + in PodSecurityContext. + type: string + type: object + type: object + startupProbe: + description: StartupProbe indicates that the Pod has successfully + initialized. If specified, no other probes are executed until + this completes successfully. + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: Command is the command line to execute + inside the container, the working directory for the + command is root ('/') in the container's filesystem. + items: + type: string + type: array + type: object + failureThreshold: + description: Minimum consecutive failures for the probe + to be considered failed after having succeeded. Defaults + to 3. Minimum value is 1. + format: int32 + type: integer + grpc: + description: GRPC specifies an action involving a GRPC port. + properties: + port: + description: Port number of the gRPC service. Number + must be in the range 1 to 65535. + format: int32 + type: integer + service: + description: Service is the name of the service to place + in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). + type: string + required: + - port + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: Host name to connect to, defaults to the + pod IP. You probably want to set "Host" in httpHeaders + instead. + type: string + httpHeaders: + description: Custom headers to set in the request. HTTP + allows repeated headers. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name. This will + be canonicalized upon output, so case-variant + names will be understood as the same header. + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: Name or number of the port to access on + the container. Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + initialDelaySeconds: + description: 'Number of seconds after the container has + started before liveness probes are initiated. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + periodSeconds: + description: How often (in seconds) to perform the probe. + Default to 10 seconds. Minimum value is 1. + format: int32 + type: integer + successThreshold: + description: Minimum consecutive successes for the probe + to be considered successful after having failed. Defaults + to 1. Must be 1 for liveness and startup. Minimum value + is 1. + format: int32 + type: integer + tcpSocket: + description: TCPSocket specifies an action involving a TCP + port. + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: Number or name of the port to access on + the container. Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + description: Optional duration in seconds the pod needs + to terminate gracefully upon probe failure. + format: int64 + type: integer + timeoutSeconds: + description: 'Number of seconds after which the probe times + out. Defaults to 1 second. Minimum value is 1. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + type: object + stdin: + description: Whether this container should allocate a buffer + for stdin in the container runtime. If this is not set, reads + from stdin in the container will always result in EOF. Default + is false. + type: boolean + stdinOnce: + description: Whether the container runtime should close the + stdin channel after it has been opened by a single attach. + When stdin is true the stdin stream will remain open across + multiple attach sessions. + type: boolean + terminationMessagePath: + description: 'Optional: Path at which the file to which the + container''s termination message will be written is mounted + into the container''s filesystem.' + type: string + terminationMessagePolicy: + description: Indicate how the termination message should be + populated. File will use the contents of terminationMessagePath + to populate the container status message on both success and + failure. + type: string + tty: + description: Whether this container should allocate a TTY for + itself, also requires 'stdin' to be true. Default is false. + type: boolean + volumeDevices: + description: volumeDevices is the list of block devices to be + used by the container. + items: + description: volumeDevice describes a mapping of a raw block + device within a container. + properties: + devicePath: + description: devicePath is the path inside of the container + that the device will be mapped to. + type: string + name: + description: name must match the name of a persistentVolumeClaim + in the pod + type: string + required: + - devicePath + - name + type: object + type: array + volumeMounts: + description: Pod volumes to mount into the container's filesystem. + Cannot be updated. + items: + description: VolumeMount describes a mounting of a Volume + within a container. + properties: + mountPath: + description: Path within the container at which the volume + should be mounted. Must not contain ':'. + type: string + mountPropagation: + description: mountPropagation determines how mounts are + propagated from the host to container and the other + way around. When not set, MountPropagationNone is used. + This field is beta in 1.10. + type: string + name: + description: This must match the Name of a Volume. + type: string + readOnly: + description: Mounted read-only if true, read-write otherwise + (false or unspecified). Defaults to false. + type: boolean + subPath: + description: Path within the volume from which the container's + volume should be mounted. Defaults to "" (volume's root). + type: string + subPathExpr: + description: Expanded path within the volume from which + the container's volume should be mounted. + type: string + required: + - mountPath + - name + type: object + type: array + workingDir: + description: Container's working directory. If not specified, + the container runtime's default will be used, which might + be configured in the container image. Cannot be updated. + type: string + required: + - name + type: object + type: array + affinity: + description: If specified, indicates the pod's scheduling constraints + properties: + nodeAffinity: + description: Describes node affinity scheduling rules for the + pod. + properties: + preferredDuringSchedulingIgnoredDuringExecution: + description: The scheduler will prefer to schedule pods to + nodes that satisfy the affinity expressions specified by + this field, but it may choose a node that violates one or + more of the expressions. + items: + description: An empty preferred scheduling term matches + all objects with implicit weight 0 (i.e. it's a no-op). + A null preferred scheduling term matches no objects (i.e. + is also a no-op). + properties: + preference: + description: A node selector term, associated with the + corresponding weight. + properties: + matchExpressions: + description: A list of node selector requirements + by node's labels. + items: + description: A node selector requirement is a + selector that contains values, a key, and an + operator that relates the key and values. + properties: + key: + description: The label key that the selector + applies to. + type: string + operator: + description: Represents a key's relationship + to a set of values. Valid operators are + In, NotIn, Exists, DoesNotExist. Gt, and + Lt. + type: string + values: + description: An array of string values. If + the operator is In or NotIn, the values + array must be non-empty. If the operator + is Exists or DoesNotExist, the values array + must be empty. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchFields: + description: A list of node selector requirements + by node's fields. + items: + description: A node selector requirement is a + selector that contains values, a key, and an + operator that relates the key and values. + properties: + key: + description: The label key that the selector + applies to. + type: string + operator: + description: Represents a key's relationship + to a set of values. Valid operators are + In, NotIn, Exists, DoesNotExist. Gt, and + Lt. + type: string + values: + description: An array of string values. If + the operator is In or NotIn, the values + array must be non-empty. If the operator + is Exists or DoesNotExist, the values array + must be empty. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + type: object + x-kubernetes-map-type: atomic + weight: + description: Weight associated with matching the corresponding + nodeSelectorTerm, in the range 1-100. + format: int32 + type: integer + required: + - preference + - weight + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + description: If the affinity requirements specified by this + field are not met at scheduling time, the pod will not be + scheduled onto the node. + properties: + nodeSelectorTerms: + description: Required. A list of node selector terms. + The terms are ORed. + items: + description: A null or empty node selector term matches + no objects. The requirements of them are ANDed. The + TopologySelectorTerm type implements a subset of the + NodeSelectorTerm. + properties: + matchExpressions: + description: A list of node selector requirements + by node's labels. + items: + description: A node selector requirement is a + selector that contains values, a key, and an + operator that relates the key and values. + properties: + key: + description: The label key that the selector + applies to. + type: string + operator: + description: Represents a key's relationship + to a set of values. Valid operators are + In, NotIn, Exists, DoesNotExist. Gt, and + Lt. + type: string + values: + description: An array of string values. If + the operator is In or NotIn, the values + array must be non-empty. If the operator + is Exists or DoesNotExist, the values array + must be empty. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchFields: + description: A list of node selector requirements + by node's fields. + items: + description: A node selector requirement is a + selector that contains values, a key, and an + operator that relates the key and values. + properties: + key: + description: The label key that the selector + applies to. + type: string + operator: + description: Represents a key's relationship + to a set of values. Valid operators are + In, NotIn, Exists, DoesNotExist. Gt, and + Lt. + type: string + values: + description: An array of string values. If + the operator is In or NotIn, the values + array must be non-empty. If the operator + is Exists or DoesNotExist, the values array + must be empty. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + type: object + x-kubernetes-map-type: atomic + type: array + required: + - nodeSelectorTerms + type: object + x-kubernetes-map-type: atomic + type: object + podAffinity: + description: Describes pod affinity scheduling rules (e.g. co-locate + this pod in the same node, zone, etc. as some other pod(s)). + properties: + preferredDuringSchedulingIgnoredDuringExecution: + description: The scheduler will prefer to schedule pods to + nodes that satisfy the affinity expressions specified by + this field, but it may choose a node that violates one or + more of the expressions. + items: + description: The weights of all of the matched WeightedPodAffinityTerm + fields are added per-node to find the most preferred node(s) + properties: + podAffinityTerm: + description: Required. A pod affinity term, associated + with the corresponding weight. + properties: + labelSelector: + description: A label query over a set of resources, + in this case pods. + properties: + matchExpressions: + description: matchExpressions is a list of label + selector requirements. The requirements are + ANDed. + items: + description: A label selector requirement + is a selector that contains values, a key, + and an operator that relates the key and + values. + properties: + key: + description: key is the label key that + the selector applies to. + type: string + operator: + description: operator represents a key's + relationship to a set of values. Valid + operators are In, NotIn, Exists and + DoesNotExist. + type: string + values: + description: values is an array of string + values. If the operator is In or NotIn, + the values array must be non-empty. + If the operator is Exists or DoesNotExist, + the values array must be empty. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} + pairs. + type: object + type: object + x-kubernetes-map-type: atomic + namespaceSelector: + description: A label query over the set of namespaces + that the term applies to. The term is applied + to the union of the namespaces selected by this + field and the ones listed in the namespaces field. + properties: + matchExpressions: + description: matchExpressions is a list of label + selector requirements. The requirements are + ANDed. + items: + description: A label selector requirement + is a selector that contains values, a key, + and an operator that relates the key and + values. + properties: + key: + description: key is the label key that + the selector applies to. + type: string + operator: + description: operator represents a key's + relationship to a set of values. Valid + operators are In, NotIn, Exists and + DoesNotExist. + type: string + values: + description: values is an array of string + values. If the operator is In or NotIn, + the values array must be non-empty. + If the operator is Exists or DoesNotExist, + the values array must be empty. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} + pairs. + type: object + type: object + x-kubernetes-map-type: atomic + namespaces: + description: namespaces specifies a static list + of namespace names that the term applies to. The + term is applied to the union of the namespaces + listed in this field and the ones selected by + namespaceSelector. + items: + type: string + type: array + topologyKey: + description: 'This pod should be co-located (affinity) + or not co-located (anti-affinity) with the pods + matching the labelSelector in the specified namespaces, + where co-located is defined as running on a node + whose ' + type: string + required: + - topologyKey + type: object + weight: + description: weight associated with matching the corresponding + podAffinityTerm, in the range 1-100. + format: int32 + type: integer + required: + - podAffinityTerm + - weight + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + description: If the affinity requirements specified by this + field are not met at scheduling time, the pod will not be + scheduled onto the node. + items: + description: Defines a set of pods (namely those matching + the labelSelector relative to the given namespace(s)) + that this pod should be co-located (affinity) or not co-located + (anti-affinity) with, where co-locate + properties: + labelSelector: + description: A label query over a set of resources, + in this case pods. + properties: + matchExpressions: + description: matchExpressions is a list of label + selector requirements. The requirements are ANDed. + items: + description: A label selector requirement is a + selector that contains values, a key, and an + operator that relates the key and values. + properties: + key: + description: key is the label key that the + selector applies to. + type: string + operator: + description: operator represents a key's relationship + to a set of values. Valid operators are + In, NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string + values. If the operator is In or NotIn, + the values array must be non-empty. If the + operator is Exists or DoesNotExist, the + values array must be empty. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} + pairs. + type: object + type: object + x-kubernetes-map-type: atomic + namespaceSelector: + description: A label query over the set of namespaces + that the term applies to. The term is applied to the + union of the namespaces selected by this field and + the ones listed in the namespaces field. + properties: + matchExpressions: + description: matchExpressions is a list of label + selector requirements. The requirements are ANDed. + items: + description: A label selector requirement is a + selector that contains values, a key, and an + operator that relates the key and values. + properties: + key: + description: key is the label key that the + selector applies to. + type: string + operator: + description: operator represents a key's relationship + to a set of values. Valid operators are + In, NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string + values. If the operator is In or NotIn, + the values array must be non-empty. If the + operator is Exists or DoesNotExist, the + values array must be empty. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} + pairs. + type: object + type: object + x-kubernetes-map-type: atomic + namespaces: + description: namespaces specifies a static list of namespace + names that the term applies to. The term is applied + to the union of the namespaces listed in this field + and the ones selected by namespaceSelector. + items: + type: string + type: array + topologyKey: + description: 'This pod should be co-located (affinity) + or not co-located (anti-affinity) with the pods matching + the labelSelector in the specified namespaces, where + co-located is defined as running on a node whose ' + type: string + required: + - topologyKey + type: object + type: array + type: object + podAntiAffinity: + description: Describes pod anti-affinity scheduling rules (e.g. + avoid putting this pod in the same node, zone, etc. as some + other pod(s)). + properties: + preferredDuringSchedulingIgnoredDuringExecution: + description: The scheduler will prefer to schedule pods to + nodes that satisfy the anti-affinity expressions specified + by this field, but it may choose a node that violates one + or more of the expressions. + items: + description: The weights of all of the matched WeightedPodAffinityTerm + fields are added per-node to find the most preferred node(s) + properties: + podAffinityTerm: + description: Required. A pod affinity term, associated + with the corresponding weight. + properties: + labelSelector: + description: A label query over a set of resources, + in this case pods. + properties: + matchExpressions: + description: matchExpressions is a list of label + selector requirements. The requirements are + ANDed. + items: + description: A label selector requirement + is a selector that contains values, a key, + and an operator that relates the key and + values. + properties: + key: + description: key is the label key that + the selector applies to. + type: string + operator: + description: operator represents a key's + relationship to a set of values. Valid + operators are In, NotIn, Exists and + DoesNotExist. + type: string + values: + description: values is an array of string + values. If the operator is In or NotIn, + the values array must be non-empty. + If the operator is Exists or DoesNotExist, + the values array must be empty. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} + pairs. + type: object + type: object + x-kubernetes-map-type: atomic + namespaceSelector: + description: A label query over the set of namespaces + that the term applies to. The term is applied + to the union of the namespaces selected by this + field and the ones listed in the namespaces field. + properties: + matchExpressions: + description: matchExpressions is a list of label + selector requirements. The requirements are + ANDed. + items: + description: A label selector requirement + is a selector that contains values, a key, + and an operator that relates the key and + values. + properties: + key: + description: key is the label key that + the selector applies to. + type: string + operator: + description: operator represents a key's + relationship to a set of values. Valid + operators are In, NotIn, Exists and + DoesNotExist. + type: string + values: + description: values is an array of string + values. If the operator is In or NotIn, + the values array must be non-empty. + If the operator is Exists or DoesNotExist, + the values array must be empty. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} + pairs. + type: object + type: object + x-kubernetes-map-type: atomic + namespaces: + description: namespaces specifies a static list + of namespace names that the term applies to. The + term is applied to the union of the namespaces + listed in this field and the ones selected by + namespaceSelector. + items: + type: string + type: array + topologyKey: + description: 'This pod should be co-located (affinity) + or not co-located (anti-affinity) with the pods + matching the labelSelector in the specified namespaces, + where co-located is defined as running on a node + whose ' + type: string + required: + - topologyKey + type: object + weight: + description: weight associated with matching the corresponding + podAffinityTerm, in the range 1-100. + format: int32 + type: integer + required: + - podAffinityTerm + - weight + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + description: If the anti-affinity requirements specified by + this field are not met at scheduling time, the pod will + not be scheduled onto the node. + items: + description: Defines a set of pods (namely those matching + the labelSelector relative to the given namespace(s)) + that this pod should be co-located (affinity) or not co-located + (anti-affinity) with, where co-locate + properties: + labelSelector: + description: A label query over a set of resources, + in this case pods. + properties: + matchExpressions: + description: matchExpressions is a list of label + selector requirements. The requirements are ANDed. + items: + description: A label selector requirement is a + selector that contains values, a key, and an + operator that relates the key and values. + properties: + key: + description: key is the label key that the + selector applies to. + type: string + operator: + description: operator represents a key's relationship + to a set of values. Valid operators are + In, NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string + values. If the operator is In or NotIn, + the values array must be non-empty. If the + operator is Exists or DoesNotExist, the + values array must be empty. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} + pairs. + type: object + type: object + x-kubernetes-map-type: atomic + namespaceSelector: + description: A label query over the set of namespaces + that the term applies to. The term is applied to the + union of the namespaces selected by this field and + the ones listed in the namespaces field. + properties: + matchExpressions: + description: matchExpressions is a list of label + selector requirements. The requirements are ANDed. + items: + description: A label selector requirement is a + selector that contains values, a key, and an + operator that relates the key and values. + properties: + key: + description: key is the label key that the + selector applies to. + type: string + operator: + description: operator represents a key's relationship + to a set of values. Valid operators are + In, NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string + values. If the operator is In or NotIn, + the values array must be non-empty. If the + operator is Exists or DoesNotExist, the + values array must be empty. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} + pairs. + type: object + type: object + x-kubernetes-map-type: atomic + namespaces: + description: namespaces specifies a static list of namespace + names that the term applies to. The term is applied + to the union of the namespaces listed in this field + and the ones selected by namespaceSelector. + items: + type: string + type: array + topologyKey: + description: 'This pod should be co-located (affinity) + or not co-located (anti-affinity) with the pods matching + the labelSelector in the specified namespaces, where + co-located is defined as running on a node whose ' + type: string + required: + - topologyKey + type: object + type: array + type: object + type: object + args: + additionalProperties: + type: string + description: Args is the set of arguments to pass to the OpenTelemetry + Collector binary + type: object + autoscaler: + description: Autoscaler specifies the pod autoscaling configuration + to use for the OpenTelemetryCollector workload. + properties: + behavior: + description: HorizontalPodAutoscalerBehavior configures the scaling + behavior of the target in both Up and Down directions (scaleUp + and scaleDown fields respectively). + properties: + scaleDown: + description: scaleDown is scaling policy for scaling Down. + If not set, the default value is to allow to scale down + to minReplicas pods, with a 300 second stabilization window + (i.e. + properties: + policies: + description: policies is a list of potential scaling polices + which can be used during scaling. At least one policy + must be specified, otherwise the HPAScalingRules will + be discarded as invalid + items: + description: HPAScalingPolicy is a single policy which + must hold true for a specified past interval. + properties: + periodSeconds: + description: periodSeconds specifies the window + of time for which the policy should hold true. + PeriodSeconds must be greater than zero and less + than or equal to 1800 (30 min). + format: int32 + type: integer + type: + description: type is used to specify the scaling + policy. + type: string + value: + description: value contains the amount of change + which is permitted by the policy. It must be greater + than zero + format: int32 + type: integer + required: + - periodSeconds + - type + - value + type: object + type: array + x-kubernetes-list-type: atomic + selectPolicy: + description: selectPolicy is used to specify which policy + should be used. If not set, the default value Max is + used. + type: string + stabilizationWindowSeconds: + description: stabilizationWindowSeconds is the number + of seconds for which past recommendations should be + considered while scaling up or scaling down. + format: int32 + type: integer + type: object + scaleUp: + description: scaleUp is scaling policy for scaling Up. + properties: + policies: + description: policies is a list of potential scaling polices + which can be used during scaling. At least one policy + must be specified, otherwise the HPAScalingRules will + be discarded as invalid + items: + description: HPAScalingPolicy is a single policy which + must hold true for a specified past interval. + properties: + periodSeconds: + description: periodSeconds specifies the window + of time for which the policy should hold true. + PeriodSeconds must be greater than zero and less + than or equal to 1800 (30 min). + format: int32 + type: integer + type: + description: type is used to specify the scaling + policy. + type: string + value: + description: value contains the amount of change + which is permitted by the policy. It must be greater + than zero + format: int32 + type: integer + required: + - periodSeconds + - type + - value + type: object + type: array + x-kubernetes-list-type: atomic + selectPolicy: + description: selectPolicy is used to specify which policy + should be used. If not set, the default value Max is + used. + type: string + stabilizationWindowSeconds: + description: stabilizationWindowSeconds is the number + of seconds for which past recommendations should be + considered while scaling up or scaling down. + format: int32 + type: integer + type: object + type: object + maxReplicas: + description: MaxReplicas sets an upper bound to the autoscaling + feature. If MaxReplicas is set autoscaling is enabled. + format: int32 + type: integer + metrics: + description: Metrics is meant to provide a customizable way to + configure HPA metrics. currently the only supported custom metrics + is type=Pod. + items: + description: MetricSpec defines a subset of metrics to be defined + for the HPA's metric array more metric type can be supported + as needed. See https://pkg.go.dev/k8s.io/api/autoscaling/v2#MetricSpec + for reference. + properties: + pods: + description: PodsMetricSource indicates how to scale on + a metric describing each pod in the current scale target + (for example, transactions-processed-per-second). + properties: + metric: + description: metric identifies the target metric by + name and selector + properties: + name: + description: name is the name of the given metric + type: string + selector: + description: selector is the string-encoded form + of a standard kubernetes label selector for the + given metric When set, it is passed as an additional + parameter to the metrics server for more specific + metrics scopi + properties: + matchExpressions: + description: matchExpressions is a list of label + selector requirements. The requirements are + ANDed. + items: + description: A label selector requirement + is a selector that contains values, a key, + and an operator that relates the key and + values. + properties: + key: + description: key is the label key that + the selector applies to. + type: string + operator: + description: operator represents a key's + relationship to a set of values. Valid + operators are In, NotIn, Exists and + DoesNotExist. + type: string + values: + description: values is an array of string + values. If the operator is In or NotIn, + the values array must be non-empty. + If the operator is Exists or DoesNotExist, + the values array must be empty. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} + pairs. + type: object + type: object + x-kubernetes-map-type: atomic + required: + - name + type: object + target: + description: target specifies the target value for the + given metric + properties: + averageUtilization: + description: averageUtilization is the target value + of the average of the resource metric across all + relevant pods, represented as a percentage of + the requested value of the resource for the pods. + format: int32 + type: integer + averageValue: + anyOf: + - type: integer + - type: string + description: averageValue is the target value of + the average of the metric across all relevant + pods (as a quantity) + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: + description: type represents whether the metric + type is Utilization, Value, or AverageValue + type: string + value: + anyOf: + - type: integer + - type: string + description: value is the target value of the metric + (as a quantity). + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + required: + - type + type: object + required: + - metric + - target + type: object + type: + description: MetricSourceType indicates the type of metric. + type: string + required: + - type + type: object + type: array + minReplicas: + description: MinReplicas sets a lower bound to the autoscaling + feature. Set this if your are using autoscaling. It must be + at least 1 + format: int32 + type: integer + targetCPUUtilization: + description: TargetCPUUtilization sets the target average CPU + used across all replicas. If average CPU exceeds this value, + the HPA will scale up. Defaults to 90 percent. + format: int32 + type: integer + targetMemoryUtilization: + description: TargetMemoryUtilization sets the target average memory + utilization across all replicas + format: int32 + type: integer + type: object + config: + description: Config is the raw JSON to be used as the collector's + configuration. Refer to the OpenTelemetry Collector documentation + for details. + type: string + configmaps: + description: ConfigMaps is a list of ConfigMaps in the same namespace + as the OpenTelemetryCollector object, which shall be mounted into + the Collector Pods. + items: + properties: + mountpath: + type: string + name: + description: Configmap defines name and path where the configMaps + should be mounted. + type: string + required: + - mountpath + - name + type: object + type: array + env: + description: ENV vars to set on the OpenTelemetry Collector's Pods. + These can then in certain cases be consumed in the config file for + the Collector. + items: + description: EnvVar represents an environment variable present in + a Container. + properties: + name: + description: Name of the environment variable. Must be a C_IDENTIFIER. + type: string + value: + description: Variable references $(VAR_NAME) are expanded using + the previously defined environment variables in the container + and any service environment variables. + type: string + valueFrom: + description: Source for the environment variable's value. Cannot + be used if value is not empty. + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + optional: + description: Specify whether the ConfigMap or its key + must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + fieldRef: + description: 'Selects a field of the pod: supports metadata.name, + metadata.namespace, `metadata.labels['''']`, `metadata.annotations['''']`, + spec.nodeName, spec.serviceAccountName, status.hostIP, + status.' + properties: + apiVersion: + description: Version of the schema the FieldPath is + written in terms of, defaults to "v1". + type: string + fieldPath: + description: Path of the field to select in the specified + API version. + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + resourceFieldRef: + description: 'Selects a resource of the container: only + resources limits and requests (limits.cpu, limits.memory, + limits.ephemeral-storage, requests.cpu, requests.memory + and requests.' + properties: + containerName: + description: 'Container name: required for volumes, + optional for env vars' + type: string + divisor: + anyOf: + - type: integer + - type: string + description: Specifies the output format of the exposed + resources, defaults to "1" + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to select' + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + secretKeyRef: + description: Selects a key of a secret in the pod's namespace + properties: + key: + description: The key of the secret to select from. Must + be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + optional: + description: Specify whether the Secret or its key must + be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + type: object + required: + - name + type: object + type: array + envFrom: + description: List of sources to populate environment variables on + the OpenTelemetry Collector's Pods. These can then in certain cases + be consumed in the config file for the Collector. + items: + description: EnvFromSource represents the source of a set of ConfigMaps + properties: + configMapRef: + description: The ConfigMap to select from + properties: + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + optional: + description: Specify whether the ConfigMap must be defined + type: boolean + type: object + x-kubernetes-map-type: atomic + prefix: + description: An optional identifier to prepend to each key in + the ConfigMap. Must be a C_IDENTIFIER. + type: string + secretRef: + description: The Secret to select from + properties: + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + optional: + description: Specify whether the Secret must be defined + type: boolean + type: object + x-kubernetes-map-type: atomic + type: object + type: array + hostNetwork: + description: HostNetwork indicates if the pod should run in the host + networking namespace. + type: boolean + image: + description: Image indicates the container image to use for the OpenTelemetry + Collector. + type: string + imagePullPolicy: + description: ImagePullPolicy indicates the pull policy to be used + for retrieving the container image (Always, Never, IfNotPresent) + type: string + ingress: + description: 'Ingress is used to specify how OpenTelemetry Collector + is exposed. This functionality is only available if one of the valid + modes is set. Valid modes are: deployment, daemonset and statefulset.' + properties: + annotations: + additionalProperties: + type: string + description: 'Annotations to add to ingress. e.g. ''cert-manager.io/cluster-issuer: + "letsencrypt"''' + type: object + hostname: + description: Hostname by which the ingress proxy can be reached. + type: string + ingressClassName: + description: IngressClassName is the name of an IngressClass cluster + resource. Ingress controller implementations use this field + to know whether they should be serving this Ingress resource. + type: string + route: + description: Route is an OpenShift specific section that is only + considered when type "route" is used. + properties: + termination: + description: Termination indicates termination type. By default + "edge" is used. + enum: + - insecure + - edge + - passthrough + - reencrypt + type: string + type: object + ruleType: + description: RuleType defines how Ingress exposes collector receivers. + IngressRuleTypePath ("path") exposes each receiver port on a + unique path on single domain defined in Hostname. + enum: + - path + - subdomain + type: string + tls: + description: TLS configuration. + items: + description: IngressTLS describes the transport layer security + associated with an ingress. + properties: + hosts: + description: hosts is a list of hosts included in the TLS + certificate. The values in this list must match the name/s + used in the tlsSecret. + items: + type: string + type: array + x-kubernetes-list-type: atomic + secretName: + description: secretName is the name of the secret used to + terminate TLS traffic on port 443. Field is left optional + to allow TLS routing based on SNI hostname alone. + type: string + type: object + type: array + type: + description: 'Type default value is: "" Supported types are: ingress, + route' + enum: + - ingress + - route + type: string + type: object + initContainers: + description: InitContainers allows injecting initContainers to the + Collector's pod definition. + items: + description: A single application container that you want to run + within a pod. + properties: + args: + description: Arguments to the entrypoint. The container image's + CMD is used if this is not provided. Variable references $(VAR_NAME) + are expanded using the container's environment. + items: + type: string + type: array + command: + description: Entrypoint array. Not executed within a shell. + The container image's ENTRYPOINT is used if this is not provided. + Variable references $(VAR_NAME) are expanded using the container's + environment. + items: + type: string + type: array + env: + description: List of environment variables to set in the container. + Cannot be updated. + items: + description: EnvVar represents an environment variable present + in a Container. + properties: + name: + description: Name of the environment variable. Must be + a C_IDENTIFIER. + type: string + value: + description: Variable references $(VAR_NAME) are expanded + using the previously defined environment variables in + the container and any service environment variables. + type: string + valueFrom: + description: Source for the environment variable's value. + Cannot be used if value is not empty. + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: + https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the ConfigMap or + its key must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + fieldRef: + description: 'Selects a field of the pod: supports + metadata.name, metadata.namespace, `metadata.labels['''']`, + `metadata.annotations['''']`, spec.nodeName, + spec.serviceAccountName, status.hostIP, status.' + properties: + apiVersion: + description: Version of the schema the FieldPath + is written in terms of, defaults to "v1". + type: string + fieldPath: + description: Path of the field to select in the + specified API version. + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + resourceFieldRef: + description: 'Selects a resource of the container: + only resources limits and requests (limits.cpu, + limits.memory, limits.ephemeral-storage, requests.cpu, + requests.memory and requests.' + properties: + containerName: + description: 'Container name: required for volumes, + optional for env vars' + type: string + divisor: + anyOf: + - type: integer + - type: string + description: Specifies the output format of the + exposed resources, defaults to "1" + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to select' + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + secretKeyRef: + description: Selects a key of a secret in the pod's + namespace + properties: + key: + description: The key of the secret to select from. Must + be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: + https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the Secret or its + key must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + type: object + required: + - name + type: object + type: array + envFrom: + description: List of sources to populate environment variables + in the container. The keys defined within a source must be + a C_IDENTIFIER. + items: + description: EnvFromSource represents the source of a set + of ConfigMaps + properties: + configMapRef: + description: The ConfigMap to select from + properties: + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the ConfigMap must be + defined + type: boolean + type: object + x-kubernetes-map-type: atomic + prefix: + description: An optional identifier to prepend to each + key in the ConfigMap. Must be a C_IDENTIFIER. + type: string + secretRef: + description: The Secret to select from + properties: + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the Secret must be defined + type: boolean + type: object + x-kubernetes-map-type: atomic + type: object + type: array + image: + description: 'Container image name. More info: https://kubernetes.' + type: string + imagePullPolicy: + description: 'Image pull policy. One of Always, Never, IfNotPresent. + Defaults to Always if :latest tag is specified, or IfNotPresent + otherwise. Cannot be updated. More info: https://kubernetes.' + type: string + lifecycle: + description: Actions that the management system should take + in response to container lifecycle events. Cannot be updated. + properties: + postStart: + description: PostStart is called immediately after a container + is created. If the handler fails, the container is terminated + and restarted according to its restart policy. + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: Command is the command line to execute + inside the container, the working directory for + the command is root ('/') in the container's + filesystem. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: Host name to connect to, defaults to + the pod IP. You probably want to set "Host" in + httpHeaders instead. + type: string + httpHeaders: + description: Custom headers to set in the request. + HTTP allows repeated headers. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name. This will + be canonicalized upon output, so case-variant + names will be understood as the same header. + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: Name or number of the port to access + on the container. Number must be in the range + 1 to 65535. Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the + host. Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: Deprecated. TCPSocket is NOT supported + as a LifecycleHandler and kept for the backward compatibility. + properties: + host: + description: 'Optional: Host name to connect to, + defaults to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: Number or name of the port to access + on the container. Number must be in the range + 1 to 65535. Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + preStop: + description: PreStop is called immediately before a container + is terminated due to an API request or management event + such as liveness/startup probe failure, preemption, resource + contention, etc. + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: Command is the command line to execute + inside the container, the working directory for + the command is root ('/') in the container's + filesystem. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: Host name to connect to, defaults to + the pod IP. You probably want to set "Host" in + httpHeaders instead. + type: string + httpHeaders: + description: Custom headers to set in the request. + HTTP allows repeated headers. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name. This will + be canonicalized upon output, so case-variant + names will be understood as the same header. + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: Name or number of the port to access + on the container. Number must be in the range + 1 to 65535. Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the + host. Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: Deprecated. TCPSocket is NOT supported + as a LifecycleHandler and kept for the backward compatibility. + properties: + host: + description: 'Optional: Host name to connect to, + defaults to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: Number or name of the port to access + on the container. Number must be in the range + 1 to 65535. Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + type: object + livenessProbe: + description: 'Periodic probe of container liveness. Container + will be restarted if the probe fails. Cannot be updated. More + info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: Command is the command line to execute + inside the container, the working directory for the + command is root ('/') in the container's filesystem. + items: + type: string + type: array + type: object + failureThreshold: + description: Minimum consecutive failures for the probe + to be considered failed after having succeeded. Defaults + to 3. Minimum value is 1. + format: int32 + type: integer + grpc: + description: GRPC specifies an action involving a GRPC port. + properties: + port: + description: Port number of the gRPC service. Number + must be in the range 1 to 65535. + format: int32 + type: integer + service: + description: Service is the name of the service to place + in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). + type: string + required: + - port + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: Host name to connect to, defaults to the + pod IP. You probably want to set "Host" in httpHeaders + instead. + type: string + httpHeaders: + description: Custom headers to set in the request. HTTP + allows repeated headers. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name. This will + be canonicalized upon output, so case-variant + names will be understood as the same header. + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: Name or number of the port to access on + the container. Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + initialDelaySeconds: + description: 'Number of seconds after the container has + started before liveness probes are initiated. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + periodSeconds: + description: How often (in seconds) to perform the probe. + Default to 10 seconds. Minimum value is 1. + format: int32 + type: integer + successThreshold: + description: Minimum consecutive successes for the probe + to be considered successful after having failed. Defaults + to 1. Must be 1 for liveness and startup. Minimum value + is 1. + format: int32 + type: integer + tcpSocket: + description: TCPSocket specifies an action involving a TCP + port. + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: Number or name of the port to access on + the container. Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + description: Optional duration in seconds the pod needs + to terminate gracefully upon probe failure. + format: int64 + type: integer + timeoutSeconds: + description: 'Number of seconds after which the probe times + out. Defaults to 1 second. Minimum value is 1. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + type: object + name: + description: Name of the container specified as a DNS_LABEL. + Each container in a pod must have a unique name (DNS_LABEL). + Cannot be updated. + type: string + ports: + description: List of ports to expose from the container. Not + specifying a port here DOES NOT prevent that port from being + exposed. Any port which is listening on the default "0.0.0. + items: + description: ContainerPort represents a network port in a + single container. + properties: + containerPort: + description: Number of port to expose on the pod's IP + address. This must be a valid port number, 0 < x < 65536. + format: int32 + type: integer + hostIP: + description: What host IP to bind the external port to. + type: string + hostPort: + description: Number of port to expose on the host. If + specified, this must be a valid port number, 0 < x < + 65536. If HostNetwork is specified, this must match + ContainerPort. Most containers do not need this. + format: int32 + type: integer + name: + description: If specified, this must be an IANA_SVC_NAME + and unique within the pod. Each named port in a pod + must have a unique name. Name for the port that can + be referred to by services. + type: string + protocol: + default: TCP + description: Protocol for port. Must be UDP, TCP, or SCTP. + Defaults to "TCP". + type: string + required: + - containerPort + type: object + type: array + x-kubernetes-list-map-keys: + - containerPort + - protocol + x-kubernetes-list-type: map + readinessProbe: + description: 'Periodic probe of container service readiness. + Container will be removed from service endpoints if the probe + fails. Cannot be updated. More info: https://kubernetes.' + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: Command is the command line to execute + inside the container, the working directory for the + command is root ('/') in the container's filesystem. + items: + type: string + type: array + type: object + failureThreshold: + description: Minimum consecutive failures for the probe + to be considered failed after having succeeded. Defaults + to 3. Minimum value is 1. + format: int32 + type: integer + grpc: + description: GRPC specifies an action involving a GRPC port. + properties: + port: + description: Port number of the gRPC service. Number + must be in the range 1 to 65535. + format: int32 + type: integer + service: + description: Service is the name of the service to place + in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). + type: string + required: + - port + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: Host name to connect to, defaults to the + pod IP. You probably want to set "Host" in httpHeaders + instead. + type: string + httpHeaders: + description: Custom headers to set in the request. HTTP + allows repeated headers. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name. This will + be canonicalized upon output, so case-variant + names will be understood as the same header. + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: Name or number of the port to access on + the container. Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + initialDelaySeconds: + description: 'Number of seconds after the container has + started before liveness probes are initiated. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + periodSeconds: + description: How often (in seconds) to perform the probe. + Default to 10 seconds. Minimum value is 1. + format: int32 + type: integer + successThreshold: + description: Minimum consecutive successes for the probe + to be considered successful after having failed. Defaults + to 1. Must be 1 for liveness and startup. Minimum value + is 1. + format: int32 + type: integer + tcpSocket: + description: TCPSocket specifies an action involving a TCP + port. + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: Number or name of the port to access on + the container. Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + description: Optional duration in seconds the pod needs + to terminate gracefully upon probe failure. + format: int64 + type: integer + timeoutSeconds: + description: 'Number of seconds after which the probe times + out. Defaults to 1 second. Minimum value is 1. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + type: object + resizePolicy: + description: Resources resize policy for the container. + items: + description: ContainerResizePolicy represents resource resize + policy for the container. + properties: + resourceName: + description: 'Name of the resource to which this resource + resize policy applies. Supported values: cpu, memory.' + type: string + restartPolicy: + description: Restart policy to apply when specified resource + is resized. If not specified, it defaults to NotRequired. + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic + resources: + description: 'Compute Resources required by this container. + Cannot be updated. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + properties: + claims: + description: "Claims lists the names of resources, defined + in spec.resourceClaims, that are used by this container. + \n This is an alpha field and requires enabling the DynamicResourceAllocation + feature gate." + items: + description: ResourceClaim references one entry in PodSpec.ResourceClaims. + properties: + name: + description: Name must match the name of one entry + in pod.spec.resourceClaims of the Pod where this + field is used. It makes that resource available + inside a container. + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Limits describes the maximum amount of compute + resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: Requests describes the minimum amount of compute + resources required. + type: object + type: object + restartPolicy: + description: RestartPolicy defines the restart behavior of individual + containers in a pod. This field may only be set for init containers, + and the only allowed value is "Always". + type: string + securityContext: + description: SecurityContext defines the security options the + container should be run with. If set, the fields of SecurityContext + override the equivalent fields of PodSecurityContext. + properties: + allowPrivilegeEscalation: + description: AllowPrivilegeEscalation controls whether a + process can gain more privileges than its parent process. + This bool directly controls if the no_new_privs flag will + be set on the container process. + type: boolean + capabilities: + description: The capabilities to add/drop when running containers. + Defaults to the default set of capabilities granted by + the container runtime. Note that this field cannot be + set when spec.os.name is windows. + properties: + add: + description: Added capabilities + items: + description: Capability represent POSIX capabilities + type + type: string + type: array + drop: + description: Removed capabilities + items: + description: Capability represent POSIX capabilities + type + type: string + type: array + type: object + privileged: + description: Run container in privileged mode. Processes + in privileged containers are essentially equivalent to + root on the host. Defaults to false. Note that this field + cannot be set when spec.os.name is windows. + type: boolean + procMount: + description: procMount denotes the type of proc mount to + use for the containers. The default is DefaultProcMount + which uses the container runtime defaults for readonly + paths and masked paths. + type: string + readOnlyRootFilesystem: + description: Whether this container has a read-only root + filesystem. Default is false. Note that this field cannot + be set when spec.os.name is windows. + type: boolean + runAsGroup: + description: The GID to run the entrypoint of the container + process. Uses runtime default if unset. May also be set + in PodSecurityContext. + format: int64 + type: integer + runAsNonRoot: + description: Indicates that the container must run as a + non-root user. + type: boolean + runAsUser: + description: The UID to run the entrypoint of the container + process. Defaults to user specified in image metadata + if unspecified. May also be set in PodSecurityContext. + format: int64 + type: integer + seLinuxOptions: + description: The SELinux context to be applied to the container. + If unspecified, the container runtime will allocate a + random SELinux context for each container. May also be + set in PodSecurityContext. + properties: + level: + description: Level is SELinux level label that applies + to the container. + type: string + role: + description: Role is a SELinux role label that applies + to the container. + type: string + type: + description: Type is a SELinux type label that applies + to the container. + type: string + user: + description: User is a SELinux user label that applies + to the container. + type: string + type: object + seccompProfile: + description: The seccomp options to use by this container. + If seccomp options are provided at both the pod & container + level, the container options override the pod options. + properties: + localhostProfile: + description: localhostProfile indicates a profile defined + in a file on the node should be used. The profile + must be preconfigured on the node to work. + type: string + type: + description: "type indicates which kind of seccomp profile + will be applied. Valid options are: \n Localhost - + a profile defined in a file on the node should be + used." + type: string + required: + - type + type: object + windowsOptions: + description: The Windows specific settings applied to all + containers. If unspecified, the options from the PodSecurityContext + will be used. + properties: + gmsaCredentialSpec: + description: GMSACredentialSpec is where the GMSA admission + webhook (https://github.com/kubernetes-sigs/windows-gmsa) + inlines the contents of the GMSA credential spec named + by the GMSACredentialSpecName field. + type: string + gmsaCredentialSpecName: + description: GMSACredentialSpecName is the name of the + GMSA credential spec to use. + type: string + hostProcess: + description: HostProcess determines if a container should + be run as a 'Host Process' container. + type: boolean + runAsUserName: + description: The UserName in Windows to run the entrypoint + of the container process. Defaults to the user specified + in image metadata if unspecified. May also be set + in PodSecurityContext. + type: string + type: object + type: object + startupProbe: + description: StartupProbe indicates that the Pod has successfully + initialized. If specified, no other probes are executed until + this completes successfully. + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: Command is the command line to execute + inside the container, the working directory for the + command is root ('/') in the container's filesystem. + items: + type: string + type: array + type: object + failureThreshold: + description: Minimum consecutive failures for the probe + to be considered failed after having succeeded. Defaults + to 3. Minimum value is 1. + format: int32 + type: integer + grpc: + description: GRPC specifies an action involving a GRPC port. + properties: + port: + description: Port number of the gRPC service. Number + must be in the range 1 to 65535. + format: int32 + type: integer + service: + description: Service is the name of the service to place + in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). + type: string + required: + - port + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: Host name to connect to, defaults to the + pod IP. You probably want to set "Host" in httpHeaders + instead. + type: string + httpHeaders: + description: Custom headers to set in the request. HTTP + allows repeated headers. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name. This will + be canonicalized upon output, so case-variant + names will be understood as the same header. + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: Name or number of the port to access on + the container. Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + initialDelaySeconds: + description: 'Number of seconds after the container has + started before liveness probes are initiated. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + periodSeconds: + description: How often (in seconds) to perform the probe. + Default to 10 seconds. Minimum value is 1. + format: int32 + type: integer + successThreshold: + description: Minimum consecutive successes for the probe + to be considered successful after having failed. Defaults + to 1. Must be 1 for liveness and startup. Minimum value + is 1. + format: int32 + type: integer + tcpSocket: + description: TCPSocket specifies an action involving a TCP + port. + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: Number or name of the port to access on + the container. Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + description: Optional duration in seconds the pod needs + to terminate gracefully upon probe failure. + format: int64 + type: integer + timeoutSeconds: + description: 'Number of seconds after which the probe times + out. Defaults to 1 second. Minimum value is 1. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + type: object + stdin: + description: Whether this container should allocate a buffer + for stdin in the container runtime. If this is not set, reads + from stdin in the container will always result in EOF. Default + is false. + type: boolean + stdinOnce: + description: Whether the container runtime should close the + stdin channel after it has been opened by a single attach. + When stdin is true the stdin stream will remain open across + multiple attach sessions. + type: boolean + terminationMessagePath: + description: 'Optional: Path at which the file to which the + container''s termination message will be written is mounted + into the container''s filesystem.' + type: string + terminationMessagePolicy: + description: Indicate how the termination message should be + populated. File will use the contents of terminationMessagePath + to populate the container status message on both success and + failure. + type: string + tty: + description: Whether this container should allocate a TTY for + itself, also requires 'stdin' to be true. Default is false. + type: boolean + volumeDevices: + description: volumeDevices is the list of block devices to be + used by the container. + items: + description: volumeDevice describes a mapping of a raw block + device within a container. + properties: + devicePath: + description: devicePath is the path inside of the container + that the device will be mapped to. + type: string + name: + description: name must match the name of a persistentVolumeClaim + in the pod + type: string + required: + - devicePath + - name + type: object + type: array + volumeMounts: + description: Pod volumes to mount into the container's filesystem. + Cannot be updated. + items: + description: VolumeMount describes a mounting of a Volume + within a container. + properties: + mountPath: + description: Path within the container at which the volume + should be mounted. Must not contain ':'. + type: string + mountPropagation: + description: mountPropagation determines how mounts are + propagated from the host to container and the other + way around. When not set, MountPropagationNone is used. + This field is beta in 1.10. + type: string + name: + description: This must match the Name of a Volume. + type: string + readOnly: + description: Mounted read-only if true, read-write otherwise + (false or unspecified). Defaults to false. + type: boolean + subPath: + description: Path within the volume from which the container's + volume should be mounted. Defaults to "" (volume's root). + type: string + subPathExpr: + description: Expanded path within the volume from which + the container's volume should be mounted. + type: string + required: + - mountPath + - name + type: object + type: array + workingDir: + description: Container's working directory. If not specified, + the container runtime's default will be used, which might + be configured in the container image. Cannot be updated. + type: string + required: + - name + type: object + type: array + lifecycle: + description: Actions that the management system should take in response + to container lifecycle events. Cannot be updated. + properties: + postStart: + description: PostStart is called immediately after a container + is created. If the handler fails, the container is terminated + and restarted according to its restart policy. + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: Command is the command line to execute inside + the container, the working directory for the command is + root ('/') in the container's filesystem. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: Host name to connect to, defaults to the + pod IP. You probably want to set "Host" in httpHeaders + instead. + type: string + httpHeaders: + description: Custom headers to set in the request. HTTP + allows repeated headers. + items: + description: HTTPHeader describes a custom header to + be used in HTTP probes + properties: + name: + description: The header field name. This will be + canonicalized upon output, so case-variant names + will be understood as the same header. + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: Name or number of the port to access on the + container. Number must be in the range 1 to 65535. Name + must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: Deprecated. TCPSocket is NOT supported as a LifecycleHandler + and kept for the backward compatibility. + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: Number or name of the port to access on the + container. Number must be in the range 1 to 65535. Name + must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + preStop: + description: PreStop is called immediately before a container + is terminated due to an API request or management event such + as liveness/startup probe failure, preemption, resource contention, + etc. + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: Command is the command line to execute inside + the container, the working directory for the command is + root ('/') in the container's filesystem. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: Host name to connect to, defaults to the + pod IP. You probably want to set "Host" in httpHeaders + instead. + type: string + httpHeaders: + description: Custom headers to set in the request. HTTP + allows repeated headers. + items: + description: HTTPHeader describes a custom header to + be used in HTTP probes + properties: + name: + description: The header field name. This will be + canonicalized upon output, so case-variant names + will be understood as the same header. + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: Name or number of the port to access on the + container. Number must be in the range 1 to 65535. Name + must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: Deprecated. TCPSocket is NOT supported as a LifecycleHandler + and kept for the backward compatibility. + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: Number or name of the port to access on the + container. Number must be in the range 1 to 65535. Name + must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + type: object + livenessProbe: + description: Liveness config for the OpenTelemetry Collector except + the probe handler which is auto generated from the health extension + of the collector. + properties: + failureThreshold: + description: Minimum consecutive failures for the probe to be + considered failed after having succeeded. Defaults to 3. Minimum + value is 1. + format: int32 + type: integer + initialDelaySeconds: + description: 'Number of seconds after the container has started + before liveness probes are initiated. Defaults to 0 seconds. + Minimum value is 0. More info: https://kubernetes.' + format: int32 + type: integer + periodSeconds: + description: How often (in seconds) to perform the probe. Default + to 10 seconds. Minimum value is 1. + format: int32 + type: integer + successThreshold: + description: Minimum consecutive successes for the probe to be + considered successful after having failed. Defaults to 1. Must + be 1 for liveness and startup. Minimum value is 1. + format: int32 + type: integer + terminationGracePeriodSeconds: + description: Optional duration in seconds the pod needs to terminate + gracefully upon probe failure. + format: int64 + type: integer + timeoutSeconds: + description: 'Number of seconds after which the probe times out. + Defaults to 1 second. Minimum value is 1. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + type: object + managementState: + default: managed + description: ManagementState defines if the CR should be managed by + the operator or not. Default is managed. + enum: + - managed + - unmanaged + type: string + maxReplicas: + description: 'MaxReplicas sets an upper bound to the autoscaling feature. + If MaxReplicas is set autoscaling is enabled. Deprecated: use "OpenTelemetryCollector.Spec.Autoscaler.MaxReplicas" + instead.' + format: int32 + type: integer + minReplicas: + description: 'MinReplicas sets a lower bound to the autoscaling feature. Set + this if you are using autoscaling. It must be at least 1 Deprecated: + use "OpenTelemetryCollector.Spec.Autoscaler.MinReplicas" instead.' + format: int32 + type: integer + mode: + description: Mode represents how the collector should be deployed + (deployment, daemonset, statefulset or sidecar) + enum: + - daemonset + - deployment + - sidecar + - statefulset + type: string + nodeSelector: + additionalProperties: + type: string + description: NodeSelector to schedule OpenTelemetry Collector pods. + This is only relevant to daemonset, statefulset, and deployment + mode + type: object + observability: + description: ObservabilitySpec defines how telemetry data gets handled. + properties: + metrics: + description: Metrics defines the metrics configuration for operands. + properties: + enableMetrics: + description: EnableMetrics specifies if ServiceMonitor should + be created for the OpenTelemetry Collector and Prometheus + Exporters. The operator.observability. + type: boolean + type: object + type: object + podAnnotations: + additionalProperties: + type: string + description: PodAnnotations is the set of annotations that will be + attached to Collector and Target Allocator pods. + type: object + podDisruptionBudget: + description: PodDisruptionBudget specifies the pod disruption budget + configuration to use for the OpenTelemetryCollector workload. + properties: + maxUnavailable: + anyOf: + - type: integer + - type: string + description: An eviction is allowed if at most "maxUnavailable" + pods selected by "selector" are unavailable after the eviction, + i.e. even in absence of the evicted pod. + x-kubernetes-int-or-string: true + minAvailable: + anyOf: + - type: integer + - type: string + description: An eviction is allowed if at least "minAvailable" + pods selected by "selector" will still be available after the + eviction, i.e. even in the absence of the evicted pod. + x-kubernetes-int-or-string: true + type: object + podSecurityContext: + description: PodSecurityContext configures the pod security context + for the opentelemetry-collector pod, when running as a deployment, + daemonset, or statefulset. + properties: + fsGroup: + description: "A special supplemental group that applies to all + containers in a pod. Some volume types allow the Kubelet to + change the ownership of that volume to be owned by the pod: + \n 1." + format: int64 + type: integer + fsGroupChangePolicy: + description: fsGroupChangePolicy defines behavior of changing + ownership and permission of the volume before being exposed + inside Pod. + type: string + runAsGroup: + description: The GID to run the entrypoint of the container process. + Uses runtime default if unset. May also be set in SecurityContext. + format: int64 + type: integer + runAsNonRoot: + description: Indicates that the container must run as a non-root + user. + type: boolean + runAsUser: + description: The UID to run the entrypoint of the container process. + Defaults to user specified in image metadata if unspecified. + May also be set in SecurityContext. + format: int64 + type: integer + seLinuxOptions: + description: The SELinux context to be applied to all containers. + If unspecified, the container runtime will allocate a random + SELinux context for each container. May also be set in SecurityContext. + properties: + level: + description: Level is SELinux level label that applies to + the container. + type: string + role: + description: Role is a SELinux role label that applies to + the container. + type: string + type: + description: Type is a SELinux type label that applies to + the container. + type: string + user: + description: User is a SELinux user label that applies to + the container. + type: string + type: object + seccompProfile: + description: The seccomp options to use by the containers in this + pod. Note that this field cannot be set when spec.os.name is + windows. + properties: + localhostProfile: + description: localhostProfile indicates a profile defined + in a file on the node should be used. The profile must be + preconfigured on the node to work. + type: string + type: + description: "type indicates which kind of seccomp profile + will be applied. Valid options are: \n Localhost - a profile + defined in a file on the node should be used." + type: string + required: + - type + type: object + supplementalGroups: + description: A list of groups applied to the first process run + in each container, in addition to the container's primary GID, + the fsGroup (if specified), and group memberships defined in + the container image for th + items: + format: int64 + type: integer + type: array + sysctls: + description: Sysctls hold a list of namespaced sysctls used for + the pod. Pods with unsupported sysctls (by the container runtime) + might fail to launch. Note that this field cannot be set when + spec.os. + items: + description: Sysctl defines a kernel parameter to be set + properties: + name: + description: Name of a property to set + type: string + value: + description: Value of a property to set + type: string + required: + - name + - value + type: object + type: array + windowsOptions: + description: The Windows specific settings applied to all containers. + If unspecified, the options within a container's SecurityContext + will be used. + properties: + gmsaCredentialSpec: + description: GMSACredentialSpec is where the GMSA admission + webhook (https://github.com/kubernetes-sigs/windows-gmsa) + inlines the contents of the GMSA credential spec named by + the GMSACredentialSpecName field. + type: string + gmsaCredentialSpecName: + description: GMSACredentialSpecName is the name of the GMSA + credential spec to use. + type: string + hostProcess: + description: HostProcess determines if a container should + be run as a 'Host Process' container. + type: boolean + runAsUserName: + description: The UserName in Windows to run the entrypoint + of the container process. Defaults to the user specified + in image metadata if unspecified. May also be set in PodSecurityContext. + type: string + type: object + type: object + ports: + description: Ports allows a set of ports to be exposed by the underlying + v1.Service. By default, the operator will attempt to infer the required + ports by parsing the .Spec. + items: + description: ServicePort contains information on service's port. + properties: + appProtocol: + description: The application protocol for this port. This is + used as a hint for implementations to offer richer behavior + for protocols that they understand. This field follows standard + Kubernetes label syntax. + type: string + name: + description: The name of this port within the service. This + must be a DNS_LABEL. All ports within a ServiceSpec must have + unique names. + type: string + nodePort: + description: The port on each node on which this service is + exposed when type is NodePort or LoadBalancer. Usually assigned + by the system. + format: int32 + type: integer + port: + description: The port that will be exposed by this service. + format: int32 + type: integer + protocol: + default: TCP + description: The IP protocol for this port. Supports "TCP", + "UDP", and "SCTP". Default is TCP. + type: string + targetPort: + anyOf: + - type: integer + - type: string + description: Number or name of the port to access on the pods + targeted by the service. Number must be in the range 1 to + 65535. Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: array + x-kubernetes-list-type: atomic + priorityClassName: + description: If specified, indicates the pod's priority. If not specified, + the pod priority will be default or zero if there is no default. + type: string + replicas: + description: Replicas is the number of pod instances for the underlying + OpenTelemetry Collector. Set this if your are not using autoscaling + format: int32 + type: integer + resources: + description: Resources to set on the OpenTelemetry Collector pods. + properties: + claims: + description: "Claims lists the names of resources, defined in + spec.resourceClaims, that are used by this container. \n This + is an alpha field and requires enabling the DynamicResourceAllocation + feature gate." + items: + description: ResourceClaim references one entry in PodSpec.ResourceClaims. + properties: + name: + description: Name must match the name of one entry in pod.spec.resourceClaims + of the Pod where this field is used. It makes that resource + available inside a container. + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Limits describes the maximum amount of compute resources + allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: Requests describes the minimum amount of compute + resources required. + type: object + type: object + securityContext: + description: SecurityContext configures the container security context + for the opentelemetry-collector container. + properties: + allowPrivilegeEscalation: + description: AllowPrivilegeEscalation controls whether a process + can gain more privileges than its parent process. This bool + directly controls if the no_new_privs flag will be set on the + container process. + type: boolean + capabilities: + description: The capabilities to add/drop when running containers. + Defaults to the default set of capabilities granted by the container + runtime. Note that this field cannot be set when spec.os.name + is windows. + properties: + add: + description: Added capabilities + items: + description: Capability represent POSIX capabilities type + type: string + type: array + drop: + description: Removed capabilities + items: + description: Capability represent POSIX capabilities type + type: string + type: array + type: object + privileged: + description: Run container in privileged mode. Processes in privileged + containers are essentially equivalent to root on the host. Defaults + to false. Note that this field cannot be set when spec.os.name + is windows. + type: boolean + procMount: + description: procMount denotes the type of proc mount to use for + the containers. The default is DefaultProcMount which uses the + container runtime defaults for readonly paths and masked paths. + type: string + readOnlyRootFilesystem: + description: Whether this container has a read-only root filesystem. + Default is false. Note that this field cannot be set when spec.os.name + is windows. + type: boolean + runAsGroup: + description: The GID to run the entrypoint of the container process. + Uses runtime default if unset. May also be set in PodSecurityContext. + format: int64 + type: integer + runAsNonRoot: + description: Indicates that the container must run as a non-root + user. + type: boolean + runAsUser: + description: The UID to run the entrypoint of the container process. + Defaults to user specified in image metadata if unspecified. + May also be set in PodSecurityContext. + format: int64 + type: integer + seLinuxOptions: + description: The SELinux context to be applied to the container. + If unspecified, the container runtime will allocate a random + SELinux context for each container. May also be set in PodSecurityContext. + properties: + level: + description: Level is SELinux level label that applies to + the container. + type: string + role: + description: Role is a SELinux role label that applies to + the container. + type: string + type: + description: Type is a SELinux type label that applies to + the container. + type: string + user: + description: User is a SELinux user label that applies to + the container. + type: string + type: object + seccompProfile: + description: The seccomp options to use by this container. If + seccomp options are provided at both the pod & container level, + the container options override the pod options. + properties: + localhostProfile: + description: localhostProfile indicates a profile defined + in a file on the node should be used. The profile must be + preconfigured on the node to work. + type: string + type: + description: "type indicates which kind of seccomp profile + will be applied. Valid options are: \n Localhost - a profile + defined in a file on the node should be used." + type: string + required: + - type + type: object + windowsOptions: + description: The Windows specific settings applied to all containers. + If unspecified, the options from the PodSecurityContext will + be used. + properties: + gmsaCredentialSpec: + description: GMSACredentialSpec is where the GMSA admission + webhook (https://github.com/kubernetes-sigs/windows-gmsa) + inlines the contents of the GMSA credential spec named by + the GMSACredentialSpecName field. + type: string + gmsaCredentialSpecName: + description: GMSACredentialSpecName is the name of the GMSA + credential spec to use. + type: string + hostProcess: + description: HostProcess determines if a container should + be run as a 'Host Process' container. + type: boolean + runAsUserName: + description: The UserName in Windows to run the entrypoint + of the container process. Defaults to the user specified + in image metadata if unspecified. May also be set in PodSecurityContext. + type: string + type: object + type: object + serviceAccount: + description: ServiceAccount indicates the name of an existing service + account to use with this instance. When set, the operator will not + automatically create a ServiceAccount for the collector. + type: string + targetAllocator: + description: TargetAllocator indicates a value which determines whether + to spawn a target allocation resource or not. + properties: + allocationStrategy: + description: AllocationStrategy determines which strategy the + target allocator should use for allocation. The current options + are least-weighted and consistent-hashing. The default option + is least-weighted + enum: + - least-weighted + - consistent-hashing + type: string + enabled: + description: Enabled indicates whether to use a target allocation + mechanism for Prometheus targets or not. + type: boolean + env: + description: ENV vars to set on the OpenTelemetry TargetAllocator's + Pods. These can then in certain cases be consumed in the config + file for the TargetAllocator. + items: + description: EnvVar represents an environment variable present + in a Container. + properties: + name: + description: Name of the environment variable. Must be a + C_IDENTIFIER. + type: string + value: + description: Variable references $(VAR_NAME) are expanded + using the previously defined environment variables in + the container and any service environment variables. + type: string + valueFrom: + description: Source for the environment variable's value. + Cannot be used if value is not empty. + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the ConfigMap or its + key must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + fieldRef: + description: 'Selects a field of the pod: supports metadata.name, + metadata.namespace, `metadata.labels['''']`, + `metadata.annotations['''']`, spec.nodeName, + spec.serviceAccountName, status.hostIP, status.' + properties: + apiVersion: + description: Version of the schema the FieldPath + is written in terms of, defaults to "v1". + type: string + fieldPath: + description: Path of the field to select in the + specified API version. + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + resourceFieldRef: + description: 'Selects a resource of the container: only + resources limits and requests (limits.cpu, limits.memory, + limits.ephemeral-storage, requests.cpu, requests.memory + and requests.' + properties: + containerName: + description: 'Container name: required for volumes, + optional for env vars' + type: string + divisor: + anyOf: + - type: integer + - type: string + description: Specifies the output format of the + exposed resources, defaults to "1" + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to select' + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + secretKeyRef: + description: Selects a key of a secret in the pod's + namespace + properties: + key: + description: The key of the secret to select from. Must + be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: Specify whether the Secret or its key + must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + type: object + required: + - name + type: object + type: array + filterStrategy: + description: FilterStrategy determines how to filter targets before + allocating them among the collectors. The only current option + is relabel-config (drops targets based on prom relabel_config). + type: string + image: + description: Image indicates the container image to use for the + OpenTelemetry TargetAllocator. + type: string + nodeSelector: + additionalProperties: + type: string + description: NodeSelector to schedule OpenTelemetry TargetAllocator + pods. + type: object + prometheusCR: + description: PrometheusCR defines the configuration for the retrieval + of PrometheusOperator CRDs ( servicemonitor.monitoring.coreos.com/v1 + and podmonitor.monitoring.coreos.com/v1 ) retrieval. + properties: + enabled: + description: Enabled indicates whether to use a PrometheusOperator + custom resources as targets or not. + type: boolean + podMonitorSelector: + additionalProperties: + type: string + description: PodMonitors to be selected for target discovery. + This is a map of {key,value} pairs. Each {key,value} in + the map is going to exactly match a label in a PodMonitor's + meta labels. + type: object + scrapeInterval: + default: 30s + description: "Interval between consecutive scrapes. Equivalent + to the same setting on the Prometheus CRD. \n Default: \"30s\"" + format: duration + type: string + serviceMonitorSelector: + additionalProperties: + type: string + description: ServiceMonitors to be selected for target discovery. + This is a map of {key,value} pairs. Each {key,value} in + the map is going to exactly match a label in a ServiceMonitor's + meta labels. + type: object + type: object + replicas: + description: Replicas is the number of pod instances for the underlying + TargetAllocator. This should only be set to a value other than + 1 if a strategy that allows for high availability is chosen. + format: int32 + type: integer + resources: + description: Resources to set on the OpenTelemetryTargetAllocator + containers. + properties: + claims: + description: "Claims lists the names of resources, defined + in spec.resourceClaims, that are used by this container. + \n This is an alpha field and requires enabling the DynamicResourceAllocation + feature gate." + items: + description: ResourceClaim references one entry in PodSpec.ResourceClaims. + properties: + name: + description: Name must match the name of one entry in + pod.spec.resourceClaims of the Pod where this field + is used. It makes that resource available inside a + container. + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Limits describes the maximum amount of compute + resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: Requests describes the minimum amount of compute + resources required. + type: object + type: object + serviceAccount: + description: ServiceAccount indicates the name of an existing + service account to use with this instance. When set, the operator + will not automatically create a ServiceAccount for the TargetAllocator. + type: string + tolerations: + description: Toleration embedded kubernetes pod configuration + option, controls how pods can be scheduled with matching taints + items: + description: The pod this Toleration is attached to tolerates + any taint that matches the triple using + the matching operator . + properties: + effect: + description: Effect indicates the taint effect to match. + Empty means match all taint effects. When specified, allowed + values are NoSchedule, PreferNoSchedule and NoExecute. + type: string + key: + description: Key is the taint key that the toleration applies + to. Empty means match all taint keys. If the key is empty, + operator must be Exists; this combination means to match + all values and all keys. + type: string + operator: + description: Operator represents a key's relationship to + the value. Valid operators are Exists and Equal. Defaults + to Equal. + type: string + tolerationSeconds: + description: TolerationSeconds represents the period of + time the toleration (which must be of effect NoExecute, + otherwise this field is ignored) tolerates the taint. + format: int64 + type: integer + value: + description: Value is the taint value the toleration matches + to. If the operator is Exists, the value should be empty, + otherwise just a regular string. + type: string + type: object + type: array + topologySpreadConstraints: + description: TopologySpreadConstraints embedded kubernetes pod + configuration option, controls how pods are spread across your + cluster among failure-domains such as regions, zones, nodes, + and other user-defined top + items: + description: TopologySpreadConstraint specifies how to spread + matching pods among the given topology. + properties: + labelSelector: + description: LabelSelector is used to find matching pods. + Pods that match this label selector are counted to determine + the number of pods in their corresponding topology domain. + properties: + matchExpressions: + description: matchExpressions is a list of label selector + requirements. The requirements are ANDed. + items: + description: A label selector requirement is a selector + that contains values, a key, and an operator that + relates the key and values. + properties: + key: + description: key is the label key that the selector + applies to. + type: string + operator: + description: operator represents a key's relationship + to a set of values. Valid operators are In, + NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. + If the operator is In or NotIn, the values array + must be non-empty. If the operator is Exists + or DoesNotExist, the values array must be empty. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. + type: object + type: object + x-kubernetes-map-type: atomic + matchLabelKeys: + description: MatchLabelKeys is a set of pod label keys to + select the pods over which spreading will be calculated. + items: + type: string + type: array + x-kubernetes-list-type: atomic + maxSkew: + description: MaxSkew describes the degree to which pods + may be unevenly distributed. + format: int32 + type: integer + minDomains: + description: MinDomains indicates a minimum number of eligible + domains. + format: int32 + type: integer + nodeAffinityPolicy: + description: NodeAffinityPolicy indicates how we will treat + Pod's nodeAffinity/nodeSelector when calculating pod topology + spread skew. + type: string + nodeTaintsPolicy: + description: NodeTaintsPolicy indicates how we will treat + node taints when calculating pod topology spread skew. + type: string + topologyKey: + description: TopologyKey is the key of node labels. Nodes + that have a label with this key and identical values are + considered to be in the same topology. + type: string + whenUnsatisfiable: + description: WhenUnsatisfiable indicates how to deal with + a pod if it doesn't satisfy the spread constraint. - DoNotSchedule + (default) tells the scheduler not to schedule it. + type: string + required: + - maxSkew + - topologyKey + - whenUnsatisfiable + type: object + type: array + type: object + terminationGracePeriodSeconds: + description: Duration in seconds the pod needs to terminate gracefully + upon probe failure. + format: int64 + type: integer + tolerations: + description: Toleration to schedule OpenTelemetry Collector pods. + This is only relevant to daemonset, statefulset, and deployment + mode + items: + description: The pod this Toleration is attached to tolerates any + taint that matches the triple using the matching + operator . + properties: + effect: + description: Effect indicates the taint effect to match. Empty + means match all taint effects. When specified, allowed values + are NoSchedule, PreferNoSchedule and NoExecute. + type: string + key: + description: Key is the taint key that the toleration applies + to. Empty means match all taint keys. If the key is empty, + operator must be Exists; this combination means to match all + values and all keys. + type: string + operator: + description: Operator represents a key's relationship to the + value. Valid operators are Exists and Equal. Defaults to Equal. + type: string + tolerationSeconds: + description: TolerationSeconds represents the period of time + the toleration (which must be of effect NoExecute, otherwise + this field is ignored) tolerates the taint. + format: int64 + type: integer + value: + description: Value is the taint value the toleration matches + to. If the operator is Exists, the value should be empty, + otherwise just a regular string. + type: string + type: object + type: array + topologySpreadConstraints: + description: TopologySpreadConstraints embedded kubernetes pod configuration + option, controls how pods are spread across your cluster among failure-domains + such as regions, zones, nodes, and other user-defined top + items: + description: TopologySpreadConstraint specifies how to spread matching + pods among the given topology. + properties: + labelSelector: + description: LabelSelector is used to find matching pods. Pods + that match this label selector are counted to determine the + number of pods in their corresponding topology domain. + properties: + matchExpressions: + description: matchExpressions is a list of label selector + requirements. The requirements are ANDed. + items: + description: A label selector requirement is a selector + that contains values, a key, and an operator that relates + the key and values. + properties: + key: + description: key is the label key that the selector + applies to. + type: string + operator: + description: operator represents a key's relationship + to a set of values. Valid operators are In, NotIn, + Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. + If the operator is In or NotIn, the values array + must be non-empty. If the operator is Exists or + DoesNotExist, the values array must be empty. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. + type: object + type: object + x-kubernetes-map-type: atomic + matchLabelKeys: + description: MatchLabelKeys is a set of pod label keys to select + the pods over which spreading will be calculated. + items: + type: string + type: array + x-kubernetes-list-type: atomic + maxSkew: + description: MaxSkew describes the degree to which pods may + be unevenly distributed. + format: int32 + type: integer + minDomains: + description: MinDomains indicates a minimum number of eligible + domains. + format: int32 + type: integer + nodeAffinityPolicy: + description: NodeAffinityPolicy indicates how we will treat + Pod's nodeAffinity/nodeSelector when calculating pod topology + spread skew. + type: string + nodeTaintsPolicy: + description: NodeTaintsPolicy indicates how we will treat node + taints when calculating pod topology spread skew. + type: string + topologyKey: + description: TopologyKey is the key of node labels. Nodes that + have a label with this key and identical values are considered + to be in the same topology. + type: string + whenUnsatisfiable: + description: WhenUnsatisfiable indicates how to deal with a + pod if it doesn't satisfy the spread constraint. - DoNotSchedule + (default) tells the scheduler not to schedule it. + type: string + required: + - maxSkew + - topologyKey + - whenUnsatisfiable + type: object + type: array + upgradeStrategy: + description: UpgradeStrategy represents how the operator will handle + upgrades to the CR when a newer version of the operator is deployed + enum: + - automatic + - none + type: string + volumeClaimTemplates: + description: VolumeClaimTemplates will provide stable storage using + PersistentVolumes. Only available when the mode=statefulset. + items: + description: PersistentVolumeClaim is a user's request for and claim + to a persistent volume + properties: + apiVersion: + description: APIVersion defines the versioned schema of this + representation of an object. Servers should convert recognized + schemas to the latest internal value, and may reject unrecognized + values. + type: string + kind: + description: Kind is a string value representing the REST resource + this object represents. Servers may infer this from the endpoint + the client submits requests to. Cannot be updated. In CamelCase. + type: string + metadata: + description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata' + properties: + annotations: + additionalProperties: + type: string + type: object + finalizers: + items: + type: string + type: array + labels: + additionalProperties: + type: string + type: object + name: + type: string + namespace: + type: string + type: object + spec: + description: 'spec defines the desired characteristics of a + volume requested by a pod author. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims' + properties: + accessModes: + description: 'accessModes contains the desired access modes + the volume should have. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1' + items: + type: string + type: array + dataSource: + description: 'dataSource field can be used to specify either: + * An existing VolumeSnapshot object (snapshot.storage.k8s.' + properties: + apiGroup: + description: APIGroup is the group for the resource + being referenced. If APIGroup is not specified, the + specified Kind must be in the core API group. For + any other third-party types, APIGroup is required. + type: string + kind: + description: Kind is the type of resource being referenced + type: string + name: + description: Name is the name of resource being referenced + type: string + required: + - kind + - name + type: object + x-kubernetes-map-type: atomic + dataSourceRef: + description: dataSourceRef specifies the object from which + to populate the volume with data, if a non-empty volume + is desired. + properties: + apiGroup: + description: APIGroup is the group for the resource + being referenced. If APIGroup is not specified, the + specified Kind must be in the core API group. For + any other third-party types, APIGroup is required. + type: string + kind: + description: Kind is the type of resource being referenced + type: string + name: + description: Name is the name of resource being referenced + type: string + namespace: + description: Namespace is the namespace of resource + being referenced Note that when a namespace is specified, + a gateway.networking.k8s. + type: string + required: + - kind + - name + type: object + resources: + description: resources represents the minimum resources + the volume should have. + properties: + claims: + description: "Claims lists the names of resources, defined + in spec.resourceClaims, that are used by this container. + \n This is an alpha field and requires enabling the + DynamicResourceAllocation feature gate." + items: + description: ResourceClaim references one entry in + PodSpec.ResourceClaims. + properties: + name: + description: Name must match the name of one entry + in pod.spec.resourceClaims of the Pod where + this field is used. It makes that resource available + inside a container. + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Limits describes the maximum amount of + compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: Requests describes the minimum amount of + compute resources required. + type: object + type: object + selector: + description: selector is a label query over volumes to consider + for binding. + properties: + matchExpressions: + description: matchExpressions is a list of label selector + requirements. The requirements are ANDed. + items: + description: A label selector requirement is a selector + that contains values, a key, and an operator that + relates the key and values. + properties: + key: + description: key is the label key that the selector + applies to. + type: string + operator: + description: operator represents a key's relationship + to a set of values. Valid operators are In, + NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. + If the operator is In or NotIn, the values array + must be non-empty. If the operator is Exists + or DoesNotExist, the values array must be empty. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. + type: object + type: object + x-kubernetes-map-type: atomic + storageClassName: + description: 'storageClassName is the name of the StorageClass + required by the claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1' + type: string + volumeMode: + description: volumeMode defines what type of volume is required + by the claim. Value of Filesystem is implied when not + included in claim spec. + type: string + volumeName: + description: volumeName is the binding reference to the + PersistentVolume backing this claim. + type: string + type: object + status: + description: 'status represents the current information/status + of a persistent volume claim. Read-only. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims' + properties: + accessModes: + description: 'accessModes contains the actual access modes + the volume backing the PVC has. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1' + items: + type: string + type: array + allocatedResourceStatuses: + additionalProperties: + description: When a controller receives persistentvolume + claim update with ClaimResourceStatus for a resource + that it does not recognizes, then it should ignore that + update and let other controllers handle it. + type: string + description: allocatedResourceStatuses stores status of + resource being resized for the given PVC. Key names follow + standard Kubernetes label syntax. + type: object + x-kubernetes-map-type: granular + allocatedResources: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: allocatedResources tracks the resources allocated + to a PVC including its capacity. Key names follow standard + Kubernetes label syntax. + type: object + capacity: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: capacity represents the actual resources of + the underlying volume. + type: object + conditions: + description: conditions is the current Condition of persistent + volume claim. If underlying persistent volume is being + resized then the Condition will be set to 'ResizeStarted'. + items: + description: PersistentVolumeClaimCondition contains details + about state of pvc + properties: + lastProbeTime: + description: lastProbeTime is the time we probed the + condition. + format: date-time + type: string + lastTransitionTime: + description: lastTransitionTime is the time the condition + transitioned from one status to another. + format: date-time + type: string + message: + description: message is the human-readable message + indicating details about last transition. + type: string + reason: + description: reason is a unique, this should be a + short, machine understandable string that gives + the reason for condition's last transition. + type: string + status: + type: string + type: + description: PersistentVolumeClaimConditionType is + a valid value of PersistentVolumeClaimCondition.Type + type: string + required: + - status + - type + type: object + type: array + phase: + description: phase represents the current phase of PersistentVolumeClaim. + type: string + type: object + type: object + type: array + x-kubernetes-list-type: atomic + volumeMounts: + description: VolumeMounts represents the mount points to use in the + underlying collector deployment(s) + items: + description: VolumeMount describes a mounting of a Volume within + a container. + properties: + mountPath: + description: Path within the container at which the volume should + be mounted. Must not contain ':'. + type: string + mountPropagation: + description: mountPropagation determines how mounts are propagated + from the host to container and the other way around. When + not set, MountPropagationNone is used. This field is beta + in 1.10. + type: string + name: + description: This must match the Name of a Volume. + type: string + readOnly: + description: Mounted read-only if true, read-write otherwise + (false or unspecified). Defaults to false. + type: boolean + subPath: + description: Path within the volume from which the container's + volume should be mounted. Defaults to "" (volume's root). + type: string + subPathExpr: + description: Expanded path within the volume from which the + container's volume should be mounted. + type: string + required: + - mountPath + - name + type: object + type: array + x-kubernetes-list-type: atomic + volumes: + description: Volumes represents which volumes to use in the underlying + collector deployment(s). + items: + description: Volume represents a named volume in a pod that may + be accessed by any container in the pod. + properties: + awsElasticBlockStore: + description: 'awsElasticBlockStore represents an AWS Disk resource + that is attached to a kubelet''s host machine and then exposed + to the pod. More info: https://kubernetes.' + properties: + fsType: + description: 'fsType is the filesystem type of the volume + that you want to mount. Tip: Ensure that the filesystem + type is supported by the host operating system. Examples: + "ext4", "xfs", "ntfs".' + type: string + partition: + description: 'partition is the partition in the volume that + you want to mount. If omitted, the default is to mount + by volume name. Examples: For volume /dev/sda1, you specify + the partition as "1".' + format: int32 + type: integer + readOnly: + description: 'readOnly value true will force the readOnly + setting in VolumeMounts. More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore' + type: boolean + volumeID: + description: 'volumeID is unique ID of the persistent disk + resource in AWS (Amazon EBS volume). More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore' + type: string + required: + - volumeID + type: object + azureDisk: + description: azureDisk represents an Azure Data Disk mount on + the host and bind mount to the pod. + properties: + cachingMode: + description: 'cachingMode is the Host Caching mode: None, + Read Only, Read Write.' + type: string + diskName: + description: diskName is the Name of the data disk in the + blob storage + type: string + diskURI: + description: diskURI is the URI of data disk in the blob + storage + type: string + fsType: + description: fsType is Filesystem type to mount. Must be + a filesystem type supported by the host operating system. + Ex. "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" + if unspecified. + type: string + kind: + description: 'kind expected values are Shared: multiple + blob disks per storage account Dedicated: single blob + disk per storage account Managed: azure managed data + disk (only in managed availability set).' + type: string + readOnly: + description: readOnly Defaults to false (read/write). ReadOnly + here will force the ReadOnly setting in VolumeMounts. + type: boolean + required: + - diskName + - diskURI + type: object + azureFile: + description: azureFile represents an Azure File Service mount + on the host and bind mount to the pod. + properties: + readOnly: + description: readOnly defaults to false (read/write). ReadOnly + here will force the ReadOnly setting in VolumeMounts. + type: boolean + secretName: + description: secretName is the name of secret that contains + Azure Storage Account Name and Key + type: string + shareName: + description: shareName is the azure share Name + type: string + required: + - secretName + - shareName + type: object + cephfs: + description: cephFS represents a Ceph FS mount on the host that + shares a pod's lifetime + properties: + monitors: + description: 'monitors is Required: Monitors is a collection + of Ceph monitors More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it' + items: + type: string + type: array + path: + description: 'path is Optional: Used as the mounted root, + rather than the full Ceph tree, default is /' + type: string + readOnly: + description: 'readOnly is Optional: Defaults to false (read/write). + ReadOnly here will force the ReadOnly setting in VolumeMounts. + More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it' + type: boolean + secretFile: + description: 'secretFile is Optional: SecretFile is the + path to key ring for User, default is /etc/ceph/user.secret + More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it' + type: string + secretRef: + description: 'secretRef is Optional: SecretRef is reference + to the authentication secret for User, default is empty. + More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it' + properties: + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + type: object + x-kubernetes-map-type: atomic + user: + description: 'user is optional: User is the rados user name, + default is admin More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it' + type: string + required: + - monitors + type: object + cinder: + description: 'cinder represents a cinder volume attached and + mounted on kubelets host machine. More info: https://examples.k8s.io/mysql-cinder-pd/README.md' + properties: + fsType: + description: 'fsType is the filesystem type to mount. Must + be a filesystem type supported by the host operating system. + Examples: "ext4", "xfs", "ntfs". Implicitly inferred to + be "ext4" if unspecified.' + type: string + readOnly: + description: 'readOnly defaults to false (read/write). ReadOnly + here will force the ReadOnly setting in VolumeMounts. + More info: https://examples.k8s.io/mysql-cinder-pd/README.md' + type: boolean + secretRef: + description: 'secretRef is optional: points to a secret + object containing parameters used to connect to OpenStack.' + properties: + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + type: object + x-kubernetes-map-type: atomic + volumeID: + description: 'volumeID used to identify the volume in cinder. + More info: https://examples.k8s.io/mysql-cinder-pd/README.md' + type: string + required: + - volumeID + type: object + configMap: + description: configMap represents a configMap that should populate + this volume + properties: + defaultMode: + description: 'defaultMode is optional: mode bits used to + set permissions on created files by default. Must be an + octal value between 0000 and 0777 or a decimal value between + 0 and 511.' + format: int32 + type: integer + items: + description: items if unspecified, each key-value pair in + the Data field of the referenced ConfigMap will be projected + into the volume as a file whose name is the key and content + is the value. + items: + description: Maps a string key to a path within a volume. + properties: + key: + description: key is the key to project. + type: string + mode: + description: 'mode is Optional: mode bits used to + set permissions on this file. Must be an octal value + between 0000 and 0777 or a decimal value between + 0 and 511.' + format: int32 + type: integer + path: + description: path is the relative path of the file + to map the key to. May not be an absolute path. + May not contain the path element '..'. May not start + with the string '..'. + type: string + required: + - key + - path + type: object + type: array + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + optional: + description: optional specify whether the ConfigMap or its + keys must be defined + type: boolean + type: object + x-kubernetes-map-type: atomic + csi: + description: csi (Container Storage Interface) represents ephemeral + storage that is handled by certain external CSI drivers (Beta + feature). + properties: + driver: + description: driver is the name of the CSI driver that handles + this volume. Consult with your admin for the correct name + as registered in the cluster. + type: string + fsType: + description: fsType to mount. Ex. "ext4", "xfs", "ntfs". + If not provided, the empty value is passed to the associated + CSI driver which will determine the default filesystem + to apply. + type: string + nodePublishSecretRef: + description: nodePublishSecretRef is a reference to the + secret object containing sensitive information to pass + to the CSI driver to complete the CSI NodePublishVolume + and NodeUnpublishVolume calls. + properties: + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + type: object + x-kubernetes-map-type: atomic + readOnly: + description: readOnly specifies a read-only configuration + for the volume. Defaults to false (read/write). + type: boolean + volumeAttributes: + additionalProperties: + type: string + description: volumeAttributes stores driver-specific properties + that are passed to the CSI driver. Consult your driver's + documentation for supported values. + type: object + required: + - driver + type: object + downwardAPI: + description: downwardAPI represents downward API about the pod + that should populate this volume + properties: + defaultMode: + description: 'Optional: mode bits to use on created files + by default. Must be a Optional: mode bits used to set + permissions on created files by default.' + format: int32 + type: integer + items: + description: Items is a list of downward API volume file + items: + description: DownwardAPIVolumeFile represents information + to create the file containing the pod field + properties: + fieldRef: + description: 'Required: Selects a field of the pod: + only annotations, labels, name and namespace are + supported.' + properties: + apiVersion: + description: Version of the schema the FieldPath + is written in terms of, defaults to "v1". + type: string + fieldPath: + description: Path of the field to select in the + specified API version. + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + mode: + description: 'Optional: mode bits used to set permissions + on this file, must be an octal value between 0000 + and 0777 or a decimal value between 0 and 511.' + format: int32 + type: integer + path: + description: 'Required: Path is the relative path + name of the file to be created. Must not be absolute + or contain the ''..'' path. Must be utf-8 encoded. + The first item of the relative path must not start + with ''..''' + type: string + resourceFieldRef: + description: 'Selects a resource of the container: + only resources limits and requests (limits.cpu, + limits.memory, requests.cpu and requests.memory) + are currently supported.' + properties: + containerName: + description: 'Container name: required for volumes, + optional for env vars' + type: string + divisor: + anyOf: + - type: integer + - type: string + description: Specifies the output format of the + exposed resources, defaults to "1" + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to select' + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + required: + - path + type: object + type: array + type: object + emptyDir: + description: 'emptyDir represents a temporary directory that + shares a pod''s lifetime. More info: https://kubernetes.io/docs/concepts/storage/volumes#emptydir' + properties: + medium: + description: medium represents what type of storage medium + should back this directory. The default is "" which means + to use the node's default medium. Must be an empty string + (default) or Memory. + type: string + sizeLimit: + anyOf: + - type: integer + - type: string + description: sizeLimit is the total amount of local storage + required for this EmptyDir volume. The size limit is also + applicable for memory medium. + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + ephemeral: + description: ephemeral represents a volume that is handled by + a cluster storage driver. + properties: + volumeClaimTemplate: + description: Will be used to create a stand-alone PVC to + provision the volume. The pod in which this EphemeralVolumeSource + is embedded will be the owner of the PVC, i.e. + properties: + metadata: + description: May contain labels and annotations that + will be copied into the PVC when creating it. No other + fields are allowed and will be rejected during validation. + properties: + annotations: + additionalProperties: + type: string + type: object + finalizers: + items: + type: string + type: array + labels: + additionalProperties: + type: string + type: object + name: + type: string + namespace: + type: string + type: object + spec: + description: The specification for the PersistentVolumeClaim. + The entire content is copied unchanged into the PVC + that gets created from this template. + properties: + accessModes: + description: 'accessModes contains the desired access + modes the volume should have. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1' + items: + type: string + type: array + dataSource: + description: 'dataSource field can be used to specify + either: * An existing VolumeSnapshot object (snapshot.storage.k8s.' + properties: + apiGroup: + description: APIGroup is the group for the resource + being referenced. If APIGroup is not specified, + the specified Kind must be in the core API + group. For any other third-party types, APIGroup + is required. + type: string + kind: + description: Kind is the type of resource being + referenced + type: string + name: + description: Name is the name of resource being + referenced + type: string + required: + - kind + - name + type: object + x-kubernetes-map-type: atomic + dataSourceRef: + description: dataSourceRef specifies the object + from which to populate the volume with data, if + a non-empty volume is desired. + properties: + apiGroup: + description: APIGroup is the group for the resource + being referenced. If APIGroup is not specified, + the specified Kind must be in the core API + group. For any other third-party types, APIGroup + is required. + type: string + kind: + description: Kind is the type of resource being + referenced + type: string + name: + description: Name is the name of resource being + referenced + type: string + namespace: + description: Namespace is the namespace of resource + being referenced Note that when a namespace + is specified, a gateway.networking.k8s. + type: string + required: + - kind + - name + type: object + resources: + description: resources represents the minimum resources + the volume should have. + properties: + claims: + description: "Claims lists the names of resources, + defined in spec.resourceClaims, that are used + by this container. \n This is an alpha field + and requires enabling the DynamicResourceAllocation + feature gate." + items: + description: ResourceClaim references one + entry in PodSpec.ResourceClaims. + properties: + name: + description: Name must match the name + of one entry in pod.spec.resourceClaims + of the Pod where this field is used. + It makes that resource available inside + a container. + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Limits describes the maximum amount + of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: Requests describes the minimum + amount of compute resources required. + type: object + type: object + selector: + description: selector is a label query over volumes + to consider for binding. + properties: + matchExpressions: + description: matchExpressions is a list of label + selector requirements. The requirements are + ANDed. + items: + description: A label selector requirement + is a selector that contains values, a key, + and an operator that relates the key and + values. + properties: + key: + description: key is the label key that + the selector applies to. + type: string + operator: + description: operator represents a key's + relationship to a set of values. Valid + operators are In, NotIn, Exists and + DoesNotExist. + type: string + values: + description: values is an array of string + values. If the operator is In or NotIn, + the values array must be non-empty. + If the operator is Exists or DoesNotExist, + the values array must be empty. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} + pairs. + type: object + type: object + x-kubernetes-map-type: atomic + storageClassName: + description: 'storageClassName is the name of the + StorageClass required by the claim. More info: + https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1' + type: string + volumeMode: + description: volumeMode defines what type of volume + is required by the claim. Value of Filesystem + is implied when not included in claim spec. + type: string + volumeName: + description: volumeName is the binding reference + to the PersistentVolume backing this claim. + type: string + type: object + required: + - spec + type: object + type: object + fc: + description: fc represents a Fibre Channel resource that is + attached to a kubelet's host machine and then exposed to the + pod. + properties: + fsType: + description: fsType is the filesystem type to mount. Must + be a filesystem type supported by the host operating system. + Ex. "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" + if unspecified. + type: string + lun: + description: 'lun is Optional: FC target lun number' + format: int32 + type: integer + readOnly: + description: 'readOnly is Optional: Defaults to false (read/write). + ReadOnly here will force the ReadOnly setting in VolumeMounts.' + type: boolean + targetWWNs: + description: 'targetWWNs is Optional: FC target worldwide + names (WWNs)' + items: + type: string + type: array + wwids: + description: 'wwids Optional: FC volume world wide identifiers + (wwids) Either wwids or combination of targetWWNs and + lun must be set, but not both simultaneously.' + items: + type: string + type: array + type: object + flexVolume: + description: flexVolume represents a generic volume resource + that is provisioned/attached using an exec based plugin. + properties: + driver: + description: driver is the name of the driver to use for + this volume. + type: string + fsType: + description: fsType is the filesystem type to mount. Must + be a filesystem type supported by the host operating system. + Ex. "ext4", "xfs", "ntfs". The default filesystem depends + on FlexVolume script. + type: string + options: + additionalProperties: + type: string + description: 'options is Optional: this field holds extra + command options if any.' + type: object + readOnly: + description: 'readOnly is Optional: defaults to false (read/write). + ReadOnly here will force the ReadOnly setting in VolumeMounts.' + type: boolean + secretRef: + description: 'secretRef is Optional: secretRef is reference + to the secret object containing sensitive information + to pass to the plugin scripts. This may be empty if no + secret object is specified.' + properties: + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + type: object + x-kubernetes-map-type: atomic + required: + - driver + type: object + flocker: + description: flocker represents a Flocker volume attached to + a kubelet's host machine. This depends on the Flocker control + service being running + properties: + datasetName: + description: datasetName is Name of the dataset stored as + metadata -> name on the dataset for Flocker should be + considered as deprecated + type: string + datasetUUID: + description: datasetUUID is the UUID of the dataset. This + is unique identifier of a Flocker dataset + type: string + type: object + gcePersistentDisk: + description: 'gcePersistentDisk represents a GCE Disk resource + that is attached to a kubelet''s host machine and then exposed + to the pod. More info: https://kubernetes.' + properties: + fsType: + description: 'fsType is filesystem type of the volume that + you want to mount. Tip: Ensure that the filesystem type + is supported by the host operating system. Examples: "ext4", + "xfs", "ntfs".' + type: string + partition: + description: 'partition is the partition in the volume that + you want to mount. If omitted, the default is to mount + by volume name. Examples: For volume /dev/sda1, you specify + the partition as "1".' + format: int32 + type: integer + pdName: + description: 'pdName is unique name of the PD resource in + GCE. Used to identify the disk in GCE. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk' + type: string + readOnly: + description: 'readOnly here will force the ReadOnly setting + in VolumeMounts. Defaults to false. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk' + type: boolean + required: + - pdName + type: object + gitRepo: + description: 'gitRepo represents a git repository at a particular + revision. DEPRECATED: GitRepo is deprecated.' + properties: + directory: + description: directory is the target directory name. Must + not contain or start with '..'. If '.' is supplied, the + volume directory will be the git repository. + type: string + repository: + description: repository is the URL + type: string + revision: + description: revision is the commit hash for the specified + revision. + type: string + required: + - repository + type: object + glusterfs: + description: 'glusterfs represents a Glusterfs mount on the + host that shares a pod''s lifetime. More info: https://examples.k8s.io/volumes/glusterfs/README.md' + properties: + endpoints: + description: 'endpoints is the endpoint name that details + Glusterfs topology. More info: https://examples.k8s.io/volumes/glusterfs/README.md#create-a-pod' + type: string + path: + description: 'path is the Glusterfs volume path. More info: + https://examples.k8s.io/volumes/glusterfs/README.md#create-a-pod' + type: string + readOnly: + description: 'readOnly here will force the Glusterfs volume + to be mounted with read-only permissions. Defaults to + false. More info: https://examples.k8s.io/volumes/glusterfs/README.md#create-a-pod' + type: boolean + required: + - endpoints + - path + type: object + hostPath: + description: hostPath represents a pre-existing file or directory + on the host machine that is directly exposed to the container. + properties: + path: + description: 'path of the directory on the host. If the + path is a symlink, it will follow the link to the real + path. More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath' + type: string + type: + description: 'type for HostPath Volume Defaults to "" More + info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath' + type: string + required: + - path + type: object + iscsi: + description: 'iscsi represents an ISCSI Disk resource that is + attached to a kubelet''s host machine and then exposed to + the pod. More info: https://examples.k8s.io/volumes/iscsi/README.md' + properties: + chapAuthDiscovery: + description: chapAuthDiscovery defines whether support iSCSI + Discovery CHAP authentication + type: boolean + chapAuthSession: + description: chapAuthSession defines whether support iSCSI + Session CHAP authentication + type: boolean + fsType: + description: 'fsType is the filesystem type of the volume + that you want to mount. Tip: Ensure that the filesystem + type is supported by the host operating system. Examples: + "ext4", "xfs", "ntfs".' + type: string + initiatorName: + description: initiatorName is the custom iSCSI Initiator + Name. + type: string + iqn: + description: iqn is the target iSCSI Qualified Name. + type: string + iscsiInterface: + description: iscsiInterface is the interface Name that uses + an iSCSI transport. Defaults to 'default' (tcp). + type: string + lun: + description: lun represents iSCSI Target Lun number. + format: int32 + type: integer + portals: + description: portals is the iSCSI Target Portal List. The + portal is either an IP or ip_addr:port if the port is + other than default (typically TCP ports 860 and 3260). + items: + type: string + type: array + readOnly: + description: readOnly here will force the ReadOnly setting + in VolumeMounts. Defaults to false. + type: boolean + secretRef: + description: secretRef is the CHAP Secret for iSCSI target + and initiator authentication + properties: + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + type: object + x-kubernetes-map-type: atomic + targetPortal: + description: targetPortal is iSCSI Target Portal. The Portal + is either an IP or ip_addr:port if the port is other than + default (typically TCP ports 860 and 3260). + type: string + required: + - iqn + - lun + - targetPortal + type: object + name: + description: 'name of the volume. Must be a DNS_LABEL and unique + within the pod. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + nfs: + description: 'nfs represents an NFS mount on the host that shares + a pod''s lifetime More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs' + properties: + path: + description: 'path that is exported by the NFS server. More + info: https://kubernetes.io/docs/concepts/storage/volumes#nfs' + type: string + readOnly: + description: 'readOnly here will force the NFS export to + be mounted with read-only permissions. Defaults to false. + More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs' + type: boolean + server: + description: 'server is the hostname or IP address of the + NFS server. More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs' + type: string + required: + - path + - server + type: object + persistentVolumeClaim: + description: 'persistentVolumeClaimVolumeSource represents a + reference to a PersistentVolumeClaim in the same namespace. + More info: https://kubernetes.' + properties: + claimName: + description: 'claimName is the name of a PersistentVolumeClaim + in the same namespace as the pod using this volume. More + info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims' + type: string + readOnly: + description: readOnly Will force the ReadOnly setting in + VolumeMounts. Default false. + type: boolean + required: + - claimName + type: object + photonPersistentDisk: + description: photonPersistentDisk represents a PhotonController + persistent disk attached and mounted on kubelets host machine + properties: + fsType: + description: fsType is the filesystem type to mount. Must + be a filesystem type supported by the host operating system. + Ex. "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" + if unspecified. + type: string + pdID: + description: pdID is the ID that identifies Photon Controller + persistent disk + type: string + required: + - pdID + type: object + portworxVolume: + description: portworxVolume represents a portworx volume attached + and mounted on kubelets host machine + properties: + fsType: + description: fSType represents the filesystem type to mount + Must be a filesystem type supported by the host operating + system. Ex. "ext4", "xfs". Implicitly inferred to be "ext4" + if unspecified. + type: string + readOnly: + description: readOnly defaults to false (read/write). ReadOnly + here will force the ReadOnly setting in VolumeMounts. + type: boolean + volumeID: + description: volumeID uniquely identifies a Portworx volume + type: string + required: + - volumeID + type: object + projected: + description: projected items for all in one resources secrets, + configmaps, and downward API + properties: + defaultMode: + description: defaultMode are the mode bits used to set permissions + on created files by default. Must be an octal value between + 0000 and 0777 or a decimal value between 0 and 511. + format: int32 + type: integer + sources: + description: sources is the list of volume projections + items: + description: Projection that may be projected along with + other supported volume types + properties: + configMap: + description: configMap information about the configMap + data to project + properties: + items: + description: items if unspecified, each key-value + pair in the Data field of the referenced ConfigMap + will be projected into the volume as a file + whose name is the key and content is the value. + items: + description: Maps a string key to a path within + a volume. + properties: + key: + description: key is the key to project. + type: string + mode: + description: 'mode is Optional: mode bits + used to set permissions on this file. + Must be an octal value between 0000 and + 0777 or a decimal value between 0 and + 511.' + format: int32 + type: integer + path: + description: path is the relative path of + the file to map the key to. May not be + an absolute path. May not contain the + path element '..'. May not start with + the string '..'. + type: string + required: + - key + - path + type: object + type: array + name: + description: 'Name of the referent. More info: + https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: optional specify whether the ConfigMap + or its keys must be defined + type: boolean + type: object + x-kubernetes-map-type: atomic + downwardAPI: + description: downwardAPI information about the downwardAPI + data to project + properties: + items: + description: Items is a list of DownwardAPIVolume + file + items: + description: DownwardAPIVolumeFile represents + information to create the file containing + the pod field + properties: + fieldRef: + description: 'Required: Selects a field + of the pod: only annotations, labels, + name and namespace are supported.' + properties: + apiVersion: + description: Version of the schema the + FieldPath is written in terms of, + defaults to "v1". + type: string + fieldPath: + description: Path of the field to select + in the specified API version. + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + mode: + description: 'Optional: mode bits used to + set permissions on this file, must be + an octal value between 0000 and 0777 or + a decimal value between 0 and 511.' + format: int32 + type: integer + path: + description: 'Required: Path is the relative + path name of the file to be created. Must + not be absolute or contain the ''..'' + path. Must be utf-8 encoded. The first + item of the relative path must not start + with ''..''' + type: string + resourceFieldRef: + description: 'Selects a resource of the + container: only resources limits and requests + (limits.cpu, limits.memory, requests.cpu + and requests.memory) are currently supported.' + properties: + containerName: + description: 'Container name: required + for volumes, optional for env vars' + type: string + divisor: + anyOf: + - type: integer + - type: string + description: Specifies the output format + of the exposed resources, defaults + to "1" + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to + select' + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + required: + - path + type: object + type: array + type: object + secret: + description: secret information about the secret data + to project + properties: + items: + description: items if unspecified, each key-value + pair in the Data field of the referenced Secret + will be projected into the volume as a file + whose name is the key and content is the value. + items: + description: Maps a string key to a path within + a volume. + properties: + key: + description: key is the key to project. + type: string + mode: + description: 'mode is Optional: mode bits + used to set permissions on this file. + Must be an octal value between 0000 and + 0777 or a decimal value between 0 and + 511.' + format: int32 + type: integer + path: + description: path is the relative path of + the file to map the key to. May not be + an absolute path. May not contain the + path element '..'. May not start with + the string '..'. + type: string + required: + - key + - path + type: object + type: array + name: + description: 'Name of the referent. More info: + https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, + uid?' + type: string + optional: + description: optional field specify whether the + Secret or its key must be defined + type: boolean + type: object + x-kubernetes-map-type: atomic + serviceAccountToken: + description: serviceAccountToken is information about + the serviceAccountToken data to project + properties: + audience: + description: audience is the intended audience + of the token. A recipient of a token must identify + itself with an identifier specified in the audience + of the token, and otherwise should reject the + token. + type: string + expirationSeconds: + description: expirationSeconds is the requested + duration of validity of the service account + token. As the token approaches expiration, the + kubelet volume plugin will proactively rotate + the service account token. + format: int64 + type: integer + path: + description: path is the path relative to the + mount point of the file to project the token + into. + type: string + required: + - path + type: object + type: object + type: array + type: object + quobyte: + description: quobyte represents a Quobyte mount on the host + that shares a pod's lifetime + properties: + group: + description: group to map volume access to Default is no + group + type: string + readOnly: + description: readOnly here will force the Quobyte volume + to be mounted with read-only permissions. Defaults to + false. + type: boolean + registry: + description: registry represents a single or multiple Quobyte + Registry services specified as a string as host:port pair + (multiple entries are separated with commas) which acts + as the central registry for volumes + type: string + tenant: + description: tenant owning the given Quobyte volume in the + Backend Used with dynamically provisioned Quobyte volumes, + value is set by the plugin + type: string + user: + description: user to map volume access to Defaults to serivceaccount + user + type: string + volume: + description: volume is a string that references an already + created Quobyte volume by name. + type: string + required: + - registry + - volume + type: object + rbd: + description: 'rbd represents a Rados Block Device mount on the + host that shares a pod''s lifetime. More info: https://examples.k8s.io/volumes/rbd/README.md' + properties: + fsType: + description: 'fsType is the filesystem type of the volume + that you want to mount. Tip: Ensure that the filesystem + type is supported by the host operating system. Examples: + "ext4", "xfs", "ntfs".' + type: string + image: + description: 'image is the rados image name. More info: + https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it' + type: string + keyring: + description: 'keyring is the path to key ring for RBDUser. + Default is /etc/ceph/keyring. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it' + type: string + monitors: + description: 'monitors is a collection of Ceph monitors. + More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it' + items: + type: string + type: array + pool: + description: 'pool is the rados pool name. Default is rbd. + More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it' + type: string + readOnly: + description: 'readOnly here will force the ReadOnly setting + in VolumeMounts. Defaults to false. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it' + type: boolean + secretRef: + description: 'secretRef is name of the authentication secret + for RBDUser. If provided overrides keyring. Default is + nil. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it' + properties: + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + type: object + x-kubernetes-map-type: atomic + user: + description: 'user is the rados user name. Default is admin. + More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it' + type: string + required: + - image + - monitors + type: object + scaleIO: + description: scaleIO represents a ScaleIO persistent volume + attached and mounted on Kubernetes nodes. + properties: + fsType: + description: fsType is the filesystem type to mount. Must + be a filesystem type supported by the host operating system. + Ex. "ext4", "xfs", "ntfs". Default is "xfs". + type: string + gateway: + description: gateway is the host address of the ScaleIO + API Gateway. + type: string + protectionDomain: + description: protectionDomain is the name of the ScaleIO + Protection Domain for the configured storage. + type: string + readOnly: + description: readOnly Defaults to false (read/write). ReadOnly + here will force the ReadOnly setting in VolumeMounts. + type: boolean + secretRef: + description: secretRef references to the secret for ScaleIO + user and other sensitive information. If this is not provided, + Login operation will fail. + properties: + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + type: object + x-kubernetes-map-type: atomic + sslEnabled: + description: sslEnabled Flag enable/disable SSL communication + with Gateway, default false + type: boolean + storageMode: + description: storageMode indicates whether the storage for + a volume should be ThickProvisioned or ThinProvisioned. + Default is ThinProvisioned. + type: string + storagePool: + description: storagePool is the ScaleIO Storage Pool associated + with the protection domain. + type: string + system: + description: system is the name of the storage system as + configured in ScaleIO. + type: string + volumeName: + description: volumeName is the name of a volume already + created in the ScaleIO system that is associated with + this volume source. + type: string + required: + - gateway + - secretRef + - system + type: object + secret: + description: 'secret represents a secret that should populate + this volume. More info: https://kubernetes.io/docs/concepts/storage/volumes#secret' + properties: + defaultMode: + description: 'defaultMode is Optional: mode bits used to + set permissions on created files by default. Must be an + octal value between 0000 and 0777 or a decimal value between + 0 and 511.' + format: int32 + type: integer + items: + description: items If unspecified, each key-value pair in + the Data field of the referenced Secret will be projected + into the volume as a file whose name is the key and content + is the value. + items: + description: Maps a string key to a path within a volume. + properties: + key: + description: key is the key to project. + type: string + mode: + description: 'mode is Optional: mode bits used to + set permissions on this file. Must be an octal value + between 0000 and 0777 or a decimal value between + 0 and 511.' + format: int32 + type: integer + path: + description: path is the relative path of the file + to map the key to. May not be an absolute path. + May not contain the path element '..'. May not start + with the string '..'. + type: string + required: + - key + - path + type: object + type: array + optional: + description: optional field specify whether the Secret or + its keys must be defined + type: boolean + secretName: + description: 'secretName is the name of the secret in the + pod''s namespace to use. More info: https://kubernetes.io/docs/concepts/storage/volumes#secret' + type: string + type: object + storageos: + description: storageOS represents a StorageOS volume attached + and mounted on Kubernetes nodes. + properties: + fsType: + description: fsType is the filesystem type to mount. Must + be a filesystem type supported by the host operating system. + Ex. "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" + if unspecified. + type: string + readOnly: + description: readOnly defaults to false (read/write). ReadOnly + here will force the ReadOnly setting in VolumeMounts. + type: boolean + secretRef: + description: secretRef specifies the secret to use for obtaining + the StorageOS API credentials. If not specified, default + values will be attempted. + properties: + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + type: object + x-kubernetes-map-type: atomic + volumeName: + description: volumeName is the human-readable name of the + StorageOS volume. Volume names are only unique within + a namespace. + type: string + volumeNamespace: + description: volumeNamespace specifies the scope of the + volume within StorageOS. If no namespace is specified + then the Pod's namespace will be used. + type: string + type: object + vsphereVolume: + description: vsphereVolume represents a vSphere volume attached + and mounted on kubelets host machine + properties: + fsType: + description: fsType is filesystem type to mount. Must be + a filesystem type supported by the host operating system. + Ex. "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" + if unspecified. + type: string + storagePolicyID: + description: storagePolicyID is the storage Policy Based + Management (SPBM) profile ID associated with the StoragePolicyName. + type: string + storagePolicyName: + description: storagePolicyName is the storage Policy Based + Management (SPBM) profile name. + type: string + volumePath: + description: volumePath is the path that identifies vSphere + volume vmdk + type: string + required: + - volumePath + type: object + required: + - name + type: object + type: array + x-kubernetes-list-type: atomic + type: object + status: + description: OpenTelemetryCollectorStatus defines the observed state of + OpenTelemetryCollector. + properties: + image: + description: Image indicates the container image to use for the OpenTelemetry + Collector. + type: string + messages: + description: 'Messages about actions performed by the operator on + this resource. Deprecated: use Kubernetes events instead.' + items: + type: string + type: array + x-kubernetes-list-type: atomic + replicas: + description: 'Replicas is currently not being set and might be removed + in the next version. Deprecated: use "OpenTelemetryCollector.Status.Scale.Replicas" + instead.' + format: int32 + type: integer + scale: + description: Scale is the OpenTelemetryCollector's scale subresource + status. + properties: + replicas: + description: The total number non-terminated pods targeted by + this OpenTelemetryCollector's deployment or statefulSet. + format: int32 + type: integer + selector: + description: The selector used to match the OpenTelemetryCollector's + deployment or statefulSet pods. + type: string + statusReplicas: + description: StatusReplicas is the number of pods targeted by + this OpenTelemetryCollector's with a Ready Condition / Total + number of non-terminated pods targeted by this OpenTelemetryCollector's + (their labels matc + type: string + type: object + version: + description: Version of the managed OpenTelemetry Collector (operand) + type: string + type: object + type: object + served: true + storage: true + subresources: + scale: + labelSelectorPath: .status.scale.selector + specReplicasPath: .spec.replicas + statusReplicasPath: .status.scale.replicas + status: {} +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + labels: + app.kubernetes.io/name: opentelemetry-operator + name: opentelemetry-operator-controller-manager + namespace: opentelemetry-operator-system +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + labels: + app.kubernetes.io/name: opentelemetry-operator + name: opentelemetry-operator-leader-election-role + namespace: opentelemetry-operator-system +rules: + - apiGroups: + - "" + resources: + - configmaps + verbs: + - get + - list + - watch + - create + - update + - patch + - delete + - apiGroups: + - "" + resources: + - configmaps/status + verbs: + - get + - update + - patch + - apiGroups: + - "" + resources: + - events + verbs: + - create + - patch +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/name: opentelemetry-operator + name: opentelemetry-operator-manager-role +rules: + - apiGroups: + - "" + resources: + - configmaps + - serviceaccounts + - services + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - "" + resources: + - events + verbs: + - create + - patch + - apiGroups: + - "" + resources: + - namespaces + verbs: + - list + - watch + - apiGroups: + - apps + resources: + - daemonsets + - deployments + - statefulsets + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - apps + resources: + - replicasets + verbs: + - get + - list + - watch + - apiGroups: + - autoscaling + resources: + - horizontalpodautoscalers + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - coordination.k8s.io + resources: + - leases + verbs: + - create + - get + - list + - update + - apiGroups: + - monitoring.coreos.com + resources: + - servicemonitors + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - networking.k8s.io + resources: + - ingresses + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - opentelemetry.io + resources: + - instrumentations + verbs: + - get + - list + - patch + - update + - watch + - apiGroups: + - opentelemetry.io + resources: + - opentelemetrycollectors + verbs: + - get + - list + - patch + - update + - watch + - apiGroups: + - opentelemetry.io + resources: + - opentelemetrycollectors/finalizers + verbs: + - get + - patch + - update + - apiGroups: + - opentelemetry.io + resources: + - opentelemetrycollectors/status + verbs: + - get + - patch + - update + - apiGroups: + - policy + resources: + - poddisruptionbudgets + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - route.openshift.io + resources: + - routes + - routes/custom-host + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/name: opentelemetry-operator + name: opentelemetry-operator-metrics-reader +rules: + - nonResourceURLs: + - /metrics + verbs: + - get +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/name: opentelemetry-operator + name: opentelemetry-operator-proxy-role +rules: + - apiGroups: + - authentication.k8s.io + resources: + - tokenreviews + verbs: + - create + - apiGroups: + - authorization.k8s.io + resources: + - subjectaccessreviews + verbs: + - create +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + labels: + app.kubernetes.io/name: opentelemetry-operator + name: opentelemetry-operator-leader-election-rolebinding + namespace: opentelemetry-operator-system +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: opentelemetry-operator-leader-election-role +subjects: + - kind: ServiceAccount + name: opentelemetry-operator-controller-manager + namespace: opentelemetry-operator-system +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + labels: + app.kubernetes.io/name: opentelemetry-operator + name: opentelemetry-operator-manager-rolebinding +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: opentelemetry-operator-manager-role +subjects: + - kind: ServiceAccount + name: opentelemetry-operator-controller-manager + namespace: opentelemetry-operator-system +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + labels: + app.kubernetes.io/name: opentelemetry-operator + name: opentelemetry-operator-proxy-rolebinding +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: opentelemetry-operator-proxy-role +subjects: + - kind: ServiceAccount + name: opentelemetry-operator-controller-manager + namespace: opentelemetry-operator-system +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app.kubernetes.io/name: opentelemetry-operator + control-plane: controller-manager + name: opentelemetry-operator-controller-manager-metrics-service + namespace: opentelemetry-operator-system +spec: + ports: + - name: https + port: 8443 + protocol: TCP + targetPort: https + selector: + app.kubernetes.io/name: opentelemetry-operator + control-plane: controller-manager +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app.kubernetes.io/name: opentelemetry-operator + name: opentelemetry-operator-webhook-service + namespace: opentelemetry-operator-system +spec: + ports: + - port: 443 + protocol: TCP + targetPort: 9443 + selector: + app.kubernetes.io/name: opentelemetry-operator + control-plane: controller-manager +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app.kubernetes.io/name: opentelemetry-operator + control-plane: controller-manager + name: opentelemetry-operator-controller-manager + namespace: opentelemetry-operator-system +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/name: opentelemetry-operator + control-plane: controller-manager + template: + metadata: + labels: + app.kubernetes.io/name: opentelemetry-operator + control-plane: controller-manager + spec: + containers: + - args: + - --metrics-addr=127.0.0.1:8080 + - --enable-leader-election + - --zap-log-level=info + - --zap-time-encoding=rfc3339nano + - --feature-gates=+operator.autoinstrumentation.go,+operator.autoinstrumentation.nginx + image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.86.0 + livenessProbe: + httpGet: + path: /healthz + port: 8081 + initialDelaySeconds: 15 + periodSeconds: 20 + name: manager + ports: + - containerPort: 9443 + name: webhook-server + protocol: TCP + readinessProbe: + httpGet: + path: /readyz + port: 8081 + initialDelaySeconds: 5 + periodSeconds: 10 + resources: + requests: + cpu: 100m + memory: 64Mi + volumeMounts: + - mountPath: /tmp/k8s-webhook-server/serving-certs + name: cert + readOnly: true + - args: + - --secure-listen-address=0.0.0.0:8443 + - --upstream=http://127.0.0.1:8080/ + - --logtostderr=true + - --v=0 + image: gcr.io/kubebuilder/kube-rbac-proxy:v0.13.1 + name: kube-rbac-proxy + ports: + - containerPort: 8443 + name: https + protocol: TCP + resources: + limits: + cpu: 500m + memory: 128Mi + requests: + cpu: 5m + memory: 64Mi + serviceAccountName: opentelemetry-operator-controller-manager + terminationGracePeriodSeconds: 10 + volumes: + - name: cert + secret: + defaultMode: 420 + secretName: opentelemetry-operator-controller-manager-service-cert +--- +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + labels: + app.kubernetes.io/name: opentelemetry-operator + name: opentelemetry-operator-serving-cert + namespace: opentelemetry-operator-system +spec: + dnsNames: + - opentelemetry-operator-webhook-service.opentelemetry-operator-system.svc + - opentelemetry-operator-webhook-service.opentelemetry-operator-system.svc.cluster.local + issuerRef: + kind: Issuer + name: opentelemetry-operator-selfsigned-issuer + secretName: opentelemetry-operator-controller-manager-service-cert + subject: + organizationalUnits: + - opentelemetry-operator +--- +apiVersion: cert-manager.io/v1 +kind: Issuer +metadata: + labels: + app.kubernetes.io/name: opentelemetry-operator + name: opentelemetry-operator-selfsigned-issuer + namespace: opentelemetry-operator-system +spec: + selfSigned: {} +--- +apiVersion: admissionregistration.k8s.io/v1 +kind: MutatingWebhookConfiguration +metadata: + annotations: + cert-manager.io/inject-ca-from: opentelemetry-operator-system/opentelemetry-operator-serving-cert + labels: + app.kubernetes.io/name: opentelemetry-operator + name: opentelemetry-operator-mutating-webhook-configuration +webhooks: + - admissionReviewVersions: + - v1 + clientConfig: + service: + name: opentelemetry-operator-webhook-service + namespace: opentelemetry-operator-system + path: /mutate-opentelemetry-io-v1alpha1-instrumentation + failurePolicy: Fail + name: minstrumentation.kb.io + rules: + - apiGroups: + - opentelemetry.io + apiVersions: + - v1alpha1 + operations: + - CREATE + - UPDATE + resources: + - instrumentations + sideEffects: None + - admissionReviewVersions: + - v1 + clientConfig: + service: + name: opentelemetry-operator-webhook-service + namespace: opentelemetry-operator-system + path: /mutate-opentelemetry-io-v1alpha1-opentelemetrycollector + failurePolicy: Fail + name: mopentelemetrycollector.kb.io + rules: + - apiGroups: + - opentelemetry.io + apiVersions: + - v1alpha1 + operations: + - CREATE + - UPDATE + resources: + - opentelemetrycollectors + sideEffects: None + - admissionReviewVersions: + - v1 + clientConfig: + service: + name: opentelemetry-operator-webhook-service + namespace: opentelemetry-operator-system + path: /mutate-v1-pod + failurePolicy: Ignore + name: mpod.kb.io + rules: + - apiGroups: + - "" + apiVersions: + - v1 + operations: + - CREATE + - UPDATE + resources: + - pods + sideEffects: None +--- +apiVersion: admissionregistration.k8s.io/v1 +kind: ValidatingWebhookConfiguration +metadata: + annotations: + cert-manager.io/inject-ca-from: opentelemetry-operator-system/opentelemetry-operator-serving-cert + labels: + app.kubernetes.io/name: opentelemetry-operator + name: opentelemetry-operator-validating-webhook-configuration +webhooks: + - admissionReviewVersions: + - v1 + clientConfig: + service: + name: opentelemetry-operator-webhook-service + namespace: opentelemetry-operator-system + path: /validate-opentelemetry-io-v1alpha1-instrumentation + failurePolicy: Fail + name: vinstrumentationcreateupdate.kb.io + rules: + - apiGroups: + - opentelemetry.io + apiVersions: + - v1alpha1 + operations: + - CREATE + - UPDATE + resources: + - instrumentations + sideEffects: None + - admissionReviewVersions: + - v1 + clientConfig: + service: + name: opentelemetry-operator-webhook-service + namespace: opentelemetry-operator-system + path: /validate-opentelemetry-io-v1alpha1-instrumentation + failurePolicy: Ignore + name: vinstrumentationdelete.kb.io + rules: + - apiGroups: + - opentelemetry.io + apiVersions: + - v1alpha1 + operations: + - DELETE + resources: + - instrumentations + sideEffects: None + - admissionReviewVersions: + - v1 + clientConfig: + service: + name: opentelemetry-operator-webhook-service + namespace: opentelemetry-operator-system + path: /validate-opentelemetry-io-v1alpha1-opentelemetrycollector + failurePolicy: Fail + name: vopentelemetrycollectorcreateupdate.kb.io + rules: + - apiGroups: + - opentelemetry.io + apiVersions: + - v1alpha1 + operations: + - CREATE + - UPDATE + resources: + - opentelemetrycollectors + sideEffects: None + - admissionReviewVersions: + - v1 + clientConfig: + service: + name: opentelemetry-operator-webhook-service + namespace: opentelemetry-operator-system + path: /validate-opentelemetry-io-v1alpha1-opentelemetrycollector + failurePolicy: Ignore + name: vopentelemetrycollectordelete.kb.io + rules: + - apiGroups: + - opentelemetry.io + apiVersions: + - v1alpha1 + operations: + - DELETE + resources: + - opentelemetrycollectors + sideEffects: None From d321f55ef373ab7f85076b7c553eb7bb303ba1e3 Mon Sep 17 00:00:00 2001 From: Jacob Aronoff Date: Thu, 12 Oct 2023 11:35:42 -0400 Subject: [PATCH 10/15] oops --- config/manager/kustomization.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index dc4d5229f4..5c5f0b84cb 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -1,8 +1,2 @@ resources: - manager.yaml -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -images: -- name: controller - newName: ghcr.io/jacob.aronoff/opentelemetry-operator/opentelemetry-operator - newTag: e2e From 49856b998f3d7ff38970b01d3ea7128f8ce87861 Mon Sep 17 00:00:00 2001 From: Jacob Aronoff Date: Thu, 12 Oct 2023 17:34:56 -0400 Subject: [PATCH 11/15] move things back --- .../v1alpha1/collector_webhook.go | 80 ++-- .../v1alpha1/collector_webhook_test.go | 341 +++++++++--------- .../v1alpha1/instrumentation_webhook.go | 48 ++- .../v1alpha1/instrumentation_webhook_test.go | 75 ++-- controllers/suite_test.go | 3 +- .../sidecar/webhookhandler_suite_test.go | 3 +- main.go | 6 +- pkg/collector/reconcile/suite_test.go | 3 +- pkg/collector/upgrade/suite_test.go | 3 +- pkg/instrumentation/upgrade/upgrade_test.go | 3 +- 10 files changed, 274 insertions(+), 291 deletions(-) rename internal/webhook/collector/webhook.go => apis/v1alpha1/collector_webhook.go (81%) rename internal/webhook/collector/webhook_test.go => apis/v1alpha1/collector_webhook_test.go (66%) rename internal/webhook/instrumentation/webhook.go => apis/v1alpha1/instrumentation_webhook.go (87%) rename internal/webhook/instrumentation/webhook_test.go => apis/v1alpha1/instrumentation_webhook_test.go (70%) diff --git a/internal/webhook/collector/webhook.go b/apis/v1alpha1/collector_webhook.go similarity index 81% rename from internal/webhook/collector/webhook.go rename to apis/v1alpha1/collector_webhook.go index 2224ba85c7..ca16bc4589 100644 --- a/internal/webhook/collector/webhook.go +++ b/apis/v1alpha1/collector_webhook.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package collectorwebhook +package v1alpha1 import ( "context" @@ -26,68 +26,64 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" "github.com/open-telemetry/opentelemetry-operator/internal/config" ta "github.com/open-telemetry/opentelemetry-operator/internal/manifests/targetallocator/adapters" "github.com/open-telemetry/opentelemetry-operator/pkg/featuregate" ) var ( - _ admission.CustomValidator = &Webhook{} - _ admission.CustomDefaulter = &Webhook{} + _ admission.CustomValidator = &CollectorWebhook{} + _ admission.CustomDefaulter = &CollectorWebhook{} ) // +kubebuilder:webhook:path=/mutate-opentelemetry-io-v1alpha1-opentelemetrycollector,mutating=true,failurePolicy=fail,groups=opentelemetry.io,resources=opentelemetrycollectors,verbs=create;update,versions=v1alpha1,name=mopentelemetrycollector.kb.io,sideEffects=none,admissionReviewVersions=v1 // +kubebuilder:webhook:verbs=create;update,path=/validate-opentelemetry-io-v1alpha1-opentelemetrycollector,mutating=false,failurePolicy=fail,groups=opentelemetry.io,resources=opentelemetrycollectors,versions=v1alpha1,name=vopentelemetrycollectorcreateupdate.kb.io,sideEffects=none,admissionReviewVersions=v1 // +kubebuilder:webhook:verbs=delete,path=/validate-opentelemetry-io-v1alpha1-opentelemetrycollector,mutating=false,failurePolicy=ignore,groups=opentelemetry.io,resources=opentelemetrycollectors,versions=v1alpha1,name=vopentelemetrycollectordelete.kb.io,sideEffects=none,admissionReviewVersions=v1 -// Webhook is isolated because there are known registration issues when a custom webhook is in the same package -// as the types. -// See here: https://github.com/kubernetes-sigs/controller-runtime/issues/780#issuecomment-713408479 -type Webhook struct { +type CollectorWebhook struct { logger logr.Logger cfg config.Config scheme *runtime.Scheme } -func (c Webhook) Default(ctx context.Context, obj runtime.Object) error { - otelcol, ok := obj.(*v1alpha1.OpenTelemetryCollector) +func (c CollectorWebhook) Default(ctx context.Context, obj runtime.Object) error { + otelcol, ok := obj.(*OpenTelemetryCollector) if !ok { return fmt.Errorf("expected an OpenTelemetryCollector, received %T", obj) } return c.defaulter(otelcol) } -func (c Webhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { - otelcol, ok := obj.(*v1alpha1.OpenTelemetryCollector) +func (c CollectorWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { + otelcol, ok := obj.(*OpenTelemetryCollector) if !ok { return nil, fmt.Errorf("expected an OpenTelemetryCollector, received %T", obj) } return c.validate(otelcol) } -func (c Webhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { - otelcol, ok := newObj.(*v1alpha1.OpenTelemetryCollector) +func (c CollectorWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { + otelcol, ok := newObj.(*OpenTelemetryCollector) if !ok { return nil, fmt.Errorf("expected an OpenTelemetryCollector, received %T", newObj) } return c.validate(otelcol) } -func (c Webhook) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { - otelcol, ok := obj.(*v1alpha1.OpenTelemetryCollector) +func (c CollectorWebhook) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { + otelcol, ok := obj.(*OpenTelemetryCollector) if !ok || otelcol == nil { return nil, fmt.Errorf("expected an OpenTelemetryCollector, received %T", obj) } return c.validate(otelcol) } -func (c Webhook) defaulter(r *v1alpha1.OpenTelemetryCollector) error { +func (c CollectorWebhook) defaulter(r *OpenTelemetryCollector) error { if len(r.Spec.Mode) == 0 { - r.Spec.Mode = v1alpha1.ModeDeployment + r.Spec.Mode = ModeDeployment } if len(r.Spec.UpgradeStrategy) == 0 { - r.Spec.UpgradeStrategy = v1alpha1.UpgradeStrategyAutomatic + r.Spec.UpgradeStrategy = UpgradeStrategyAutomatic } if r.Labels == nil { @@ -109,7 +105,7 @@ func (c Webhook) defaulter(r *v1alpha1.OpenTelemetryCollector) error { if r.Spec.MaxReplicas != nil || (r.Spec.Autoscaler != nil && r.Spec.Autoscaler.MaxReplicas != nil) { if r.Spec.Autoscaler == nil { - r.Spec.Autoscaler = &v1alpha1.AutoscalerSpec{} + r.Spec.Autoscaler = &AutoscalerSpec{} } if r.Spec.Autoscaler.MaxReplicas == nil { @@ -134,7 +130,7 @@ func (c Webhook) defaulter(r *v1alpha1.OpenTelemetryCollector) error { // not blocking node drains but preventing out-of-the-box // from disruption generated by them with replicas > 1 if r.Spec.PodDisruptionBudget == nil { - r.Spec.PodDisruptionBudget = &v1alpha1.PodDisruptionBudgetSpec{ + r.Spec.PodDisruptionBudget = &PodDisruptionBudgetSpec{ MaxUnavailable: &intstr.IntOrString{ Type: intstr.Int, IntVal: 1, @@ -142,48 +138,48 @@ func (c Webhook) defaulter(r *v1alpha1.OpenTelemetryCollector) error { } } - if r.Spec.Ingress.Type == v1alpha1.IngressTypeRoute && r.Spec.Ingress.Route.Termination == "" { - r.Spec.Ingress.Route.Termination = v1alpha1.TLSRouteTerminationTypeEdge + if r.Spec.Ingress.Type == IngressTypeRoute && r.Spec.Ingress.Route.Termination == "" { + r.Spec.Ingress.Route.Termination = TLSRouteTerminationTypeEdge } - if r.Spec.Ingress.Type == v1alpha1.IngressTypeNginx && r.Spec.Ingress.RuleType == "" { - r.Spec.Ingress.RuleType = v1alpha1.IngressRuleTypePath + if r.Spec.Ingress.Type == IngressTypeNginx && r.Spec.Ingress.RuleType == "" { + r.Spec.Ingress.RuleType = IngressRuleTypePath } // If someone upgrades to a later version without upgrading their CRD they will not have a management state set. // This results in a default state of unmanaged preventing reconciliation from continuing. if len(r.Spec.ManagementState) == 0 { - r.Spec.ManagementState = v1alpha1.ManagementStateManaged + r.Spec.ManagementState = ManagementStateManaged } return nil } -func (c Webhook) validate(r *v1alpha1.OpenTelemetryCollector) (admission.Warnings, error) { +func (c CollectorWebhook) validate(r *OpenTelemetryCollector) (admission.Warnings, error) { warnings := admission.Warnings{} // validate volumeClaimTemplates - if r.Spec.Mode != v1alpha1.ModeStatefulSet && len(r.Spec.VolumeClaimTemplates) > 0 { + if r.Spec.Mode != ModeStatefulSet && len(r.Spec.VolumeClaimTemplates) > 0 { return warnings, fmt.Errorf("the OpenTelemetry Collector mode is set to %s, which does not support the attribute 'volumeClaimTemplates'", r.Spec.Mode) } // validate tolerations - if r.Spec.Mode == v1alpha1.ModeSidecar && len(r.Spec.Tolerations) > 0 { + if r.Spec.Mode == ModeSidecar && len(r.Spec.Tolerations) > 0 { return warnings, fmt.Errorf("the OpenTelemetry Collector mode is set to %s, which does not support the attribute 'tolerations'", r.Spec.Mode) } // validate priorityClassName - if r.Spec.Mode == v1alpha1.ModeSidecar && r.Spec.PriorityClassName != "" { + if r.Spec.Mode == ModeSidecar && r.Spec.PriorityClassName != "" { return warnings, fmt.Errorf("the OpenTelemetry Collector mode is set to %s, which does not support the attribute 'priorityClassName'", r.Spec.Mode) } // validate affinity - if r.Spec.Mode == v1alpha1.ModeSidecar && r.Spec.Affinity != nil { + if r.Spec.Mode == ModeSidecar && r.Spec.Affinity != nil { return warnings, fmt.Errorf("the OpenTelemetry Collector mode is set to %s, which does not support the attribute 'affinity'", r.Spec.Mode) } - if r.Spec.Mode == v1alpha1.ModeSidecar && len(r.Spec.AdditionalContainers) > 0 { + if r.Spec.Mode == ModeSidecar && len(r.Spec.AdditionalContainers) > 0 { return warnings, fmt.Errorf("the OpenTelemetry Collector mode is set to %s, which does not support the attribute 'AdditionalContainers'", r.Spec.Mode) } // validate target allocation - if r.Spec.TargetAllocator.Enabled && r.Spec.Mode != v1alpha1.ModeStatefulSet { + if r.Spec.TargetAllocator.Enabled && r.Spec.Mode != ModeStatefulSet { return warnings, fmt.Errorf("the OpenTelemetry Collector mode is set to %s, which does not support the target allocation deployment", r.Spec.Mode) } @@ -239,9 +235,9 @@ func (c Webhook) validate(r *v1alpha1.OpenTelemetryCollector) (admission.Warning } } - if r.Spec.Ingress.Type == v1alpha1.IngressTypeNginx && r.Spec.Mode == v1alpha1.ModeSidecar { + if r.Spec.Ingress.Type == IngressTypeNginx && r.Spec.Mode == ModeSidecar { return warnings, fmt.Errorf("the OpenTelemetry Spec Ingress configuration is incorrect. Ingress can only be used in combination with the modes: %s, %s, %s", - v1alpha1.ModeDeployment, v1alpha1.ModeDaemonSet, v1alpha1.ModeStatefulSet, + ModeDeployment, ModeDaemonSet, ModeStatefulSet, ) } @@ -268,12 +264,12 @@ func (c Webhook) validate(r *v1alpha1.OpenTelemetryCollector) (admission.Warning } } - if r.Spec.Ingress.Type == v1alpha1.IngressTypeNginx && r.Spec.Mode == v1alpha1.ModeSidecar { + if r.Spec.Ingress.Type == IngressTypeNginx && r.Spec.Mode == ModeSidecar { return warnings, fmt.Errorf("the OpenTelemetry Spec Ingress configuiration is incorrect. Ingress can only be used in combination with the modes: %s, %s, %s", - v1alpha1.ModeDeployment, v1alpha1.ModeDaemonSet, v1alpha1.ModeStatefulSet, + ModeDeployment, ModeDaemonSet, ModeStatefulSet, ) } - if r.Spec.Ingress.RuleType == v1alpha1.IngressRuleTypeSubdomain && (r.Spec.Ingress.Hostname == "" || r.Spec.Ingress.Hostname == "*") { + if r.Spec.Ingress.RuleType == IngressRuleTypeSubdomain && (r.Spec.Ingress.Hostname == "" || r.Spec.Ingress.Hostname == "*") { return warnings, fmt.Errorf("a valid Ingress hostname has to be defined for subdomain ruleType") } @@ -301,7 +297,7 @@ func (c Webhook) validate(r *v1alpha1.OpenTelemetryCollector) (admission.Warning return warnings, nil } -func checkAutoscalerSpec(autoscaler *v1alpha1.AutoscalerSpec) error { +func checkAutoscalerSpec(autoscaler *AutoscalerSpec) error { if autoscaler.Behavior != nil { if autoscaler.Behavior.ScaleDown != nil && autoscaler.Behavior.ScaleDown.StabilizationWindowSeconds != nil && *autoscaler.Behavior.ScaleDown.StabilizationWindowSeconds < int32(1) { @@ -342,14 +338,14 @@ func checkAutoscalerSpec(autoscaler *v1alpha1.AutoscalerSpec) error { return nil } -func SetupWebhook(mgr ctrl.Manager, cfg config.Config) error { - cvw := &Webhook{ +func SetupCollectorWebhook(mgr ctrl.Manager, cfg config.Config) error { + cvw := &CollectorWebhook{ logger: mgr.GetLogger().WithValues("handler", "CollectorWebhook"), scheme: mgr.GetScheme(), cfg: cfg, } return ctrl.NewWebhookManagedBy(mgr). - For(&v1alpha1.OpenTelemetryCollector{}). + For(&OpenTelemetryCollector{}). WithValidator(cvw). WithDefaulter(cvw). Complete() diff --git a/internal/webhook/collector/webhook_test.go b/apis/v1alpha1/collector_webhook_test.go similarity index 66% rename from internal/webhook/collector/webhook_test.go rename to apis/v1alpha1/collector_webhook_test.go index bce735e085..0f23134717 100644 --- a/internal/webhook/collector/webhook_test.go +++ b/apis/v1alpha1/collector_webhook_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package collectorwebhook +package v1alpha1 import ( "context" @@ -30,7 +30,6 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/client-go/kubernetes/scheme" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" "github.com/open-telemetry/opentelemetry-operator/internal/config" ) @@ -43,31 +42,31 @@ func TestOTELColDefaultingWebhook(t *testing.T) { five := int32(5) defaultCPUTarget := int32(90) - if err := v1alpha1.AddToScheme(testScheme); err != nil { + if err := AddToScheme(testScheme); err != nil { fmt.Printf("failed to register scheme: %v", err) os.Exit(1) } tests := []struct { name string - otelcol v1alpha1.OpenTelemetryCollector - expected v1alpha1.OpenTelemetryCollector + otelcol OpenTelemetryCollector + expected OpenTelemetryCollector }{ { name: "all fields default", - otelcol: v1alpha1.OpenTelemetryCollector{}, - expected: v1alpha1.OpenTelemetryCollector{ + otelcol: OpenTelemetryCollector{}, + expected: OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{ "app.kubernetes.io/managed-by": "opentelemetry-operator", }, }, - Spec: v1alpha1.OpenTelemetryCollectorSpec{ - Mode: v1alpha1.ModeDeployment, + Spec: OpenTelemetryCollectorSpec{ + Mode: ModeDeployment, Replicas: &one, - UpgradeStrategy: v1alpha1.UpgradeStrategyAutomatic, - ManagementState: v1alpha1.ManagementStateManaged, - PodDisruptionBudget: &v1alpha1.PodDisruptionBudgetSpec{ + UpgradeStrategy: UpgradeStrategyAutomatic, + ManagementState: ManagementStateManaged, + PodDisruptionBudget: &PodDisruptionBudgetSpec{ MaxUnavailable: &intstr.IntOrString{ Type: intstr.Int, IntVal: 1, @@ -78,25 +77,25 @@ func TestOTELColDefaultingWebhook(t *testing.T) { }, { name: "provided values in spec", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ - Mode: v1alpha1.ModeSidecar, + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ + Mode: ModeSidecar, Replicas: &five, UpgradeStrategy: "adhoc", }, }, - expected: v1alpha1.OpenTelemetryCollector{ + expected: OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{ "app.kubernetes.io/managed-by": "opentelemetry-operator", }, }, - Spec: v1alpha1.OpenTelemetryCollectorSpec{ - Mode: v1alpha1.ModeSidecar, + Spec: OpenTelemetryCollectorSpec{ + Mode: ModeSidecar, Replicas: &five, UpgradeStrategy: "adhoc", - ManagementState: v1alpha1.ManagementStateManaged, - PodDisruptionBudget: &v1alpha1.PodDisruptionBudgetSpec{ + ManagementState: ManagementStateManaged, + PodDisruptionBudget: &PodDisruptionBudgetSpec{ MaxUnavailable: &intstr.IntOrString{ Type: intstr.Int, IntVal: 1, @@ -107,26 +106,26 @@ func TestOTELColDefaultingWebhook(t *testing.T) { }, { name: "doesn't override unmanaged", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ - ManagementState: v1alpha1.ManagementStateUnmanaged, - Mode: v1alpha1.ModeSidecar, + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ + ManagementState: ManagementStateUnmanaged, + Mode: ModeSidecar, Replicas: &five, UpgradeStrategy: "adhoc", }, }, - expected: v1alpha1.OpenTelemetryCollector{ + expected: OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{ "app.kubernetes.io/managed-by": "opentelemetry-operator", }, }, - Spec: v1alpha1.OpenTelemetryCollectorSpec{ - Mode: v1alpha1.ModeSidecar, + Spec: OpenTelemetryCollectorSpec{ + Mode: ModeSidecar, Replicas: &five, UpgradeStrategy: "adhoc", - ManagementState: v1alpha1.ManagementStateUnmanaged, - PodDisruptionBudget: &v1alpha1.PodDisruptionBudgetSpec{ + ManagementState: ManagementStateUnmanaged, + PodDisruptionBudget: &PodDisruptionBudgetSpec{ MaxUnavailable: &intstr.IntOrString{ Type: intstr.Int, IntVal: 1, @@ -137,31 +136,31 @@ func TestOTELColDefaultingWebhook(t *testing.T) { }, { name: "Setting Autoscaler MaxReplicas", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ - Autoscaler: &v1alpha1.AutoscalerSpec{ + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ + Autoscaler: &AutoscalerSpec{ MaxReplicas: &five, MinReplicas: &one, }, }, }, - expected: v1alpha1.OpenTelemetryCollector{ + expected: OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{ "app.kubernetes.io/managed-by": "opentelemetry-operator", }, }, - Spec: v1alpha1.OpenTelemetryCollectorSpec{ - Mode: v1alpha1.ModeDeployment, + Spec: OpenTelemetryCollectorSpec{ + Mode: ModeDeployment, Replicas: &one, - UpgradeStrategy: v1alpha1.UpgradeStrategyAutomatic, - ManagementState: v1alpha1.ManagementStateManaged, - Autoscaler: &v1alpha1.AutoscalerSpec{ + UpgradeStrategy: UpgradeStrategyAutomatic, + ManagementState: ManagementStateManaged, + Autoscaler: &AutoscalerSpec{ TargetCPUUtilization: &defaultCPUTarget, MaxReplicas: &five, MinReplicas: &one, }, - PodDisruptionBudget: &v1alpha1.PodDisruptionBudgetSpec{ + PodDisruptionBudget: &PodDisruptionBudgetSpec{ MaxUnavailable: &intstr.IntOrString{ Type: intstr.Int, IntVal: 1, @@ -172,23 +171,23 @@ func TestOTELColDefaultingWebhook(t *testing.T) { }, { name: "MaxReplicas but no Autoscale", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ MaxReplicas: &five, }, }, - expected: v1alpha1.OpenTelemetryCollector{ + expected: OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{ "app.kubernetes.io/managed-by": "opentelemetry-operator", }, }, - Spec: v1alpha1.OpenTelemetryCollectorSpec{ - Mode: v1alpha1.ModeDeployment, + Spec: OpenTelemetryCollectorSpec{ + Mode: ModeDeployment, Replicas: &one, - UpgradeStrategy: v1alpha1.UpgradeStrategyAutomatic, - ManagementState: v1alpha1.ManagementStateManaged, - Autoscaler: &v1alpha1.AutoscalerSpec{ + UpgradeStrategy: UpgradeStrategyAutomatic, + ManagementState: ManagementStateManaged, + Autoscaler: &AutoscalerSpec{ TargetCPUUtilization: &defaultCPUTarget, // webhook Default adds MaxReplicas to Autoscaler because // OpenTelemetryCollector.Spec.MaxReplicas is deprecated. @@ -196,7 +195,7 @@ func TestOTELColDefaultingWebhook(t *testing.T) { MinReplicas: &one, }, MaxReplicas: &five, - PodDisruptionBudget: &v1alpha1.PodDisruptionBudgetSpec{ + PodDisruptionBudget: &PodDisruptionBudgetSpec{ MaxUnavailable: &intstr.IntOrString{ Type: intstr.Int, IntVal: 1, @@ -207,32 +206,32 @@ func TestOTELColDefaultingWebhook(t *testing.T) { }, { name: "Missing route termination", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ - Mode: v1alpha1.ModeDeployment, - Ingress: v1alpha1.Ingress{ - Type: v1alpha1.IngressTypeRoute, + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ + Mode: ModeDeployment, + Ingress: Ingress{ + Type: IngressTypeRoute, }, }, }, - expected: v1alpha1.OpenTelemetryCollector{ + expected: OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{ "app.kubernetes.io/managed-by": "opentelemetry-operator", }, }, - Spec: v1alpha1.OpenTelemetryCollectorSpec{ - Mode: v1alpha1.ModeDeployment, - ManagementState: v1alpha1.ManagementStateManaged, - Ingress: v1alpha1.Ingress{ - Type: v1alpha1.IngressTypeRoute, - Route: v1alpha1.OpenShiftRoute{ - Termination: v1alpha1.TLSRouteTerminationTypeEdge, + Spec: OpenTelemetryCollectorSpec{ + Mode: ModeDeployment, + ManagementState: ManagementStateManaged, + Ingress: Ingress{ + Type: IngressTypeRoute, + Route: OpenShiftRoute{ + Termination: TLSRouteTerminationTypeEdge, }, }, Replicas: &one, - UpgradeStrategy: v1alpha1.UpgradeStrategyAutomatic, - PodDisruptionBudget: &v1alpha1.PodDisruptionBudgetSpec{ + UpgradeStrategy: UpgradeStrategyAutomatic, + PodDisruptionBudget: &PodDisruptionBudgetSpec{ MaxUnavailable: &intstr.IntOrString{ Type: intstr.Int, IntVal: 1, @@ -243,10 +242,10 @@ func TestOTELColDefaultingWebhook(t *testing.T) { }, { name: "Defined PDB", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ - Mode: v1alpha1.ModeDeployment, - PodDisruptionBudget: &v1alpha1.PodDisruptionBudgetSpec{ + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ + Mode: ModeDeployment, + PodDisruptionBudget: &PodDisruptionBudgetSpec{ MinAvailable: &intstr.IntOrString{ Type: intstr.String, StrVal: "10%", @@ -254,18 +253,18 @@ func TestOTELColDefaultingWebhook(t *testing.T) { }, }, }, - expected: v1alpha1.OpenTelemetryCollector{ + expected: OpenTelemetryCollector{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{ "app.kubernetes.io/managed-by": "opentelemetry-operator", }, }, - Spec: v1alpha1.OpenTelemetryCollectorSpec{ - Mode: v1alpha1.ModeDeployment, + Spec: OpenTelemetryCollectorSpec{ + Mode: ModeDeployment, Replicas: &one, - UpgradeStrategy: v1alpha1.UpgradeStrategyAutomatic, - ManagementState: v1alpha1.ManagementStateManaged, - PodDisruptionBudget: &v1alpha1.PodDisruptionBudgetSpec{ + UpgradeStrategy: UpgradeStrategyAutomatic, + ManagementState: ManagementStateManaged, + PodDisruptionBudget: &PodDisruptionBudgetSpec{ MinAvailable: &intstr.IntOrString{ Type: intstr.String, StrVal: "10%", @@ -278,7 +277,7 @@ func TestOTELColDefaultingWebhook(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - cvw := &Webhook{ + cvw := &CollectorWebhook{ logger: logr.Discard(), scheme: testScheme, cfg: config.New( @@ -307,24 +306,24 @@ func TestOTELColValidatingWebhook(t *testing.T) { tests := []struct { //nolint:govet name string - otelcol v1alpha1.OpenTelemetryCollector + otelcol OpenTelemetryCollector expectedErr string expectedWarnings []string }{ { name: "valid empty spec", - otelcol: v1alpha1.OpenTelemetryCollector{}, + otelcol: OpenTelemetryCollector{}, }, { name: "valid full spec", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ - Mode: v1alpha1.ModeStatefulSet, + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ + Mode: ModeStatefulSet, MinReplicas: &one, Replicas: &three, MaxReplicas: &five, UpgradeStrategy: "adhoc", - TargetAllocator: v1alpha1.OpenTelemetryTargetAllocator{ + TargetAllocator: OpenTelemetryTargetAllocator{ Enabled: true, }, Config: `receivers: @@ -353,7 +352,7 @@ func TestOTELColValidatingWebhook(t *testing.T) { Protocol: v1.ProtocolUDP, }, }, - Autoscaler: &v1alpha1.AutoscalerSpec{ + Autoscaler: &AutoscalerSpec{ Behavior: &autoscalingv2.HorizontalPodAutoscalerBehavior{ ScaleDown: &autoscalingv2.HPAScalingRules{ StabilizationWindowSeconds: &three, @@ -369,9 +368,9 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid mode with volume claim templates", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ - Mode: v1alpha1.ModeSidecar, + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ + Mode: ModeSidecar, VolumeClaimTemplates: []v1.PersistentVolumeClaim{{}, {}}, }, }, @@ -379,9 +378,9 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid mode with tolerations", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ - Mode: v1alpha1.ModeSidecar, + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ + Mode: ModeSidecar, Tolerations: []v1.Toleration{{}, {}}, }, }, @@ -389,10 +388,10 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid mode with target allocator", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ - Mode: v1alpha1.ModeDeployment, - TargetAllocator: v1alpha1.OpenTelemetryTargetAllocator{ + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ + Mode: ModeDeployment, + TargetAllocator: OpenTelemetryTargetAllocator{ Enabled: true, }, }, @@ -401,10 +400,10 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid target allocator config", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ - Mode: v1alpha1.ModeStatefulSet, - TargetAllocator: v1alpha1.OpenTelemetryTargetAllocator{ + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ + Mode: ModeStatefulSet, + TargetAllocator: OpenTelemetryTargetAllocator{ Enabled: true, }, }, @@ -413,8 +412,8 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid port name", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ Ports: []v1.ServicePort{ { // this port name contains a non alphanumeric character, which is invalid. @@ -429,8 +428,8 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid port name, too long", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ Ports: []v1.ServicePort{ { Name: "aaaabbbbccccdddd", // len: 16, too long @@ -443,8 +442,8 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid port num", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ Ports: []v1.ServicePort{ { Name: "aaaabbbbccccddd", // len: 15 @@ -457,8 +456,8 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid max replicas", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ MaxReplicas: &zero, }, }, @@ -467,8 +466,8 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid replicas, greater than max", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ MaxReplicas: &three, Replicas: &five, }, @@ -478,8 +477,8 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid min replicas, greater than max", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ MaxReplicas: &three, MinReplicas: &five, }, @@ -489,8 +488,8 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid min replicas, lesser than 1", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ MaxReplicas: &three, MinReplicas: &zero, }, @@ -500,10 +499,10 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid autoscaler scale down", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ MaxReplicas: &three, - Autoscaler: &v1alpha1.AutoscalerSpec{ + Autoscaler: &AutoscalerSpec{ Behavior: &autoscalingv2.HorizontalPodAutoscalerBehavior{ ScaleDown: &autoscalingv2.HPAScalingRules{ StabilizationWindowSeconds: &zero, @@ -517,10 +516,10 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid autoscaler scale up", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ MaxReplicas: &three, - Autoscaler: &v1alpha1.AutoscalerSpec{ + Autoscaler: &AutoscalerSpec{ Behavior: &autoscalingv2.HorizontalPodAutoscalerBehavior{ ScaleUp: &autoscalingv2.HPAScalingRules{ StabilizationWindowSeconds: &zero, @@ -534,10 +533,10 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid autoscaler target cpu utilization", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ MaxReplicas: &three, - Autoscaler: &v1alpha1.AutoscalerSpec{ + Autoscaler: &AutoscalerSpec{ TargetCPUUtilization: &zero, }, }, @@ -547,9 +546,9 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "autoscaler minReplicas is less than maxReplicas", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ - Autoscaler: &v1alpha1.AutoscalerSpec{ + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ + Autoscaler: &AutoscalerSpec{ MaxReplicas: &one, MinReplicas: &five, }, @@ -559,11 +558,11 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid autoscaler metric type", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ MaxReplicas: &three, - Autoscaler: &v1alpha1.AutoscalerSpec{ - Metrics: []v1alpha1.MetricSpec{ + Autoscaler: &AutoscalerSpec{ + Metrics: []MetricSpec{ { Type: autoscalingv2.ResourceMetricSourceType, }, @@ -576,11 +575,11 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid pod metric average value", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ MaxReplicas: &three, - Autoscaler: &v1alpha1.AutoscalerSpec{ - Metrics: []v1alpha1.MetricSpec{ + Autoscaler: &AutoscalerSpec{ + Metrics: []MetricSpec{ { Type: autoscalingv2.PodsMetricSourceType, Pods: &autoscalingv2.PodsMetricSource{ @@ -602,11 +601,11 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "utilization target is not valid with pod metrics", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ MaxReplicas: &three, - Autoscaler: &v1alpha1.AutoscalerSpec{ - Metrics: []v1alpha1.MetricSpec{ + Autoscaler: &AutoscalerSpec{ + Metrics: []MetricSpec{ { Type: autoscalingv2.PodsMetricSourceType, Pods: &autoscalingv2.PodsMetricSource{ @@ -628,23 +627,23 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid deployment mode incompabible with ingress settings", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ - Mode: v1alpha1.ModeSidecar, - Ingress: v1alpha1.Ingress{ - Type: v1alpha1.IngressTypeNginx, + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ + Mode: ModeSidecar, + Ingress: Ingress{ + Type: IngressTypeNginx, }, }, }, expectedErr: fmt.Sprintf("Ingress can only be used in combination with the modes: %s, %s, %s", - v1alpha1.ModeDeployment, v1alpha1.ModeDaemonSet, v1alpha1.ModeStatefulSet, + ModeDeployment, ModeDaemonSet, ModeStatefulSet, ), }, { name: "invalid mode with priorityClassName", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ - Mode: v1alpha1.ModeSidecar, + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ + Mode: ModeSidecar, PriorityClassName: "test-class", }, }, @@ -652,9 +651,9 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid mode with affinity", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ - Mode: v1alpha1.ModeSidecar, + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ + Mode: ModeSidecar, Affinity: &v1.Affinity{ NodeAffinity: &v1.NodeAffinity{ RequiredDuringSchedulingIgnoredDuringExecution: &v1.NodeSelector{ @@ -678,9 +677,9 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid InitialDelaySeconds", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ - LivenessProbe: &v1alpha1.Probe{ + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ + LivenessProbe: &Probe{ InitialDelaySeconds: &minusOne, }, }, @@ -689,9 +688,9 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid PeriodSeconds", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ - LivenessProbe: &v1alpha1.Probe{ + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ + LivenessProbe: &Probe{ PeriodSeconds: &zero, }, }, @@ -700,9 +699,9 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid TimeoutSeconds", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ - LivenessProbe: &v1alpha1.Probe{ + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ + LivenessProbe: &Probe{ TimeoutSeconds: &zero, }, }, @@ -711,9 +710,9 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid SuccessThreshold", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ - LivenessProbe: &v1alpha1.Probe{ + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ + LivenessProbe: &Probe{ SuccessThreshold: &zero, }, }, @@ -722,9 +721,9 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid FailureThreshold", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ - LivenessProbe: &v1alpha1.Probe{ + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ + LivenessProbe: &Probe{ FailureThreshold: &zero, }, }, @@ -733,9 +732,9 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid TerminationGracePeriodSeconds", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ - LivenessProbe: &v1alpha1.Probe{ + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ + LivenessProbe: &Probe{ TerminationGracePeriodSeconds: &zero64, }, }, @@ -744,9 +743,9 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "invalid AdditionalContainers", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ - Mode: v1alpha1.ModeSidecar, + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ + Mode: ModeSidecar, AdditionalContainers: []v1.Container{ { Name: "test", @@ -758,10 +757,10 @@ func TestOTELColValidatingWebhook(t *testing.T) { }, { name: "missing ingress hostname for subdomain ruleType", - otelcol: v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ - Ingress: v1alpha1.Ingress{ - RuleType: v1alpha1.IngressRuleTypeSubdomain, + otelcol: OpenTelemetryCollector{ + Spec: OpenTelemetryCollectorSpec{ + Ingress: Ingress{ + RuleType: IngressRuleTypeSubdomain, }, }, }, @@ -771,7 +770,7 @@ func TestOTELColValidatingWebhook(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - cvw := &Webhook{ + cvw := &CollectorWebhook{ logger: logr.Discard(), scheme: testScheme, cfg: config.New( diff --git a/internal/webhook/instrumentation/webhook.go b/apis/v1alpha1/instrumentation_webhook.go similarity index 87% rename from internal/webhook/instrumentation/webhook.go rename to apis/v1alpha1/instrumentation_webhook.go index e7c3633d18..d35e252ff6 100644 --- a/internal/webhook/instrumentation/webhook.go +++ b/apis/v1alpha1/instrumentation_webhook.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package instrumentation +package v1alpha1 import ( "context" @@ -27,7 +27,6 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/pkg/constants" ) @@ -38,8 +37,8 @@ const ( ) var ( - _ admission.CustomValidator = &Webhook{} - _ admission.CustomDefaulter = &Webhook{} + _ admission.CustomValidator = &InstrumentationWebhook{} + _ admission.CustomDefaulter = &InstrumentationWebhook{} initContainerDefaultLimitResources = corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("500m"), corev1.ResourceMemory: resource.MustParse("128Mi"), @@ -54,48 +53,45 @@ var ( // +kubebuilder:webhook:verbs=create;update,path=/validate-opentelemetry-io-v1alpha1-instrumentation,mutating=false,failurePolicy=fail,groups=opentelemetry.io,resources=instrumentations,versions=v1alpha1,name=vinstrumentationcreateupdate.kb.io,sideEffects=none,admissionReviewVersions=v1 // +kubebuilder:webhook:verbs=delete,path=/validate-opentelemetry-io-v1alpha1-instrumentation,mutating=false,failurePolicy=ignore,groups=opentelemetry.io,resources=instrumentations,versions=v1alpha1,name=vinstrumentationdelete.kb.io,sideEffects=none,admissionReviewVersions=v1 -// Webhook is isolated because there are known registration issues when a custom webhook is in the same package -// as the types. -// See here: https://github.com/kubernetes-sigs/controller-runtime/issues/780#issuecomment-713408479 -type Webhook struct { +type InstrumentationWebhook struct { logger logr.Logger cfg config.Config scheme *runtime.Scheme } -func (w Webhook) Default(ctx context.Context, obj runtime.Object) error { - instrumentation, ok := obj.(*v1alpha1.Instrumentation) +func (w InstrumentationWebhook) Default(ctx context.Context, obj runtime.Object) error { + instrumentation, ok := obj.(*Instrumentation) if !ok { return fmt.Errorf("expected an Instrumentation, received %T", obj) } return w.defaulter(instrumentation) } -func (w Webhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { - inst, ok := obj.(*v1alpha1.Instrumentation) +func (w InstrumentationWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { + inst, ok := obj.(*Instrumentation) if !ok { return nil, fmt.Errorf("expected an Instrumentation, received %T", obj) } return w.validate(inst) } -func (w Webhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { - inst, ok := newObj.(*v1alpha1.Instrumentation) +func (w InstrumentationWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { + inst, ok := newObj.(*Instrumentation) if !ok { return nil, fmt.Errorf("expected an Instrumentation, received %T", newObj) } return w.validate(inst) } -func (w Webhook) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { - inst, ok := obj.(*v1alpha1.Instrumentation) +func (w InstrumentationWebhook) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { + inst, ok := obj.(*Instrumentation) if !ok || inst == nil { return nil, fmt.Errorf("expected an Instrumentation, received %T", obj) } return w.validate(inst) } -func (w Webhook) defaulter(r *v1alpha1.Instrumentation) error { +func (w InstrumentationWebhook) defaulter(r *Instrumentation) error { if r.Labels == nil { r.Labels = map[string]string{} } @@ -219,12 +215,12 @@ func (w Webhook) defaulter(r *v1alpha1.Instrumentation) error { return nil } -func (w Webhook) validate(r *v1alpha1.Instrumentation) (admission.Warnings, error) { +func (w InstrumentationWebhook) validate(r *Instrumentation) (admission.Warnings, error) { var warnings []string switch r.Spec.Sampler.Type { case "": warnings = append(warnings, "sampler type not set") - case v1alpha1.TraceIDRatio, v1alpha1.ParentBasedTraceIDRatio: + case TraceIDRatio, ParentBasedTraceIDRatio: if r.Spec.Sampler.Argument != "" { rate, err := strconv.ParseFloat(r.Spec.Sampler.Argument, 64) if err != nil { @@ -234,7 +230,7 @@ func (w Webhook) validate(r *v1alpha1.Instrumentation) (admission.Warnings, erro return warnings, fmt.Errorf("spec.sampler.argument should be in rage [0..1]: %s", r.Spec.Sampler.Argument) } } - case v1alpha1.JaegerRemote, v1alpha1.ParentBasedJaegerRemote: + case JaegerRemote, ParentBasedJaegerRemote: // value is a comma separated list of endpoint, pollingIntervalMs, initialSamplingRate // Example: `endpoint=http://localhost:14250,pollingIntervalMs=5000,initialSamplingRate=0.25` if r.Spec.Sampler.Argument != "" { @@ -244,7 +240,7 @@ func (w Webhook) validate(r *v1alpha1.Instrumentation) (admission.Warnings, erro return warnings, fmt.Errorf("spec.sampler.argument is not a valid argument for sampler %s: %w", r.Spec.Sampler.Type, err) } } - case v1alpha1.AlwaysOn, v1alpha1.AlwaysOff, v1alpha1.ParentBasedAlwaysOn, v1alpha1.ParentBasedAlwaysOff, v1alpha1.XRaySampler: + case AlwaysOn, AlwaysOff, ParentBasedAlwaysOn, ParentBasedAlwaysOff, XRaySampler: default: return warnings, fmt.Errorf("spec.sampler.type is not valid: %s", r.Spec.Sampler.Type) } @@ -277,7 +273,7 @@ func (w Webhook) validate(r *v1alpha1.Instrumentation) (admission.Warnings, erro return warnings, nil } -func (w Webhook) validateEnv(envs []corev1.EnvVar) error { +func (w InstrumentationWebhook) validateEnv(envs []corev1.EnvVar) error { for _, env := range envs { if !strings.HasPrefix(env.Name, envPrefix) && !strings.HasPrefix(env.Name, envSplunkPrefix) { return fmt.Errorf("env name should start with \"OTEL_\" or \"SPLUNK_\": %s", env.Name) @@ -317,22 +313,22 @@ func validateJaegerRemoteSamplerArgument(argument string) error { return nil } -func NewInstrumentationWebhook(logger logr.Logger, scheme *runtime.Scheme, cfg config.Config) *Webhook { - return &Webhook{ +func NewInstrumentationWebhook(logger logr.Logger, scheme *runtime.Scheme, cfg config.Config) *InstrumentationWebhook { + return &InstrumentationWebhook{ logger: logger, scheme: scheme, cfg: cfg, } } -func SetupWebhook(mgr ctrl.Manager, cfg config.Config) error { +func SetupInstrumentationWebhook(mgr ctrl.Manager, cfg config.Config) error { ivw := NewInstrumentationWebhook( mgr.GetLogger().WithValues("handler", "InstrumentationWebhook"), mgr.GetScheme(), cfg, ) return ctrl.NewWebhookManagedBy(mgr). - For(&v1alpha1.Instrumentation{}). + For(&Instrumentation{}). WithValidator(ivw). WithDefaulter(ivw). Complete() diff --git a/internal/webhook/instrumentation/webhook_test.go b/apis/v1alpha1/instrumentation_webhook_test.go similarity index 70% rename from internal/webhook/instrumentation/webhook_test.go rename to apis/v1alpha1/instrumentation_webhook_test.go index 0a6fa331a1..3465544b3c 100644 --- a/internal/webhook/instrumentation/webhook_test.go +++ b/apis/v1alpha1/instrumentation_webhook_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package instrumentation +package v1alpha1 import ( "context" @@ -21,13 +21,12 @@ import ( "github.com/stretchr/testify/assert" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" - "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" "github.com/open-telemetry/opentelemetry-operator/internal/config" ) func TestInstrumentationDefaultingWebhook(t *testing.T) { - inst := &v1alpha1.Instrumentation{} - err := Webhook{ + inst := &Instrumentation{} + err := CollectorWebhook{ cfg: config.New( config.WithAutoInstrumentationJavaImage("java-img:1"), config.WithAutoInstrumentationNodeJSImage("nodejs-img:1"), @@ -51,20 +50,20 @@ func TestInstrumentationValidatingWebhook(t *testing.T) { name string err string warnings admission.Warnings - inst v1alpha1.Instrumentation + inst Instrumentation }{ { name: "all defaults", - inst: v1alpha1.Instrumentation{ - Spec: v1alpha1.InstrumentationSpec{}, + inst: Instrumentation{ + Spec: InstrumentationSpec{}, }, warnings: []string{"sampler type not set"}, }, { name: "sampler configuration not present", - inst: v1alpha1.Instrumentation{ - Spec: v1alpha1.InstrumentationSpec{ - Sampler: v1alpha1.Sampler{}, + inst: Instrumentation{ + Spec: InstrumentationSpec{ + Sampler: Sampler{}, }, }, warnings: []string{"sampler type not set"}, @@ -72,10 +71,10 @@ func TestInstrumentationValidatingWebhook(t *testing.T) { { name: "argument is not a number", err: "spec.sampler.argument is not a number", - inst: v1alpha1.Instrumentation{ - Spec: v1alpha1.InstrumentationSpec{ - Sampler: v1alpha1.Sampler{ - Type: v1alpha1.ParentBasedTraceIDRatio, + inst: Instrumentation{ + Spec: InstrumentationSpec{ + Sampler: Sampler{ + Type: ParentBasedTraceIDRatio, Argument: "abc", }, }, @@ -84,10 +83,10 @@ func TestInstrumentationValidatingWebhook(t *testing.T) { { name: "argument is a wrong number", err: "spec.sampler.argument should be in rage [0..1]", - inst: v1alpha1.Instrumentation{ - Spec: v1alpha1.InstrumentationSpec{ - Sampler: v1alpha1.Sampler{ - Type: v1alpha1.ParentBasedTraceIDRatio, + inst: Instrumentation{ + Spec: InstrumentationSpec{ + Sampler: Sampler{ + Type: ParentBasedTraceIDRatio, Argument: "1.99", }, }, @@ -95,10 +94,10 @@ func TestInstrumentationValidatingWebhook(t *testing.T) { }, { name: "argument is a number", - inst: v1alpha1.Instrumentation{ - Spec: v1alpha1.InstrumentationSpec{ - Sampler: v1alpha1.Sampler{ - Type: v1alpha1.ParentBasedTraceIDRatio, + inst: Instrumentation{ + Spec: InstrumentationSpec{ + Sampler: Sampler{ + Type: ParentBasedTraceIDRatio, Argument: "0.99", }, }, @@ -106,10 +105,10 @@ func TestInstrumentationValidatingWebhook(t *testing.T) { }, { name: "argument is missing", - inst: v1alpha1.Instrumentation{ - Spec: v1alpha1.InstrumentationSpec{ - Sampler: v1alpha1.Sampler{ - Type: v1alpha1.ParentBasedTraceIDRatio, + inst: Instrumentation{ + Spec: InstrumentationSpec{ + Sampler: Sampler{ + Type: ParentBasedTraceIDRatio, }, }, }, @@ -120,17 +119,17 @@ func TestInstrumentationValidatingWebhook(t *testing.T) { t.Run(test.name, func(t *testing.T) { ctx := context.Background() if test.err == "" { - warnings, err := Webhook{}.ValidateCreate(ctx, &test.inst) + warnings, err := CollectorWebhook{}.ValidateCreate(ctx, &test.inst) assert.Equal(t, test.warnings, warnings) assert.Nil(t, err) - warnings, err = Webhook{}.ValidateUpdate(ctx, nil, &test.inst) + warnings, err = CollectorWebhook{}.ValidateUpdate(ctx, nil, &test.inst) assert.Equal(t, test.warnings, warnings) assert.Nil(t, err) } else { - warnings, err := Webhook{}.ValidateCreate(ctx, &test.inst) + warnings, err := CollectorWebhook{}.ValidateCreate(ctx, &test.inst) assert.Equal(t, test.warnings, warnings) assert.Contains(t, err.Error(), test.err) - warnings, err = Webhook{}.ValidateUpdate(ctx, nil, &test.inst) + warnings, err = CollectorWebhook{}.ValidateUpdate(ctx, nil, &test.inst) assert.Equal(t, test.warnings, warnings) assert.Contains(t, err.Error(), test.err) } @@ -165,14 +164,14 @@ func TestInstrumentationJaegerRemote(t *testing.T) { }, } - samplers := []v1alpha1.SamplerType{v1alpha1.JaegerRemote, v1alpha1.ParentBasedJaegerRemote} + samplers := []SamplerType{JaegerRemote, ParentBasedJaegerRemote} for _, sampler := range samplers { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - inst := v1alpha1.Instrumentation{ - Spec: v1alpha1.InstrumentationSpec{ - Sampler: v1alpha1.Sampler{ + inst := Instrumentation{ + Spec: InstrumentationSpec{ + Sampler: Sampler{ Type: sampler, Argument: test.arg, }, @@ -180,17 +179,17 @@ func TestInstrumentationJaegerRemote(t *testing.T) { } ctx := context.Background() if test.err == "" { - warnings, err := Webhook{}.ValidateCreate(ctx, &inst) + warnings, err := CollectorWebhook{}.ValidateCreate(ctx, &inst) assert.Nil(t, warnings) assert.Nil(t, err) - warnings, err = Webhook{}.ValidateUpdate(ctx, nil, &inst) + warnings, err = CollectorWebhook{}.ValidateUpdate(ctx, nil, &inst) assert.Nil(t, warnings) assert.Nil(t, err) } else { - warnings, err := Webhook{}.ValidateCreate(ctx, &inst) + warnings, err := CollectorWebhook{}.ValidateCreate(ctx, &inst) assert.Nil(t, warnings) assert.Contains(t, err.Error(), test.err) - warnings, err = Webhook{}.ValidateUpdate(ctx, nil, &inst) + warnings, err = CollectorWebhook{}.ValidateUpdate(ctx, nil, &inst) assert.Nil(t, warnings) assert.Contains(t, err.Error(), test.err) } diff --git a/controllers/suite_test.go b/controllers/suite_test.go index bc2797d64f..acf46e64ef 100644 --- a/controllers/suite_test.go +++ b/controllers/suite_test.go @@ -49,7 +49,6 @@ import ( "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/manifests" "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/testdata" - collectorwebhook "github.com/open-telemetry/opentelemetry-operator/internal/webhook/collector" // +kubebuilder:scaffold:imports ) @@ -126,7 +125,7 @@ func TestMain(m *testing.M) { os.Exit(1) } - if err = collectorwebhook.SetupWebhook(mgr, config.New()); err != nil { + if err = v1alpha1.SetupCollectorWebhook(mgr, config.New()); err != nil { fmt.Printf("failed to SetupWebhookWithManager: %v", err) os.Exit(1) } diff --git a/internal/webhook/sidecar/webhookhandler_suite_test.go b/internal/webhook/sidecar/webhookhandler_suite_test.go index 827dfc5bd6..aeb52bb300 100644 --- a/internal/webhook/sidecar/webhookhandler_suite_test.go +++ b/internal/webhook/sidecar/webhookhandler_suite_test.go @@ -38,7 +38,6 @@ import ( "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" "github.com/open-telemetry/opentelemetry-operator/internal/config" - collectorwebhook "github.com/open-telemetry/opentelemetry-operator/internal/webhook/collector" // +kubebuilder:scaffold:imports ) @@ -99,7 +98,7 @@ func TestMain(m *testing.M) { os.Exit(1) } - if err = collectorwebhook.SetupWebhook(mgr, config.New()); err != nil { + if err = v1alpha1.SetupInstrumentationWebhook(mgr, config.New()); err != nil { fmt.Printf("failed to SetupWebhookWithManager: %v", err) os.Exit(1) } diff --git a/main.go b/main.go index 9c65e1474a..064c30f393 100644 --- a/main.go +++ b/main.go @@ -47,8 +47,6 @@ import ( "github.com/open-telemetry/opentelemetry-operator/controllers" "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/version" - collectorwebhook "github.com/open-telemetry/opentelemetry-operator/internal/webhook/collector" - instrumentationwebhook "github.com/open-telemetry/opentelemetry-operator/internal/webhook/instrumentation" sidecarwebhook "github.com/open-telemetry/opentelemetry-operator/internal/webhook/sidecar" "github.com/open-telemetry/opentelemetry-operator/pkg/autodetect" collectorupgrade "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" @@ -248,11 +246,11 @@ func main() { } if os.Getenv("ENABLE_WEBHOOKS") != "false" { - if err = collectorwebhook.SetupWebhook(mgr, cfg); err != nil { + if err = otelv1alpha1.SetupCollectorWebhook(mgr, cfg); err != nil { setupLog.Error(err, "unable to create webhook", "webhook", "OpenTelemetryCollector") os.Exit(1) } - if err = instrumentationwebhook.SetupWebhook(mgr, cfg); err != nil { + if err = otelv1alpha1.SetupInstrumentationWebhook(mgr, cfg); err != nil { setupLog.Error(err, "unable to create webhook", "webhook", "Instrumentation") os.Exit(1) } diff --git a/pkg/collector/reconcile/suite_test.go b/pkg/collector/reconcile/suite_test.go index 315f434dd7..cfe28fc28a 100644 --- a/pkg/collector/reconcile/suite_test.go +++ b/pkg/collector/reconcile/suite_test.go @@ -52,7 +52,6 @@ import ( "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/manifests" "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/testdata" - collectorwebhook "github.com/open-telemetry/opentelemetry-operator/internal/webhook/collector" ) var ( @@ -136,7 +135,7 @@ func TestMain(m *testing.M) { os.Exit(1) } - if err = collectorwebhook.SetupWebhook(mgr, config.New()); err != nil { + if err = v1alpha1.SetupCollectorWebhook(mgr, config.New()); err != nil { fmt.Printf("failed to SetupWebhookWithManager: %v", err) os.Exit(1) } diff --git a/pkg/collector/upgrade/suite_test.go b/pkg/collector/upgrade/suite_test.go index dcafd906a9..9496b9f47d 100644 --- a/pkg/collector/upgrade/suite_test.go +++ b/pkg/collector/upgrade/suite_test.go @@ -38,7 +38,6 @@ import ( "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" "github.com/open-telemetry/opentelemetry-operator/internal/config" - collectorwebhook "github.com/open-telemetry/opentelemetry-operator/internal/webhook/collector" // +kubebuilder:scaffold:imports ) @@ -101,7 +100,7 @@ func TestMain(m *testing.M) { os.Exit(1) } - if err = collectorwebhook.SetupWebhook(mgr, conf); err != nil { + if err = v1alpha1.SetupCollectorWebhook(mgr, conf); err != nil { fmt.Printf("failed to SetupWebhookWithManager: %v", err) os.Exit(1) } diff --git a/pkg/instrumentation/upgrade/upgrade_test.go b/pkg/instrumentation/upgrade/upgrade_test.go index 49562463a4..e4f6448e45 100644 --- a/pkg/instrumentation/upgrade/upgrade_test.go +++ b/pkg/instrumentation/upgrade/upgrade_test.go @@ -29,7 +29,6 @@ import ( "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" "github.com/open-telemetry/opentelemetry-operator/internal/config" - instrumentationwebhook "github.com/open-telemetry/opentelemetry-operator/internal/webhook/instrumentation" "github.com/open-telemetry/opentelemetry-operator/pkg/constants" "github.com/open-telemetry/opentelemetry-operator/pkg/featuregate" ) @@ -72,7 +71,7 @@ func TestUpgrade(t *testing.T) { }, }, } - err = instrumentationwebhook.NewInstrumentationWebhook( + err = v1alpha1.NewInstrumentationWebhook( logr.Discard(), testScheme, config.New( From 7c4185d4fb0695b66d6ee676f65b0c0e5aa8455f Mon Sep 17 00:00:00 2001 From: Jacob Aronoff Date: Thu, 12 Oct 2023 17:37:20 -0400 Subject: [PATCH 12/15] update manifests --- config/webhook/manifests.yaml | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/config/webhook/manifests.yaml b/config/webhook/manifests.yaml index 310e18215b..d9adaf855a 100644 --- a/config/webhook/manifests.yaml +++ b/config/webhook/manifests.yaml @@ -10,9 +10,9 @@ webhooks: service: name: webhook-service namespace: system - path: /mutate-opentelemetry-io-v1alpha1-opentelemetrycollector + path: /mutate-opentelemetry-io-v1alpha1-instrumentation failurePolicy: Fail - name: mopentelemetrycollector.kb.io + name: minstrumentation.kb.io rules: - apiGroups: - opentelemetry.io @@ -22,7 +22,7 @@ webhooks: - CREATE - UPDATE resources: - - opentelemetrycollectors + - instrumentations sideEffects: None - admissionReviewVersions: - v1 @@ -30,9 +30,9 @@ webhooks: service: name: webhook-service namespace: system - path: /mutate-opentelemetry-io-v1alpha1-instrumentation + path: /mutate-opentelemetry-io-v1alpha1-opentelemetrycollector failurePolicy: Fail - name: minstrumentation.kb.io + name: mopentelemetrycollector.kb.io rules: - apiGroups: - opentelemetry.io @@ -42,7 +42,7 @@ webhooks: - CREATE - UPDATE resources: - - instrumentations + - opentelemetrycollectors sideEffects: None - admissionReviewVersions: - v1 @@ -76,9 +76,9 @@ webhooks: service: name: webhook-service namespace: system - path: /validate-opentelemetry-io-v1alpha1-opentelemetrycollector + path: /validate-opentelemetry-io-v1alpha1-instrumentation failurePolicy: Fail - name: vopentelemetrycollectorcreateupdate.kb.io + name: vinstrumentationcreateupdate.kb.io rules: - apiGroups: - opentelemetry.io @@ -88,7 +88,7 @@ webhooks: - CREATE - UPDATE resources: - - opentelemetrycollectors + - instrumentations sideEffects: None - admissionReviewVersions: - v1 @@ -96,9 +96,9 @@ webhooks: service: name: webhook-service namespace: system - path: /validate-opentelemetry-io-v1alpha1-opentelemetrycollector + path: /validate-opentelemetry-io-v1alpha1-instrumentation failurePolicy: Ignore - name: vopentelemetrycollectordelete.kb.io + name: vinstrumentationdelete.kb.io rules: - apiGroups: - opentelemetry.io @@ -107,7 +107,7 @@ webhooks: operations: - DELETE resources: - - opentelemetrycollectors + - instrumentations sideEffects: None - admissionReviewVersions: - v1 @@ -115,9 +115,9 @@ webhooks: service: name: webhook-service namespace: system - path: /validate-opentelemetry-io-v1alpha1-instrumentation + path: /validate-opentelemetry-io-v1alpha1-opentelemetrycollector failurePolicy: Fail - name: vinstrumentationcreateupdate.kb.io + name: vopentelemetrycollectorcreateupdate.kb.io rules: - apiGroups: - opentelemetry.io @@ -127,7 +127,7 @@ webhooks: - CREATE - UPDATE resources: - - instrumentations + - opentelemetrycollectors sideEffects: None - admissionReviewVersions: - v1 @@ -135,9 +135,9 @@ webhooks: service: name: webhook-service namespace: system - path: /validate-opentelemetry-io-v1alpha1-instrumentation + path: /validate-opentelemetry-io-v1alpha1-opentelemetrycollector failurePolicy: Ignore - name: vinstrumentationdelete.kb.io + name: vopentelemetrycollectordelete.kb.io rules: - apiGroups: - opentelemetry.io @@ -146,5 +146,5 @@ webhooks: operations: - DELETE resources: - - instrumentations + - opentelemetrycollectors sideEffects: None From 82971e1038cf56f3be7e6ab32cb5361afffbfc8a Mon Sep 17 00:00:00 2001 From: Jacob Aronoff Date: Thu, 12 Oct 2023 17:40:02 -0400 Subject: [PATCH 13/15] fix a miss --- internal/webhook/sidecar/webhookhandler_suite_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/webhook/sidecar/webhookhandler_suite_test.go b/internal/webhook/sidecar/webhookhandler_suite_test.go index aeb52bb300..9ff9a474b9 100644 --- a/internal/webhook/sidecar/webhookhandler_suite_test.go +++ b/internal/webhook/sidecar/webhookhandler_suite_test.go @@ -98,7 +98,7 @@ func TestMain(m *testing.M) { os.Exit(1) } - if err = v1alpha1.SetupInstrumentationWebhook(mgr, config.New()); err != nil { + if err = v1alpha1.SetupCollectorWebhook(mgr, config.New()); err != nil { fmt.Printf("failed to SetupWebhookWithManager: %v", err) os.Exit(1) } From b25036507d6c4c83e4928d4c8938f477ad14f642 Mon Sep 17 00:00:00 2001 From: Jacob Aronoff Date: Fri, 13 Oct 2023 14:04:15 -0400 Subject: [PATCH 14/15] fix tests --- apis/v1alpha1/collector_webhook.go | 1 + apis/v1alpha1/instrumentation_webhook.go | 1 + apis/v1alpha1/instrumentation_webhook_test.go | 18 +++++++++--------- apis/v1alpha1/zz_generated.deepcopy.go | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/apis/v1alpha1/collector_webhook.go b/apis/v1alpha1/collector_webhook.go index ca16bc4589..cc61f72b59 100644 --- a/apis/v1alpha1/collector_webhook.go +++ b/apis/v1alpha1/collector_webhook.go @@ -39,6 +39,7 @@ var ( // +kubebuilder:webhook:path=/mutate-opentelemetry-io-v1alpha1-opentelemetrycollector,mutating=true,failurePolicy=fail,groups=opentelemetry.io,resources=opentelemetrycollectors,verbs=create;update,versions=v1alpha1,name=mopentelemetrycollector.kb.io,sideEffects=none,admissionReviewVersions=v1 // +kubebuilder:webhook:verbs=create;update,path=/validate-opentelemetry-io-v1alpha1-opentelemetrycollector,mutating=false,failurePolicy=fail,groups=opentelemetry.io,resources=opentelemetrycollectors,versions=v1alpha1,name=vopentelemetrycollectorcreateupdate.kb.io,sideEffects=none,admissionReviewVersions=v1 // +kubebuilder:webhook:verbs=delete,path=/validate-opentelemetry-io-v1alpha1-opentelemetrycollector,mutating=false,failurePolicy=ignore,groups=opentelemetry.io,resources=opentelemetrycollectors,versions=v1alpha1,name=vopentelemetrycollectordelete.kb.io,sideEffects=none,admissionReviewVersions=v1 +// +kubebuilder:object:generate=false type CollectorWebhook struct { logger logr.Logger diff --git a/apis/v1alpha1/instrumentation_webhook.go b/apis/v1alpha1/instrumentation_webhook.go index d35e252ff6..beeaedf362 100644 --- a/apis/v1alpha1/instrumentation_webhook.go +++ b/apis/v1alpha1/instrumentation_webhook.go @@ -52,6 +52,7 @@ var ( // +kubebuilder:webhook:path=/mutate-opentelemetry-io-v1alpha1-instrumentation,mutating=true,failurePolicy=fail,sideEffects=None,groups=opentelemetry.io,resources=instrumentations,verbs=create;update,versions=v1alpha1,name=minstrumentation.kb.io,admissionReviewVersions=v1 // +kubebuilder:webhook:verbs=create;update,path=/validate-opentelemetry-io-v1alpha1-instrumentation,mutating=false,failurePolicy=fail,groups=opentelemetry.io,resources=instrumentations,versions=v1alpha1,name=vinstrumentationcreateupdate.kb.io,sideEffects=none,admissionReviewVersions=v1 // +kubebuilder:webhook:verbs=delete,path=/validate-opentelemetry-io-v1alpha1-instrumentation,mutating=false,failurePolicy=ignore,groups=opentelemetry.io,resources=instrumentations,versions=v1alpha1,name=vinstrumentationdelete.kb.io,sideEffects=none,admissionReviewVersions=v1 +// +kubebuilder:object:generate=false type InstrumentationWebhook struct { logger logr.Logger diff --git a/apis/v1alpha1/instrumentation_webhook_test.go b/apis/v1alpha1/instrumentation_webhook_test.go index 3465544b3c..46f7327ad8 100644 --- a/apis/v1alpha1/instrumentation_webhook_test.go +++ b/apis/v1alpha1/instrumentation_webhook_test.go @@ -26,7 +26,7 @@ import ( func TestInstrumentationDefaultingWebhook(t *testing.T) { inst := &Instrumentation{} - err := CollectorWebhook{ + err := InstrumentationWebhook{ cfg: config.New( config.WithAutoInstrumentationJavaImage("java-img:1"), config.WithAutoInstrumentationNodeJSImage("nodejs-img:1"), @@ -119,17 +119,17 @@ func TestInstrumentationValidatingWebhook(t *testing.T) { t.Run(test.name, func(t *testing.T) { ctx := context.Background() if test.err == "" { - warnings, err := CollectorWebhook{}.ValidateCreate(ctx, &test.inst) + warnings, err := InstrumentationWebhook{}.ValidateCreate(ctx, &test.inst) assert.Equal(t, test.warnings, warnings) assert.Nil(t, err) - warnings, err = CollectorWebhook{}.ValidateUpdate(ctx, nil, &test.inst) + warnings, err = InstrumentationWebhook{}.ValidateUpdate(ctx, nil, &test.inst) assert.Equal(t, test.warnings, warnings) assert.Nil(t, err) } else { - warnings, err := CollectorWebhook{}.ValidateCreate(ctx, &test.inst) + warnings, err := InstrumentationWebhook{}.ValidateCreate(ctx, &test.inst) assert.Equal(t, test.warnings, warnings) assert.Contains(t, err.Error(), test.err) - warnings, err = CollectorWebhook{}.ValidateUpdate(ctx, nil, &test.inst) + warnings, err = InstrumentationWebhook{}.ValidateUpdate(ctx, nil, &test.inst) assert.Equal(t, test.warnings, warnings) assert.Contains(t, err.Error(), test.err) } @@ -179,17 +179,17 @@ func TestInstrumentationJaegerRemote(t *testing.T) { } ctx := context.Background() if test.err == "" { - warnings, err := CollectorWebhook{}.ValidateCreate(ctx, &inst) + warnings, err := InstrumentationWebhook{}.ValidateCreate(ctx, &inst) assert.Nil(t, warnings) assert.Nil(t, err) - warnings, err = CollectorWebhook{}.ValidateUpdate(ctx, nil, &inst) + warnings, err = InstrumentationWebhook{}.ValidateUpdate(ctx, nil, &inst) assert.Nil(t, warnings) assert.Nil(t, err) } else { - warnings, err := CollectorWebhook{}.ValidateCreate(ctx, &inst) + warnings, err := InstrumentationWebhook{}.ValidateCreate(ctx, &inst) assert.Nil(t, warnings) assert.Contains(t, err.Error(), test.err) - warnings, err = CollectorWebhook{}.ValidateUpdate(ctx, nil, &inst) + warnings, err = InstrumentationWebhook{}.ValidateUpdate(ctx, nil, &inst) assert.Nil(t, warnings) assert.Contains(t, err.Error(), test.err) } diff --git a/apis/v1alpha1/zz_generated.deepcopy.go b/apis/v1alpha1/zz_generated.deepcopy.go index b99c43312f..bd1c11e449 100644 --- a/apis/v1alpha1/zz_generated.deepcopy.go +++ b/apis/v1alpha1/zz_generated.deepcopy.go @@ -24,7 +24,7 @@ import ( "k8s.io/api/core/v1" networkingv1 "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/intstr" ) From ebc2c19506a5738fdce8cf5af65cd2cd221a3dac Mon Sep 17 00:00:00 2001 From: Jacob Aronoff Date: Mon, 16 Oct 2023 10:56:52 -0700 Subject: [PATCH 15/15] Rename --- .../{sidecar => podmutation}/webhookhandler.go | 12 ++++++------ .../webhookhandler_suite_test.go | 2 +- .../{sidecar => podmutation}/webhookhandler_test.go | 4 ++-- main.go | 6 +++--- pkg/instrumentation/podmutator.go | 4 ++-- pkg/sidecar/podmutator.go | 4 ++-- 6 files changed, 16 insertions(+), 16 deletions(-) rename internal/webhook/{sidecar => podmutation}/webhookhandler.go (92%) rename internal/webhook/{sidecar => podmutation}/webhookhandler_suite_test.go (99%) rename internal/webhook/{sidecar => podmutation}/webhookhandler_test.go (99%) diff --git a/internal/webhook/sidecar/webhookhandler.go b/internal/webhook/podmutation/webhookhandler.go similarity index 92% rename from internal/webhook/sidecar/webhookhandler.go rename to internal/webhook/podmutation/webhookhandler.go index dce007e3ce..9d9fa6e743 100644 --- a/internal/webhook/sidecar/webhookhandler.go +++ b/internal/webhook/podmutation/webhookhandler.go @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Package sidecar contains the webhook that injects sidecars into pods. -package sidecar +// Package podmutation contains the webhook that injects sidecars into pods. +package podmutation import ( "context" @@ -35,7 +35,7 @@ import ( // +kubebuilder:rbac:groups=opentelemetry.io,resources=instrumentations,verbs=get;list;watch // +kubebuilder:rbac:groups="apps",resources=replicasets,verbs=get;list;watch -var _ WebhookHandler = (*sidecarWebhook)(nil) +var _ WebhookHandler = (*podMutationWebhook)(nil) // WebhookHandler is a webhook handler that analyzes new pods and injects appropriate sidecars into it. type WebhookHandler interface { @@ -43,7 +43,7 @@ type WebhookHandler interface { } // the implementation. -type sidecarWebhook struct { +type podMutationWebhook struct { client client.Client decoder *admission.Decoder logger logr.Logger @@ -58,7 +58,7 @@ type PodMutator interface { // NewWebhookHandler creates a new WebhookHandler. func NewWebhookHandler(cfg config.Config, logger logr.Logger, decoder *admission.Decoder, cl client.Client, podMutators []PodMutator) WebhookHandler { - return &sidecarWebhook{ + return &podMutationWebhook{ config: cfg, decoder: decoder, logger: logger, @@ -67,7 +67,7 @@ func NewWebhookHandler(cfg config.Config, logger logr.Logger, decoder *admission } } -func (p *sidecarWebhook) Handle(ctx context.Context, req admission.Request) admission.Response { +func (p *podMutationWebhook) Handle(ctx context.Context, req admission.Request) admission.Response { pod := corev1.Pod{} err := p.decoder.Decode(req, &pod) if err != nil { diff --git a/internal/webhook/sidecar/webhookhandler_suite_test.go b/internal/webhook/podmutation/webhookhandler_suite_test.go similarity index 99% rename from internal/webhook/sidecar/webhookhandler_suite_test.go rename to internal/webhook/podmutation/webhookhandler_suite_test.go index 9ff9a474b9..05f6c062be 100644 --- a/internal/webhook/sidecar/webhookhandler_suite_test.go +++ b/internal/webhook/podmutation/webhookhandler_suite_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package sidecar_test +package podmutation_test import ( "context" diff --git a/internal/webhook/sidecar/webhookhandler_test.go b/internal/webhook/podmutation/webhookhandler_test.go similarity index 99% rename from internal/webhook/sidecar/webhookhandler_test.go rename to internal/webhook/podmutation/webhookhandler_test.go index 5e93358efc..d5bb69b795 100644 --- a/internal/webhook/sidecar/webhookhandler_test.go +++ b/internal/webhook/podmutation/webhookhandler_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package sidecar_test +package podmutation_test import ( "context" @@ -33,7 +33,7 @@ import ( "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/naming" - . "github.com/open-telemetry/opentelemetry-operator/internal/webhook/sidecar" + . "github.com/open-telemetry/opentelemetry-operator/internal/webhook/podmutation" "github.com/open-telemetry/opentelemetry-operator/pkg/sidecar" ) diff --git a/main.go b/main.go index 064c30f393..80872048b6 100644 --- a/main.go +++ b/main.go @@ -47,7 +47,7 @@ import ( "github.com/open-telemetry/opentelemetry-operator/controllers" "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/version" - sidecarwebhook "github.com/open-telemetry/opentelemetry-operator/internal/webhook/sidecar" + "github.com/open-telemetry/opentelemetry-operator/internal/webhook/podmutation" "github.com/open-telemetry/opentelemetry-operator/pkg/autodetect" collectorupgrade "github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade" "github.com/open-telemetry/opentelemetry-operator/pkg/featuregate" @@ -256,8 +256,8 @@ func main() { } decoder := admission.NewDecoder(mgr.GetScheme()) mgr.GetWebhookServer().Register("/mutate-v1-pod", &webhook.Admission{ - Handler: sidecarwebhook.NewWebhookHandler(cfg, ctrl.Log.WithName("pod-webhook"), decoder, mgr.GetClient(), - []sidecarwebhook.PodMutator{ + Handler: podmutation.NewWebhookHandler(cfg, ctrl.Log.WithName("pod-webhook"), decoder, mgr.GetClient(), + []podmutation.PodMutator{ sidecar.NewMutator(logger, cfg, mgr.GetClient()), instrumentation.NewMutator(logger, mgr.GetClient(), mgr.GetEventRecorderFor("opentelemetry-operator")), }), diff --git a/pkg/instrumentation/podmutator.go b/pkg/instrumentation/podmutator.go index 7c122091f7..0a7878ae19 100644 --- a/pkg/instrumentation/podmutator.go +++ b/pkg/instrumentation/podmutator.go @@ -27,7 +27,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" - "github.com/open-telemetry/opentelemetry-operator/internal/webhook/sidecar" + "github.com/open-telemetry/opentelemetry-operator/internal/webhook/podmutation" "github.com/open-telemetry/opentelemetry-operator/pkg/featuregate" ) @@ -191,7 +191,7 @@ func (langInsts *languageInstrumentations) setInstrumentationLanguageContainers( } } -var _ sidecar.PodMutator = (*instPodMutator)(nil) +var _ podmutation.PodMutator = (*instPodMutator)(nil) func NewMutator(logger logr.Logger, client client.Client, recorder record.EventRecorder) *instPodMutator { return &instPodMutator{ diff --git a/pkg/sidecar/podmutator.go b/pkg/sidecar/podmutator.go index e94c8be468..a7a0737b53 100644 --- a/pkg/sidecar/podmutator.go +++ b/pkg/sidecar/podmutator.go @@ -28,7 +28,7 @@ import ( "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" "github.com/open-telemetry/opentelemetry-operator/internal/config" - "github.com/open-telemetry/opentelemetry-operator/internal/webhook/sidecar" + "github.com/open-telemetry/opentelemetry-operator/internal/webhook/podmutation" ) var ( @@ -43,7 +43,7 @@ type sidecarPodMutator struct { config config.Config } -var _ sidecar.PodMutator = (*sidecarPodMutator)(nil) +var _ podmutation.PodMutator = (*sidecarPodMutator)(nil) func NewMutator(logger logr.Logger, config config.Config, client client.Client) *sidecarPodMutator { return &sidecarPodMutator{