Kubernetes 对象大小限制

Kubernetes object size limitations

我正在处理 CRD 并创建自定义资源。我需要在自定义资源中保留有关我的应用程序的大量信息。根据官方文档,etcd 可处理高达 1.5MB 的请求。我遇到了类似

的错误

"error": "Request entity too large: limit is 3145728"

我相信错误中指定的限制是 3MB。对此有什么想法吗?这个问题有什么出路吗?

  • "error": "Request entity too large: limit is 3145728" 可能是 kubernetes 处理程序对大于 3MB 的对象的默认响应,如源代码的 here at L305 所示:
expectedMsgFor1MB := `etcdserver: request is too large`
expectedMsgFor2MB := `rpc error: code = ResourceExhausted desc = trying to send message larger than max`
expectedMsgFor3MB := `Request entity too large: limit is 3145728`
expectedMsgForLargeAnnotation := `metadata.annotations: Too long: must have at most 262144 bytes`
  • ETCD has indeed a 1.5MB limit for processing a file and you will find on ETCD Documentation 建议尝试 --max-request-bytes 标志,但它对 GKE 集群没有影响,因为您在主节点上没有这样的权限。

  • 但即使你这样做了,也不是理想的,因为通常这个错误意味着你在 consuming the objects 而不是引用它们,这会降低你的性能。

我强烈建议您考虑以下选项:

  • 确定您的对象是否包含未使用的引用;
  • 分解你的资源;
  • 考虑安装卷;

有人请求 new API Resource: File (orBinaryData) 可以适用于您的情况。很新鲜,不过留个心眼也不错

如果您仍然需要帮助,请告诉我。

如果您使用的是 HELM,请检查您是否有像日志文件这样的大文件。添加 .helmignore

.DS_Store
# Common VCS dirs
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

*.log

当我在我的 Helm 图表目录中放置一些大文件时,这发生在我身上。删除这些文件帮助我解决了问题。