-
Notifications
You must be signed in to change notification settings - Fork 41
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
feat(k8s): init operator project & add webhook #259
Conversation
Codecov Report
@@ Coverage Diff @@
## master #259 +/- ##
============================================
- Coverage 85.86% 85.72% -0.14%
+ Complexity 3235 3232 -3
============================================
Files 344 344
Lines 12115 12115
Branches 1092 1092
============================================
- Hits 10402 10386 -16
- Misses 1190 1207 +17
+ Partials 523 522 -1
... and 5 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Hi @coderzc @imbajin @simon824 @javeme , Now,
We have to update doc, images, resource yaml file, I will be appreciated if you can instruct me how to finish these :D |
...uter-k8s/src/main/java/org/apache/hugegraph/computer/k8s/crd/model/HugeGraphComputerJob.java
Show resolved
Hide resolved
Good job! BTY,I think we should consider rewriting controller in the future using the Go API. |
Hi @coderzc , I have updated deployment guide in PR description. Can you help test it when you are available? |
computer-k8s-operator/crd-generate/api/v1/hugegraphcomputerjob_webhook.go
Outdated
Show resolved
Hide resolved
computer-k8s-operator/crd-generate/config/default/kustomization.yaml
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some tiny comments
) | ||
|
||
var ( | ||
scheme = runtime.NewScheme() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redundant spaces?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not redundant, which is go's align way.
"sigs.k8s.io/controller-runtime/pkg/log/zap" | ||
|
||
operatorv1 "hugegraph.apache.org/operator/api/v1" | ||
//+kubebuilder:scaffold:imports |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we removed the unused code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These comments are used by kubebuilder
to locate code places for future possible auto-generation. We can not remove these, unless we maintain this file by ourselves from now on.
utilruntime.Must(clientgoscheme.AddToScheme(scheme)) | ||
|
||
utilruntime.Must(operatorv1.AddToScheme(scheme)) | ||
//+kubebuilder:scaffold:scheme |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
|
||
setupLog.Info("starting manager") | ||
if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil { | ||
setupLog.Error(err, "problem running manager") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefer "Failed to start Manager"
// LeaderElectionReleaseOnCancel: true, | ||
}) | ||
if err != nil { | ||
setupLog.Error(err, "unable to start manager") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefer "Unable to create Manager"
}) | ||
if err != nil { | ||
setupLog.Error(err, "unable to start manager") | ||
os.Exit(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we just return err
?
|
||
if err = (&operatorv1.HugeGraphComputerJob{}).SetupWebhookWithManager(mgr); err != nil { | ||
setupLog.Error(err, "unable to create webhook", "webhook", "HugeGraphComputerJob") | ||
os.Exit(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
setupLog.Info("starting manager") | ||
if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil { | ||
setupLog.Error(err, "problem running manager") | ||
os.Exit(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These os.Exit(1)
and above log message are auto-generated, do we have to modify them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, let's just keep as it is
computer-k8s-operator/crd-generate/config/default/manager_config_patch.yaml
Outdated
Show resolved
Hide resolved
setupLog.Info("starting manager") | ||
if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil { | ||
setupLog.Error(err, "problem running manager") | ||
os.Exit(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, let's just keep as it is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Busy with other tasks before 🚌
Thanks for the contribution, merge it now
Purpose of the PR
Main Changes
Webhook
to deny update. Launch pod with two containers (originalcontroller
and newmanager
).List some TODO here:
apiVersion "apiextensions.k8s.io/v1beta1" is not supported
when executingmake gen-all
under crd-generateVerifying these changes
If you execute
kubectl create -f hugegraphjob.yaml
twice, you can get error log:You can do the following things for local test
computer-k8s-operator/manifests
, or you can generate by yourself.cd computer-k8s-operator/crd-generate make gen-all
Does this PR potentially affect the following parts?
Documentation Status
Doc - TODO
Doc - Done
Doc - No Need