-
Notifications
You must be signed in to change notification settings - Fork 28
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
crd: reduce CRD size #498
crd: reduce CRD size #498
Conversation
@@ -1,4 +1,3 @@ | |||
--- |
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.
Not sure if we need this and why controller-gen adds it, perhaps to enable concatenation via cat foo.yaml bar.yaml > baz.yaml
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 think it's fine to now have 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.
Did you mean not to have it?
size -= len(d.value) | ||
delete(d.property, "description") |
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.
Here we can do more sophisticated logic if necessary, e.g. trim description to a single sentence like in zalando-incubator/kubernetes-on-aws#5980
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.
Also this is not exactly precise as removing description also reduces json size by the len("description")
plus quotes and colon. Strict implementation should recalculate actual size after removal by serializing into json.
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.
interesting :)
Oh, oh:
|
7e9b93c
to
3f33cfc
Compare
In theory, if the limit of |
👍 |
Yes. Another options are: use server-side apply that does not need annotation or create/update CRDs via API instead of using kubectl apply. Both require changes to https://github.com/zalando-incubator/cluster-lifecycle-manager/ Also StackSet embeds descriptions for for k8s.io types which may grow over time and CRD may theoretically hit the limit of k8s object size (~1.5Mb). |
Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
3f33cfc
to
ab6b7a3
Compare
👍 |
1 similar comment
👍 |
See zalando-incubator/stackset-controller#498 Followup on #5980 Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
Stack and StackSet CRDs were update to not exceed annotation size limit, see zalando-incubator/stackset-controller#498 Note that CRDs are not verbatim copies but contain conditional blocks. Templates were commented to make CRDs valid yaml. Followup on #5980 Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
Stack and StackSet CRDs were updated to not exceed annotation size limit, see zalando-incubator/stackset-controller#498 Note that CRDs are not verbatim copies but contain conditional blocks. Templates were commented to make CRDs valid yaml. Followup on #5980 Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
Stack and StackSet CRDs were updated to not exceed annotation size limit, see zalando-incubator/stackset-controller#498 Note that CRDs are not verbatim copies but contain conditional blocks. Templates were commented to make CRDs valid yaml. Followup on #5980 Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
Stack and StackSet CRDs were updated to not exceed annotation size limit, see zalando-incubator/stackset-controller#498 Note that CRDs are not verbatim copies but contain conditional blocks. Templates were commented to make CRDs valid yaml. Followup on #5980 Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
Why
When CRD is applied via
kubectl apply -f docs/stackset_crd.yaml
(aka client-side apply) kubectl storesCRD content into the kubectl.kubernetes.io/last-applied-configuration annotation which has
size limit of 262144 bytes.
If the size of the annotation exceeds the limit, kubectl will fail with the following error:
See kubernetes/kubectl#712
The CRD contains a lot of descriptions for k8s.io types and controller-gen
does not allow to skip descriptions per field or per package,
see kubernetes-sigs/controller-tools#441
How
It removes descriptions starting at the deepest level of the yaml tree
until the size of the yaml converted to json is less than the maximum allowed annotation size.