Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
kustomizeでCustomResourceにいい感じにStrategicMergePat...
Search
s-shirayama
August 26, 2021
Technology
1
1.6k
kustomizeでCustomResourceにいい感じにStrategicMergePatchする / StrategicMergePatch to CustomResource with Kustomize
Kubernetes Meetup Tokyo #44のLT発表資料です。
https://k8sjp.connpass.com/event/218143/
s-shirayama
August 26, 2021
Tweet
Share
More Decks by s-shirayama
See All by s-shirayama
安心・安全なCluster移行で実現するKubernetesのバージョンアップ / Kubernetes upgrade with cluster migration
sshirayama
1
1.1k
How Istio helped us investigate failures on our microservices
sshirayama
0
64
継続的なバージョンアップのためのテスト戦略 〜自動テストの導入とコンテナ化〜 / Testing Strategy for Continuous Version Up
sshirayama
1
750
Other Decks in Technology
See All in Technology
[OCI Technical Deep Dive] OracleのAI戦略(2025年8月5日開催)
oracle4engineer
PRO
1
250
第4回 関東Kaggler会 [Training LLMs with Limited VRAM]
tascj
5
690
新卒(ほぼ)専業Kagglerという選択肢
nocchi1
0
1.6k
ABEMAにおける 生成AI活用の現在地 / The Current Status of Generative AI at ABEMA
dekatotoro
0
540
Rethinking Incident Response: Context-Aware AI in Practice - Incident Buddy Edition -
rrreeeyyy
0
130
[CV勉強会@関東 CVPR2025 読み会] MegaSaM: Accurate, Fast, and Robust Structure and Motion from Casual Dynamic Videos (Li+, CVPR2025)
abemii
0
160
2025新卒研修・Webアプリケーションセキュリティ #弁護士ドットコム
bengo4com
3
9.8k
意志の力が9割。アニメから学ぶAI時代のこれから。
endohizumi
1
110
歴代のWeb Speed Hackathonの出題から考えるデグレしないパフォーマンス改善
shuta13
5
550
kintone開発チームの紹介
cybozuinsideout
PRO
0
73k
広島発!スタートアップ開発の裏側
tsankyo
0
120
コミュニティと計画的偶発性理論 - 出会いが人生を変える / Life-Changing Encounters
soudai
PRO
7
1.1k
Featured
See All Featured
Rebuilding a faster, lazier Slack
samanthasiow
83
9.1k
StorybookのUI Testing Handbookを読んだ
zakiyama
30
6k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
9
770
Optimizing for Happiness
mojombo
379
70k
Why You Should Never Use an ORM
jnunemaker
PRO
58
9.5k
jQuery: Nuts, Bolts and Bling
dougneiner
64
7.9k
Testing 201, or: Great Expectations
jmmastey
45
7.6k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
53
2.9k
For a Future-Friendly Web
brad_frost
179
9.9k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
23
1.4k
Bash Introduction
62gerente
614
210k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Transcript
kustomizeでCustomResourceにいい感じに StrategicMergePatchする Kubernetes Meetup Tokyo #44 LT Shota Shirayama ECインキュベーション開発部
Rakuten Group, Inc.
2 kustomize 便利ですよね base overlays output + = • base/*
→ 共通の設定 • overlays/development/* → 開発環境特有の設定 • overlays/production/* → 本番環境特有の設定
3 CustomResource だと StrategicMergePatch がいい感じにあたらない base overlays output + =
Overlaysで指定したリストで置き換えられてしまう。 (kustomizeがリストを扱うときのDefaultの挙動)
4 なぜ︖ k8s Native Resource のスキーマ定義が kustomize内で参照されている。 x-kubernetes-patch-xxx で何をキーにマージ するのかが指定されている。
これが指定されていない場合、kustomizeは arrayをそのまま置き換えてしまう。 https://github.com/kubernetes- sigs/kustomize/blob/kustomize/v4.2.0/kyaml/openapi/kubernetesapi/v1204/swagger.json
5 CustomResrouce⽤の独⾃のスキーマ定義も利⽤できるようになった • v4.1.0 (2021/4/14 Release) の追加機能 • 独⾃のスキーマ定義ファイルをkustomizeで読み込むことができる https://github.com/kubernetes-
sigs/kustomize/blob/kustomize/v4.2.0/examples/customOpenAPIschema.md ただし、利⽤にはいくつか注意したい点がある
6 CR⽤のスキーマ定義利⽤時の注意点︓公式のスキーマ定義の提供がない • CustomResrouceの提供元から公式のスキーマ定義が提供されていない場合がある • 例)ArgoRolloutはIssue #1210にあがっているが未提供(2021/8/16時点) ↓ • ⾃作する必要がある。
7 CR⽤のスキーマ定義利⽤時の注意点︓ Defaultのスキーマ定義は読み込まれない • 独⾃のスキーマ定義を読み込むと、kustomizeがDefaultで読み込んでいたk8s Native Resrouceのスキーマ定義は読み込まれない。 • DeploymentなどにStrategicMergePatch がいい感じにあたらなくなる
↓ • kustomizeのDefaultで読み込まれているスキーマ定義と、独⾃のスキーマ定義を マージしたスキーマ定義ファイルを作成する DEFAULT_SCHEMA_URL= https://raw.githubusercontent.com/kubernetes- sigs/kustomize/kustomize/v4.2.0/kyaml/openapi/kubernetesapi/v1204/swagger.json
8 CR⽤のスキーマ定義利⽤時の注意点︓ Remoteのスキーマ定義は参照できない • “openapi:” では、“resources:” や “configurations:” のようにRemoteのURLを指定する ことができない
• kustomize buildするそれぞれの場所にスキーマ定義ファイルを配置しておかな ければならない ↓ • Base⽤のリポジトリを各Manifest⽤のリポジトリから参照する⽅式を採⽤した Base repo Manifest repo Manifest repo Manifest repo schema.json kustomization.yaml
9 まとめ • kustomizeでCustomResourceにいい感じにStrategicMergePatchできなかったが、 v4.1.0からはできるようになった。 • ただし、利⽤する際にはいくつか注意点がある • 公式のスキーマ定義の提供がない場合がある •
Defaultのスキーマ定義は読み込まれない • Remoteのスキーマ定義は参照できない
None