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

Use Operator SDK framework #387

Merged
merged 2 commits into from
Oct 31, 2019
Merged

Conversation

zroubalik
Copy link
Member

@zroubalik zroubalik commented Oct 17, 2019

Keda controller is rewritten to use operator-sdk framework. The controller logic was simplified removing informers, locks...

Usage changes

  • adding Operator SDK tooling Use Operator SDK #54
  • enable Keda to be deployed as namespaced/cluster-wide controller, ie. there can be deployed multiple Keda controllers, each serving specific namespace only

Major internal changes

  • changes on ScaledObject are handled by Reconcile loop, it creates and manages lifecycle of the relevant HPA(in case of deploment) and then starting Scale Loop
  • created dependent resources are properly deleted by Finalizer on ScaledObject
  • operator is not holding any state in the code (previously sync.RWMutex in ScaleHandler, etc)
  • External Metrics Names are stored in the ScaledObejct Status
  • not using Clientset anymore, but using Controller Runtime Client API
  • Metrics adapter was moved to the separate container, GetExternalMetricNames() and GetScaledObjectMetrics() are moved from ScaleHandler directly to the provider
  • now using Structured logging provided by Operator SDK Logging,
  • Debug log messages previously logged via log.Debug(msg) are now logged under Level 1, ie. log.V(1).Info(msg), this allow us to add more granularity in logging in the future (introduce Level 2/3/4 if needed)
  • Permissions were a little bit restricted, previous were to wide (cluster-admin for keda-operator SA)

Deploying this version of Keda

This implementation can be deployed by running these commands, it is expecting existing keda namespace

git clone https://github.com/zroubalik/keda.git -b operator-sdk
cd keda
sed -i 's/kedacore/zroubalik/g' deploy/operator.yaml  
kubectl apply -f deploy/crds/keda.k8s.io_scaledobjects_crd.yaml
kubectl apply -f deploy/crds/keda.k8s.io_triggerauthentications_crd.yaml
kubectl apply -f deploy/

TODO

  • set appropriate loging levels V(?) for log messages previously marked as Debug sections in the code (Debug -> V(1))
  • tweak adapter logging
  • test adapter (Kafka scaler working correctly)
  • test namespaced vs cluster wide operator

@msftclas
Copy link

msftclas commented Oct 17, 2019

CLA assistant check
All CLA requirements met.

@zroubalik zroubalik force-pushed the operator-sdk branch 5 times, most recently from 6149b84 to 8b62b50 Compare October 18, 2019 03:25
@zroubalik
Copy link
Member Author

Into PR's description I've added instructions on how to deploy this code.

@zroubalik zroubalik force-pushed the operator-sdk branch 3 times, most recently from 314fecc to 0ce4182 Compare October 18, 2019 20:45
@zroubalik zroubalik changed the title [WIP] Use Operator SDK framework Use Operator SDK framework Oct 18, 2019
@zroubalik
Copy link
Member Author

I've tweaked rest of the outstanding minor issues. I've tested this on OpenShift 4 using Kafka trigger, worked as expected. The code is ready for a Review and Merge.

Helm chart update might be needed after merging this PR

@zroubalik zroubalik force-pushed the operator-sdk branch 3 times, most recently from 18f2056 to e720356 Compare October 21, 2019 20:32
@zroubalik
Copy link
Member Author

@tomkerkhove you might be interested to take a look on this PR

@tomkerkhove
Copy link
Member

Thanks for the ping @zroubalik but I'll leave it up to @ahmelsayed as I'm not that knowledgeable on this level.

@jeffhollan
Copy link
Member

I'll spend some time this week to test out this fork, @ahmelsayed plans to review sometime in the next week

@jeffhollan
Copy link
Member

Validated that this works with my demos around Service Bus and Rabbit MQ. Thanks @zroubalik


COPY build/_output/bin/keda-adapter ${OPERATOR}

COPY build/bin /usr/local/bin
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this line is not needed, right? It fails for me on both images on a make build. Removing it from both resolves the issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually I think that folder is just missing the user_setup script.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, thanks. .gitignore was too strict and prevented pushing those files. There's so much files, so I haven't noticed that. I'll fix it in a few.

Copy link
Member Author

Choose a reason for hiding this comment

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

@ahmelsayed should be fixed now, PTAL

Copy link
Contributor

@ahmelsayed ahmelsayed left a comment

Choose a reason for hiding this comment

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

Thank you very much @zroubalik. The change looks good to me. instead of going over every file change here, I tested main scenarios and make sure I can read the new operator-sdk code.

make build has that one issue about the missing bin folder, but it's a very minor thing. I'll merge it once you add that folder (or I can also just merge it and send a PR with it since I already need to update some of the CI scripts)

@zroubalik
Copy link
Member Author

@ahmelsayed @jeffhollan I have added one last minor change. The original cluster permissions were to wide (granting cluster-admin to the keda SA). I have restricted the permissions a little bit and have tested it and working for me. I might want to test it with your scenarios or at least one :)

@ahmelsayed ahmelsayed merged commit 10c92ff into kedacore:master Oct 31, 2019
@@ -1,115 +1,74 @@
module github.com/kedacore/keda

go 1.13
go 1.13.1
Copy link
Contributor

Choose a reason for hiding this comment

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

The go version is supposed to be "go ." this is producing that I'm not able to use this package as dependency for a controller.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks a lot!

@zroubalik zroubalik deleted the operator-sdk branch August 11, 2020 11:32
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.

6 participants