diff --git a/.chloggen/2449-fix-ingress.yaml b/.chloggen/2449-fix-ingress.yaml new file mode 100755 index 0000000000..423f4bb6f5 --- /dev/null +++ b/.chloggen/2449-fix-ingress.yaml @@ -0,0 +1,16 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: bug_fix + +# 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: Fix the path and annotations needed for the Ingress to expose the OTLP HTTP receiver. + +# One or more tracking issues related to the change +issues: [2449] + +# (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: diff --git a/internal/manifests/collector/ingress.go b/internal/manifests/collector/ingress.go index 4bb692ff90..86517e4410 100644 --- a/internal/manifests/collector/ingress.go +++ b/internal/manifests/collector/ingress.go @@ -53,11 +53,20 @@ func Ingress(params manifests.Params) (*networkingv1.Ingress, error) { rules = createSubdomainIngressRules(params.OtelCol.Name, params.OtelCol.Spec.Ingress.Hostname, ports) } + ingressAnnotations := params.OtelCol.Spec.Ingress.Annotations + if ingressAnnotations == nil { + ingressAnnotations = make(map[string]string) + } + + if _, ok := ingressAnnotations["nginx.ingress.kubernetes.io/rewrite-target"]; !ok { + ingressAnnotations["nginx.ingress.kubernetes.io/rewrite-target"] = "/$2" + } + return &networkingv1.Ingress{ ObjectMeta: metav1.ObjectMeta{ Name: naming.Ingress(params.OtelCol.Name), Namespace: params.OtelCol.Namespace, - Annotations: params.OtelCol.Spec.Ingress.Annotations, + Annotations: ingressAnnotations, Labels: map[string]string{ "app.kubernetes.io/name": naming.Ingress(params.OtelCol.Name), "app.kubernetes.io/instance": fmt.Sprintf("%s.%s", params.OtelCol.Namespace, params.OtelCol.Name), @@ -78,7 +87,7 @@ func createPathIngressRules(otelcol string, hostname string, ports []corev1.Serv for i, port := range ports { portName := naming.PortName(port.Name, port.Port) paths[i] = networkingv1.HTTPIngressPath{ - Path: "/" + port.Name, + Path: "/" + port.Name + "(/|$)(.*)", PathType: &pathType, Backend: networkingv1.IngressBackend{ Service: &networkingv1.IngressServiceBackend{