-
Notifications
You must be signed in to change notification settings - Fork 134
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
[ISSUE-479] [operator] refine operator's build system #491
Conversation
@wangao1236 please take a look when you have time. |
Me too. I'm not sure why this version format is used. Maybe @wangao1236 could give us some hint. |
This is just a way of differentiating versions. You can customize the version name by setting value of "IMAGE_VERSION". Maybe we can define a new way to differentiate versions. Do you have any suggestions? |
Codecov Report
@@ Coverage Diff @@
## master #491 +/- ##
============================================
+ Coverage 59.73% 59.78% +0.04%
- Complexity 1764 1770 +6
============================================
Files 205 205
Lines 11527 11531 +4
Branches 1033 1033
============================================
+ Hits 6886 6894 +8
+ Misses 4234 4232 -2
+ Partials 407 405 -2
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
|
||
MODULES ?= webhook controller | ||
|
||
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. | ||
ENVTEST_K8S_VERSION = 1.22.1 | ||
ENVTEST_K8S_VERSION = 1.24.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.
Maybe you can update it in go.mod as well?
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.
which lib should I update the version? k8s.io/api v0.22.2
-> what version?
I'm not quite family with envtest...
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.
Actually my question is why update envtest?
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 seems that the names of individual fields in k8s v1.24 have been changed, and I recommend a separate PR to change the k8s version.
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.
Actually my question is why update envtest?
To quote:upgrade envtest to 1.24.1 to support Apple M1 chips
. envtest v1.22.x doesn't support M1 chip, not publish related arm archives. So, you cannot test the controller on M1.
The operator's required k8s in go.mod doesn't change, and still goes to 1.22 (k8s.io/api v0.22.x). And RSS's operator doesn't seem to use too much advanced features.
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.
As discussed earlier, why upgrade envtest to 1.24 when you don't need to upgrade k8s to 1.24?
cc @advancedxy
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.
As discussed earlier, why upgrade envtest to 1.24 when you don't need to upgrade k8s to 1.24? cc @advancedxy
Yeah, as discussed earlier. Envtest is upgraded to 1.24 to support Apple M1's chips as 1.22 doesn't work for M1 chip.
The operator itself doesn't need to upgrade to 1.24 and it shouldn't since many K8S clusters are in old versions.
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.
As discussed earlier, why upgrade envtest to 1.24 when you don't need to upgrade k8s to 1.24? cc @advancedxy
Yeah, as discussed earlier. Envtest is upgraded to 1.24 to support Apple M1's chips as 1.22 doesn't work for M1 chip.
The operator itself doesn't need to upgrade to 1.24 and it shouldn't since many K8S clusters are in old versions.
Ok, I get it.
@@ -1,3 +1,4 @@ | |||
//go:build !ignore_autogenerated |
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.
This is due to locally dev machine's go version is 1.17 or higher(such as 1.19).
I will create a followup pr to upgrade the go version to 1.17.
WORKDIR / | ||
COPY --from=builder /workspace/${MODULE} . | ||
|
||
CMD ["${MODULE}"] |
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.
Previously, this is wrong:
- the
ARG MODULE
is not defined in the second stage. the module might be empty or undefined. - MODULE is only available in build time. You cannot start the container by default since the
MODULE
env is not defined in the container.
cc @wangao1236
@zuston could you also help review this pr. |
OK. I will take a look tomorrow, but to be honest, I don’t have much golang experience. |
Rerun CI to see if #512 can be fixed. |
@wangao1236 @kaijchen please take a look at this. I would like this to be merged today as there are other changes based on this. |
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.
I took a glance of the changes, mostly looks good.
I'm not familiar with the build-operator.sh
and the Makefile
part.
ping @wangao1236 @kaijchen |
|
||
MODULES ?= webhook controller | ||
|
||
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. | ||
ENVTEST_K8S_VERSION = 1.22.1 | ||
ENVTEST_K8S_VERSION = 1.24.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.
As discussed earlier, why upgrade envtest to 1.24 when you don't need to upgrade k8s to 1.24? cc @advancedxy
Yeah, as discussed earlier. Envtest is upgraded to 1.24 to support Apple M1's chips as 1.22 doesn't work for M1 chip.
The operator itself doesn't need to upgrade to 1.24 and it shouldn't since many K8S clusters are in old versions.
Ok, I get it.
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.
LGTM, thanks @advancedxy for the improvement.
|
||
CMD ["${MODULE}"] | ||
ENV OPERATOR_BIN=/${MODULE} | ||
ENTRYPOINT "/${OPERATOR_BIN}" |
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.
I suggest using exec mode in dockerfile. For example, ENTRYPOINT ["${OPERATOR_BIN}"]
.
Ref: https://emmer.dev/blog/docker-shell-vs.-exec-form/
However, this does not affect normal running.
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.
Good suggestion. Let's raise a follow up pr to quick address it.
What changes were proposed in this pull request?
Why are the changes needed?
to address #479.
Does this PR introduce any user-facing change?
No
How was this patch tested?
No need