$30 off During Our Annual Pro Sale. View Details »
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.7k
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
67
継続的なバージョンアップのためのテスト戦略 〜自動テストの導入とコンテナ化〜 / Testing Strategy for Continuous Version Up
sshirayama
1
770
Other Decks in Technology
See All in Technology
インフラ室事例集
mixi_engineers
PRO
2
190
ECMAScript仕様の最新動向: プロセスの変化と仕様のトレンド
uhyo
2
310
Kill the Vibe?Architecture in the age of AI
stoth
1
160
経営から紐解くデータマネジメント
pacocat
9
1.9k
履歴テーブル、今回はこう作りました 〜 Delegated Types編 〜 / How We Built Our History Table This Time — With Delegated Types
moznion
14
9k
Flutter Thread Merge - Flutter Tokyo #11
itsmedreamwalker
1
130
『星の世界の地図の話: Google Sky MapをAI Agentでよみがえらせる』 - Google Developers DevFest Tokyo 2025
taniiicom
0
470
プラットフォームエンジニアリングとは何であり、なぜプラットフォームエンジニアリングなのか
doublemarket
1
520
DGX SparkでローカルLLMをLangChainで動かした話
ruzia
1
240
"'TSのAPI型安全”の対価は誰が払う?不公平なスキーマ駆動に終止符を打つハイブリッド戦略
hal_spidernight
0
220
GitHub を組織的に使いこなすために ソニーが実践した全社展開のプラクティス
sony
21
11k
私も懇親会は苦手でした ~苦手だからこそ懇親会を楽しむ方法~ / 20251127 Masaki Okuda
shift_evolve
PRO
4
530
Featured
See All Featured
Rebuilding a faster, lazier Slack
samanthasiow
84
9.3k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.8k
Java REST API Framework Comparison - PWX 2021
mraible
34
9k
Site-Speed That Sticks
csswizardry
13
980
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.5k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
46
7.8k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
13k
Unsuck your backbone
ammeep
671
58k
Designing for Performance
lara
610
69k
Building an army of robots
kneath
306
46k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.5k
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