41

记一次使用 Kustomize 时遇到的愚蠢问题

 4 years ago
source link: https://www.tuicool.com/articles/6z6JJnQ
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

现象

在日常 CI/CD 流程中,已经将 Kustomize 集成到 pipeline 中使用,但是在对一个项目进行 Kustomize 改造时,将单个 deploy.yaml 拆分为了若干个 patch 以达到灵活 Kubernetes 部署的目的。但是在使用 kubectl apply -k . 命令进行部署的时候遇到了 error: failed to find an object with apps_v1_Deployment|myapp to apply the patch 的报错。

VRFj22m.jpg!web

解决之路

由于之前的使用中没有遇到此类报错,看报错信息像是 apiVersion 的问题,所以先检查了所有 patch 的 apiVersion ,但是并没有找到有什么问题。

Google 搜索

对该报错进行了搜索,搜索到如下结果:

yeeUruR.jpg!webniYF3i3.jpg!web

??? 为何这个 issue 没有解决就被提出者关闭了?

问题解决

在 Google 了一圈之后还是没有找到什么有营养的回答,问题又回到了原点…只能对所有的 patch 的每个字符和每个配置逐一进行了检查。结果发现是 name 的内容 base 与 overlays 不同… base 中是 name:myapp ,而 overlays 中是 name:my-app

好吧,issue 关的是有道理的…

MneiUnF.jpg!web


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK