Skip to content
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

use kubectl kustomize #71

Merged
merged 1 commit into from
Jan 2, 2021
Merged

use kubectl kustomize #71

merged 1 commit into from
Jan 2, 2021

Conversation

ludwig125
Copy link
Owner

@ludwig125 ludwig125 commented Jan 2, 2021

#66
#67
これらと同じタイミングで、kustomize build時にダブルクォーテーションがつかなくなってしまうという問題が発生した

kustomize version

root@987cbe951fe4:~/go/src/github.com/ludwig125#   ./kustomize version
--
{Version:kustomize/v3.9.1   GitCommit:7439f1809e5ccd4677ed52be7f98f2ad75122a93   BuildDate:2020-12-29T19:25:35Z GoOs:linux GoArch:amd64}
root@987cbe951fe4:~/go/src/github.com/ludwig125#

例えば、以下のように変数にダブルクォーテーション””をつけてbuildしてみる

  • CALC_GROWTHTREND_CONCURRENCY="1"
  • 以下はcircleciのビルド環境で実施したもの
root@987cbe951fe4:~/go/src/github.com/ludwig125#   grep -r CALC_GROWTHTREND_CONCURRENCY k8s/
k8s/overlays/prod/kustomization.yaml:  -   CALC_GROWTHTREND_CONCURRENCY="1"
k8s/base/kustomization.yaml:  -   CALC_GROWTHTREND_CONCURRENCY="3"

kustomize buldするとダブルクォーテーションがなくなっている

root@987cbe951fe4:~/go/src/github.com/ludwig125#   ./kustomize build ./k8s/overlays/prod/ > prod.yaml
cat prod.yaml

略

apiVersion: v1
--
data:
CALC_GROWTHTREND_CONCURRENCY: 1
CALC_MOVINGAVG_CONCURRENCY: 1
CHECK_DAYOFF: "on"

略

このyamlをapplyしようとすると、文字と認識できずにエラーが出る

# kubectl apply -f configmap.yaml

Error from server (BadRequest): error when creating "STDIN": 
ConfigMap in version "v1" cannot be handled as a ConfigMap: v1.ConfigMap.Data: ReadString: expects " or n, but found 1, 
error found in #10 byte of ...|URRENCY":1,"CALC_MOV|..., bigger context ...|ion":"v1","data":{"CALC_GROWTHTREND_CONCURRENCY":1,"CALC_MOVINGAVG_CONCURRENCY":1,"CHECK_DAYOFF":"on|...

どうやってもkustomize buildの結果にダブルクォーテーションをつけることができなかった。。

この問題を解決できないので、この機会にkubectl kustomizeを使うことにした

baseディレクトリの参照方法は
resourcesではなくbasesにする必要があるので修正

resourcesのままだと以下のようなエラーがでる
root@987cbe951fe4:~/go/src/github.com/ludwig125# kubectl kustomize k8s/overlays/prod
Error: rawResources failed to read Resources: Load from path ../../base failed: '../../base' must be a file (got d='/root/go/src/github.com/ludwig125/k8s2/base')

参考

kubernetes-sigs/kustomize#766 (comment)
kubernetes-sigs/kustomize#776 (comment)

kubectl 公式
https://kubernetes.io/docs/tasks/manage-kubernetes-objects/kustomization/#bases-and-overlays

@ludwig125 ludwig125 merged commit ff89d82 into master Jan 2, 2021
@ludwig125 ludwig125 deleted the use_kubectl_kustomize branch January 2, 2021 23:04
ludwig125 added a commit that referenced this pull request Feb 2, 2021
ludwig125 added a commit that referenced this pull request Feb 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant