Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
Signed-off-by: Pavol Loffay <[email protected]>
  • Loading branch information
pavolloffay committed Aug 4, 2023
1 parent 89e0d78 commit 4f00da7
Show file tree
Hide file tree
Showing 18 changed files with 171 additions and 21 deletions.
18 changes: 18 additions & 0 deletions .chloggen/1967-ingress-path.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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 and route now uses only root path `/` for all exposed collector receivers.
Each receiver is exposed on a subdomain that matches the port name of the receiver.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ generate: controller-gen api-docs
# end-to-tests
.PHONY: e2e
e2e:
$(KUTTL) test
$(KUTTL) test --test ingress

# end-to-end-test for PrometheusCR E2E tests
.PHONY: e2e-prometheuscr
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)
8 changes: 6 additions & 2 deletions internal/manifests/collector/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,16 @@ func Ingress(cfg config.Config, logger logr.Logger, otelcol v1alpha1.OpenTelemet

func createIngressRules(otelcol string, hostname string, ports []corev1.ServicePort) []networkingv1.IngressRule {
var rules []networkingv1.IngressRule
pathType := networkingv1.PathTypeExact
pathType := networkingv1.PathTypePrefix
for _, port := range ports {
portName := naming.PortName(port.Name, port.Port)

host := fmt.Sprintf("%s.%s", portName, hostname)
if hostname == "" || hostname == "*" {
host = portName
}
rules = append(rules, networkingv1.IngressRule{
Host: fmt.Sprintf("%s.%s", portName, hostname),
Host: host,
IngressRuleValue: networkingv1.IngressRuleValue{
HTTP: &networkingv1.HTTPIngressRuleValue{
Paths: []networkingv1.HTTPIngressPath{
Expand Down
5 changes: 3 additions & 2 deletions internal/manifests/collector/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func Routes(cfg config.Config, logger logr.Logger, otelcol v1alpha1.OpenTelemetr

routes := make([]*routev1.Route, len(ports))
for i, p := range ports {
portName := naming.PortName(p.Name, p.Port)
routes[i] = &routev1.Route{
ObjectMeta: metav1.ObjectMeta{
Name: naming.Route(otelcol.Name, p.Name),
Expand All @@ -77,8 +78,8 @@ func Routes(cfg config.Config, logger logr.Logger, otelcol v1alpha1.OpenTelemetr
},
},
Spec: routev1.RouteSpec{
Host: p.Name + "." + otelcol.Spec.Ingress.Hostname,
Path: "/" + p.Name,
Host: fmt.Sprintf("%s.%s", portName, otelcol.Spec.Ingress.Hostname),
Path: "/",
To: routev1.RouteTargetReference{
Kind: "Service",
Name: naming.Service(otelcol.Name),
Expand Down
13 changes: 13 additions & 0 deletions kind-1.19.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,16 @@ apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
image: kindest/node:v1.19.16@sha256:476cb3269232888437b61deca013832fee41f9f074f9bed79f57e4280f7c48b7
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
extraPortMappings:
- containerPort: 80
hostPort: 80
protocol: TCP
- containerPort: 443
hostPort: 443
protocol: TCP
13 changes: 13 additions & 0 deletions kind-1.20.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,16 @@ apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
image: kindest/node:v1.20.15@sha256:a32bf55309294120616886b5338f95dd98a2f7231519c7dedcec32ba29699394
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
extraPortMappings:
- containerPort: 80
hostPort: 80
protocol: TCP
- containerPort: 443
hostPort: 443
protocol: TCP
13 changes: 13 additions & 0 deletions kind-1.21.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,16 @@ apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
image: kindest/node:v1.21.14@sha256:8a4e9bb3f415d2bb81629ce33ef9c76ba514c14d707f9797a01e3216376ba093
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
extraPortMappings:
- containerPort: 80
hostPort: 80
protocol: TCP
- containerPort: 443
hostPort: 443
protocol: TCP
13 changes: 13 additions & 0 deletions kind-1.22.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,16 @@ apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
image: kindest/node:v1.22.17@sha256:f5b2e5698c6c9d6d0adc419c0deae21a425c07d81bbf3b6a6834042f25d4fba2
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
extraPortMappings:
- containerPort: 80
hostPort: 80
protocol: TCP
- containerPort: 443
hostPort: 443
protocol: TCP
13 changes: 13 additions & 0 deletions kind-1.23.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,16 @@ apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
image: kindest/node:v1.23.17@sha256:59c989ff8a517a93127d4a536e7014d28e235fb3529d9fba91b3951d461edfdb
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
extraPortMappings:
- containerPort: 80
hostPort: 80
protocol: TCP
- containerPort: 443
hostPort: 443
protocol: TCP
13 changes: 13 additions & 0 deletions kind-1.24.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,16 @@ apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
image: kindest/node:v1.24.15@sha256:7db4f8bea3e14b82d12e044e25e34bd53754b7f2b0e9d56df21774e6f66a70ab
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
extraPortMappings:
- containerPort: 80
hostPort: 80
protocol: TCP
- containerPort: 443
hostPort: 443
protocol: TCP
13 changes: 13 additions & 0 deletions kind-1.25.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,16 @@ apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
image: kindest/node:v1.25.11@sha256:227fa11ce74ea76a0474eeefb84cb75d8dad1b08638371ecf0e86259b35be0c8
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
extraPortMappings:
- containerPort: 80
hostPort: 80
protocol: TCP
- containerPort: 443
hostPort: 443
protocol: TCP
13 changes: 13 additions & 0 deletions kind-1.26.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,16 @@ apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
image: kindest/node:v1.26.6@sha256:6e2d8b28a5b601defe327b98bd1c2d1930b49e5d8c512e1895099e4504007adb
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
extraPortMappings:
- containerPort: 80
hostPort: 80
protocol: TCP
- containerPort: 443
hostPort: 443
protocol: TCP
13 changes: 13 additions & 0 deletions kind-1.27.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,16 @@ apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
image: kindest/node:v1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
extraPortMappings:
- containerPort: 80
hostPort: 80
protocol: TCP
- containerPort: 443
hostPort: 443
protocol: TCP
5 changes: 1 addition & 4 deletions pkg/collector/reconcile/ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ func TestExpectedIngresses(t *testing.T) {
err = params.Client.Get(ctx, nns, got)
assert.NoError(t, err)

gotHostname := got.Spec.Rules[0].Host
if gotHostname != expectHostname {
t.Errorf("host name is not up-to-date. expect: %s, got: %s", expectHostname, gotHostname)
}
assert.Equal(t, "web.something-else.com", got.Spec.Rules[0].Host)

if v, ok := got.Annotations["blub"]; !ok || v != "blob" {
t.Error("annotations are not up-to-date. Missing entry or value is invalid.")
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e-openshift/route/00-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ metadata:
name: simplest
spec:
host: otlp-grpc.example.com
path: /otlp-grpc
path: /
port:
targetPort: otlp-grpc
to:
Expand Down
23 changes: 14 additions & 9 deletions tests/e2e/ingress/00-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: simplest-collector
status:
readyReplicas: 1
---
apiVersion: networking.k8s.io/v1
kind: Ingress
Expand All @@ -21,20 +23,23 @@ metadata:
name: simplest
spec:
rules:
- host: example.com
- host: otlp-grpc.test.otel
http:
paths:
- backend:
service:
name: simplest-collector
port:
name: otlp-grpc
path: /otlp-grpc
pathType: Prefix
- backend:
service:
name: simplest-collector
port:
name: otlp-http
path: /otlp-http
path: /
pathType: Prefix
- host: otlp-http.test.otel
http:
paths:
- backend:
service:
name: simplest-collector
port:
name: otlp-http
path: /
pathType: Prefix
2 changes: 1 addition & 1 deletion tests/e2e/ingress/00-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ spec:
mode: "deployment"
ingress:
type: ingress
hostname: "example.com"
hostname: "test.otel"
annotations:
something.com: "true"
config: |
Expand Down
8 changes: 8 additions & 0 deletions tests/e2e/ingress/01-report-http-spans.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
commands:
- script: |
#!/bin/bash
set -ex
# Export empty payload and check of collector accepted it with 2xx status code
for i in {1..40}; do curl --fail -ivX POST --resolve 'otlp-http.test.otel:80:127.0.0.1' http://otlp-http.test.otel:80/v1/traces -H "Content-Type: application/json" -d '{}' && break || sleep 1; done

0 comments on commit 4f00da7

Please sign in to comment.