konpyutaika / nifikop

The NiFiKop NiFi Kubernetes operator makes it easy to run Apache NiFi on Kubernetes. Apache NiFI is a free, open-source solution that support powerful and scalable directed graphs of data routing, transformation, and system mediation logic.
https://konpyutaika.github.io/nifikop/
Apache License 2.0
123 stars 40 forks source link

Ability to set port network protocol (TCP/UDP) and LoadBalancerClass in externalServices #331

Closed TimMilton closed 7 months ago

TimMilton commented 7 months ago

Type of question

Best Practices

Support question

Hello. Thank you for adding new feature set container port network protocol. But is there any way to add ability to change port network protocol (TCP/UDP) in externalServices? We are using AWS ALB/NLB. Due to the impossibility of assigning a protocol in the NiFi configuration file, we applied the changes manually in yaml of the service. This led to the fact that after applying changes to nifi yaml configuration, NiFiKop operator unsuccessfully tries to apply changes and it gives an error:

{"level":"error","time":"2023-12-11T07:59:17.457Z","caller":"controller/controller.go:329","msg":"Reconciler error","controller":"nificluster","controllerGroup":"nifi.konpyutaika.com","controllerKind":"NifiCluster","nifiCluster":{"name":"nifi","namespace":"nifi"},"namespace":"nifi","name":"nifi","reconcileID":"b5e0bdca-6f32-4491-9df4-6b8886160e67","error":"failed to reconcile resource: updating resource failed: Service \"nlb\" is invalid: spec.loadBalancerClass: Invalid value: \"null\": may not change once set","errorVerbose":"updating resource failed: Service \"nlb\" is invalid: spec.loadBalancerClass: Invalid value: \"null\": may not change once set\nfailed to reconcile resource\ngithub.com/konpyutaika/nifikop/pkg/resources/nifi.(*Reconciler).Reconcile\n\t/workspace/pkg/resources/nifi/nifi.go:196\ngithub.com/konpyutaika/nifikop/controllers.(*NifiClusterReconciler).Reconcile\n\t/workspace/controllers/nificluster_controller.go:145\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.6/pkg/internal/controller/controller.go:122\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.6/pkg/internal/controller/controller.go:323\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.6/pkg/internal/controller/controller.go:274\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.6/pkg/internal/controller/controller.go:235\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_arm64.s:1197","stacktrace":"sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.6/pkg/internal/controller/controller.go:329\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.6/pkg/internal/controller/controller.go:274\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.14.6/pkg/internal/controller/controller.go:235"}

Seems, NiFiKop operator also can't downscale pods because of that error.

NiFiKop version

v1.5.0-release

Golang version

-

Kubernetes version

Client Version: v1.28.2 Server Version: v1.28.2-eks

NiFi version

1.23.2

Carverook commented 7 months ago

Hello. We are looking forward to your assistance on this matter. This problem blocks nifi scaling. @mh013370 @juldrixx

mh013370 commented 7 months ago

Definitely isn't possible currently, but i'll raise a PR for this. I believe we can just do the same thing we did for container ports.

Carverook commented 7 months ago

We will be very happy. Maybe tell me some solution now to make scaling work. And what is the general reason for the error, why is the operator trying to change the LoadBalancerClass field?

mh013370 commented 7 months ago

We will be very happy. Maybe tell me some solution now to make scaling work. And what is the general reason for the error, why is the operator trying to change the LoadBalancerClass field?

nifikop doesn't modify the loadBalancerClass field in a Service. Here's the one and only place it modifies Service objects it creates: https://github.com/konpyutaika/nifikop/blob/master/pkg/resources/nifi/service.go#L55-L76

Can you clarify what you mean by "we applied the changes manually in yaml of the service"? When did you do this? Before or after nifikop deployed a cluster? And what field(s) did you change? Can you please share the spec?

Carverook commented 7 months ago

We changed the port protocol in the spec.ports field after nifikop deployed the cluster. For some reason, the operator wants to change the loadBalancerClass field to null, based on errors in the nifikop logs.

nlb.yaml https://gist.github.com/Carverook/26db88eb6f2cf8a0afc716dced6e57f4

mh013370 commented 7 months ago

Did you also set loadBalancerClass: service.k8s.aws/nlb? nifikop doesn't set it when it creates services, so it gets default to null.

Do you need to be able to set the loadBalancerClass? We can expose that in nifikop.

Carverook commented 7 months ago

Yeah, it would be great. Since now this is blocking possible downscaling. We will be grateful if you do this, thank you!

mh013370 commented 7 months ago

Yeah, it would be great. Since now this is blocking possible downscaling. We will be grateful if you do this, thank you!

I have added this feature to PR #335

Carverook commented 7 months ago

Thank you!

TimMilton commented 7 months ago

Thank you very much!)