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

Add ingress options #1128

Merged
merged 10 commits into from
Oct 11, 2022
Merged

Conversation

frzifus
Copy link
Member

@frzifus frzifus commented Sep 27, 2022

Part of: #902

Example:

apiVersion: opentelemetry.io/v1alpha1
kind: OpenTelemetryCollector
metadata:
  name: simplest
spec:
  mode: "deployment"
  ingress:
    type: ingress
    hostname: ""
    annotations:
      something.com: "true"
  config: |
    receivers:
      otlp:
        protocols:
          grpc:
          http:
    processors:
      memory_limiter:
        check_interval: 1s
        limit_percentage: 75
        spike_limit_percentage: 15
      batch:
        send_batch_size: 10000
        timeout: 10s

    exporters:
      logging:

    service:
      pipelines:
        traces:
          receivers: [otlp]
          processors: []
          exporters: [logging]

Configure kind:

cat <<EOF | kind create cluster --config=-
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
  kubeadmConfigPatches:
  - |
    kind: InitConfiguration
    nodeRegistration:
      kubeletExtraArgs:
        node-labels: "ingress-ready=true"
  extraPortMappings:
  - containerPort: 80
    hostPort: 80
    protocol: TCP
  - containerPort: 443
    hostPort: 443
    protocol: TCP
EOF

@frzifus frzifus force-pushed the add_ingress_options branch 3 times, most recently from d2d45d4 to b8a6bbc Compare October 6, 2022 12:57
@frzifus frzifus marked this pull request as ready for review October 6, 2022 13:40
@frzifus frzifus requested a review from a team October 6, 2022 13:40
Copy link
Member

@pavolloffay pavolloffay left a comment

Choose a reason for hiding this comment

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

There are missing tests for this PR - controller, e2e.

apis/v1alpha1/opentelemetrycollector_types.go Outdated Show resolved Hide resolved
apis/v1alpha1/opentelemetrycollector_types.go Show resolved Hide resolved
@frzifus frzifus force-pushed the add_ingress_options branch 4 times, most recently from 003e709 to 2bf168b Compare October 10, 2022 12:24
@frzifus frzifus force-pushed the add_ingress_options branch from 2bf168b to 409d6e4 Compare October 10, 2022 15:03
@pavolloffay
Copy link
Member

linting failed

@frzifus frzifus force-pushed the add_ingress_options branch from 409d6e4 to 9f50e48 Compare October 10, 2022 15:34
@frzifus
Copy link
Member Author

frzifus commented Oct 10, 2022

y, iam working on it. Think i messed up some things while reordering my commits 🤦

Copy link
Member

@pavolloffay pavolloffay left a comment

Choose a reason for hiding this comment

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

Some comments:

  • the webhook is missing tests
  • there is a missing constant for none with a defaulting webhook (if a webhook is needed to set it as default).

apis/v1alpha1/ingress_type.go Outdated Show resolved Hide resolved
apis/v1alpha1/ingress_type.go Outdated Show resolved Hide resolved
apis/v1alpha1/ingress_type.go Outdated Show resolved Hide resolved
apis/v1alpha1/opentelemetrycollector_types.go Outdated Show resolved Hide resolved
apis/v1alpha1/opentelemetrycollector_types.go Outdated Show resolved Hide resolved
apis/v1alpha1/opentelemetrycollector_webhook.go Outdated Show resolved Hide resolved
@@ -166,5 +167,12 @@ func (r *OpenTelemetryCollector) validateCRDSpec() error {

}

mode := strings.ToLower(string(r.Spec.Mode))
if r.Spec.Ingress.Type == IngressTypeNginx && (mode == "deployment" || mode == "daemonset" || mode == "statefulset") {
Copy link
Member

Choose a reason for hiding this comment

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

for mode it's better to use the defined mode constants

Copy link
Member

Choose a reason for hiding this comment

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

The if statement does not seem correct. It can be easier to compare if the mode is sidecar as it is the only not supported config.

Copy link
Member Author

Choose a reason for hiding this comment

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

you mean r.Spec.Ingress.Type == IngressTypeNginx && r.Spec.Mode != ModeSidecar ? Thats the check i made in the beginning. But as soon as another mode gets added, the condition is invalid.

Copy link
Member

Choose a reason for hiding this comment

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

I mean r.Spec.Ingress.Type == IngressTypeNginx && r.Spec.Mode == ModeSidecar then throw an error.

If a new mode is added we don't know if ingress will be supported or not

Copy link
Member Author

Choose a reason for hiding this comment

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

my intention to test for the supported modis was to be a bit more restrictive. If a new mode is added, the documentation will have to be adapted anyway. But have there no strong opinion and changed it. :)

apis/v1alpha1/opentelemetrycollector_webhook.go Outdated Show resolved Hide resolved

// Hostname by which the ingress proxy can be reached.
// +optional
Hostname string `json:"hostname,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Could you please explain this configuration? Why is it needed?

https://kubernetes.io/docs/concepts/services-networking/ingress/

PS: I don't have much experience with ingress so I might ask something stupid here.

Copy link
Member Author

Choose a reason for hiding this comment

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

With the ingress entry we want to direct incoming traffic on port 80 or 443 to our service. Without a set hostname, this applies to all domains, which can not be intentional. For example if traffic with the same path but from another domain should be directed to another service.

It could look like this:

NAMESPACE  NAME            HOST/PORT            PATH     SERVICES                  PORT
test123    jaeger-skupper  example.com          /traces  jaeger-skupper-collector  https-collector
test456    jaeger-ingress  another-example.com  /traces  jaeger-ingress-collector  grpc-collector

@frzifus frzifus force-pushed the add_ingress_options branch 3 times, most recently from dcc99bb to 3854e23 Compare October 10, 2022 18:48
@frzifus frzifus force-pushed the add_ingress_options branch 3 times, most recently from 54c8a0b to cdd3815 Compare October 10, 2022 19:47
apis/v1alpha1/ingress_type.go Show resolved Hide resolved
apis/v1alpha1/opentelemetrycollector_types.go Outdated Show resolved Hide resolved
pkg/collector/reconcile/ingress.go Outdated Show resolved Hide resolved
Signed-off-by: Benedikt Bongartz <[email protected]>
Signed-off-by: Benedikt Bongartz <[email protected]>
@frzifus frzifus force-pushed the add_ingress_options branch from cdd3815 to dd031a6 Compare October 11, 2022 09:20
@frzifus frzifus requested a review from pavolloffay October 11, 2022 09:22
@pavolloffay pavolloffay merged commit 8783fe1 into open-telemetry:main Oct 11, 2022
@frzifus frzifus deleted the add_ingress_options branch October 11, 2022 10:33
ItielOlenick pushed a commit to ItielOlenick/opentelemetry-operator that referenced this pull request May 1, 2024
* add ingress name generation function

Signed-off-by: Benedikt Bongartz <[email protected]>

* extend otelcol crd with minimalistic ingress options

Signed-off-by: Benedikt Bongartz <[email protected]>

* support collector ingress reconciling

Signed-off-by: Benedikt Bongartz <[email protected]>

* register ingress reconciler

Signed-off-by: Benedikt Bongartz <[email protected]>

* grant permission to create, modify and delete ingress entries

Signed-off-by: Benedikt Bongartz <[email protected]>

* add ingress integration tests

Signed-off-by: Benedikt Bongartz <[email protected]>

* verify if collector mode is compatible with ingress settings

Signed-off-by: Benedikt Bongartz <[email protected]>

* create dedicated ingress type

Signed-off-by: Benedikt Bongartz <[email protected]>

* follow recommendations

Signed-off-by: Benedikt Bongartz <[email protected]>

* regenerate

Signed-off-by: Benedikt Bongartz <[email protected]>

Signed-off-by: Benedikt Bongartz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants