Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure OTLP exporter can report data to OTLP ingress/route without additional configuration #1981

Merged
merged 4 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .chloggen/1967-ingress-path.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking

# The name of the component, or a single word describing the area of concern, (e.g. operator, target allocator, github action)
component: operator

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Make sure OTLP export can report data to OTLP ingress/route without additional configuration

# One or more tracking issues related to the change
issues: [1967]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext: |
The ingress can be configured to create a single host with multiple paths or
multiple hosts with subdomains (one per receiver port).
The path from OpenShift route was removed.
The port names are truncate to 15 characters. Users with custom receivers
which create ports with longer name might need to update their configuration.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL)
endif
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)

CRD_OPTIONS ?= "crd:generateEmbeddedObjectMeta=true"
CRD_OPTIONS ?= "crd:generateEmbeddedObjectMeta=true,maxDescLen=200"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#1980 increased size of CRD to a point that no additional fields can be added. The CI was failing on

Error from server (Invalid): error when creating "STDIN": CustomResourceDefinition.apiextensions.k8s.io Too long: must have at most 262144 characters

This can be solved by removing/trimming the CRD description texts. Similar to jaegertracing/jaeger-operator#932

docs:


# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand Down Expand Up @@ -484,4 +484,4 @@ catalog-build: opm bundle-build bundle-push ## Build a catalog image.
# Push the catalog image.
.PHONY: catalog-push
catalog-push: ## Push a catalog image.
docker push $(CATALOG_IMG)
docker push $(CATALOG_IMG)
15 changes: 15 additions & 0 deletions apis/v1alpha1/ingress_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,18 @@ const (
// and re-encrypt using a new certificate.
TLSRouteTerminationTypeReencrypt TLSRouteTerminationType = "reencrypt"
)

// IngressRuleType defines how the collector receivers will be exposed in the Ingress.
//
// +kubebuilder:validation:Enum=path;subdomain
type IngressRuleType string

const (
// IngressRuleTypePath configures Ingress to use single host with multiple paths.
// This configuration might require additional ingress setting to rewrite paths.
IngressRuleTypePath IngressRuleType = "path"

// IngressRuleTypeSubdomain configures Ingress to use multiple hosts - one for each exposed
// receiver port. The port name is used as a subdomain for the host defined in the Ingress e.g. otlp-http.example.com.
IngressRuleTypeSubdomain IngressRuleType = "subdomain"
)
8 changes: 7 additions & 1 deletion apis/v1alpha1/opentelemetrycollector_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,15 @@ const (
// SEE: OpenTelemetryCollector.spec.ports[index].
type Ingress struct {
// Type default value is: ""
// Supported types are: ingress
// Supported types are: ingress, route
Type IngressType `json:"type,omitempty"`

// RuleType defines how Ingress exposes collector receivers.
// IngressRuleTypePath ("path") exposes each receiver port on a unique path on single domain defined in Hostname.
// IngressRuleTypeSubdomain ("subdomain") exposes each receiver port on a unique subdomain of Hostname.
// Default is IngressRuleTypePath ("path").
RuleType IngressRuleType `json:"ruleType,omitempty"`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better naming ideas are appreciated :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about exposeMethod instead of ruleType?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it might be better to keep the name aligned with the upstream ingress settings.

It seems that users don't like that operators re-invent existing concepts #1987


// Hostname by which the ingress proxy can be reached.
// +optional
Hostname string `json:"hostname,omitempty"`
Expand Down
6 changes: 6 additions & 0 deletions apis/v1alpha1/opentelemetrycollector_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ 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 == IngressTypeNginx && r.Spec.Ingress.RuleType == "" {
r.Spec.Ingress.RuleType = IngressRuleTypePath
}
}

// +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
Expand Down Expand Up @@ -248,6 +251,9 @@ func (r *OpenTelemetryCollector) validateCRDSpec() error {
ModeDeployment, ModeDaemonSet, 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.LivenessProbe != nil {
if r.Spec.LivenessProbe.InitialDelaySeconds != nil && *r.Spec.LivenessProbe.InitialDelaySeconds < 0 {
Expand Down
11 changes: 11 additions & 0 deletions apis/v1alpha1/opentelemetrycollector_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,17 @@ func TestOTELColValidatingWebhook(t *testing.T) {
},
expectedErr: "the OpenTelemetry Collector mode is set to sidecar, which does not support the attribute 'AdditionalContainers'",
},
{
name: "missing ingress hostname for subdomain ruleType",
otelcol: OpenTelemetryCollector{
Spec: OpenTelemetryCollectorSpec{
Ingress: Ingress{
RuleType: IngressRuleTypeSubdomain,
},
},
},
expectedErr: "a valid Ingress hostname has to be defined for subdomain ruleType",
},
}

for _, test := range tests {
Expand Down
Loading