Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
kustomizeでCustomResourceにいい感じにStrategicMergePat...
Search
s-shirayama
August 26, 2021
Technology
1.8k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
kustomizeでCustomResourceにいい感じにStrategicMergePatchする / StrategicMergePatch to CustomResource with Kustomize
Kubernetes Meetup Tokyo #44のLT発表資料です。
https://k8sjp.connpass.com/event/218143/
s-shirayama
August 26, 2021
More Decks by s-shirayama
See All by s-shirayama
安心・安全なCluster移行で実現するKubernetesのバージョンアップ / Kubernetes upgrade with cluster migration
sshirayama
1
1.2k
How Istio helped us investigate failures on our microservices
sshirayama
0
93
継続的なバージョンアップのためのテスト戦略 〜自動テストの導入とコンテナ化〜 / Testing Strategy for Continuous Version Up
sshirayama
1
810
Other Decks in Technology
See All in Technology
AIに攻撃される前に、AIに攻撃させる
tsuchikazu
0
170
無理せず続ける、子育てエンジニアの学び
codmoninc
PRO
0
550
事業活動を AI Ready にする攻めと守りのデータエンジニアリング / data-engineering-for-ai-ready-business
pei0804
6
2.3k
AI時代のPRレビューにどう向き合うか?
kairim0
1
130
go-sqletch
moznion
0
130
IoTデバイスを繋げるプロトコルMatterをAndroidで使用する方法
harutiro
0
120
12 個 Tool と、 4,096 Token
hlum
0
110
メルペイ 会計システム概要と歴史
mewuto
0
200
プロダクト価値を、 チームが使える判断軸に変える
vivion
0
140
生成AIと進める探索的データ分析(2026.10.03 第122回Tokyo.R勉強会)
tatamiya
2
1.5k
OSC2026on_the-world-is-waiting-for-your-voice.pdf
naruoga
0
370
宣言型部分更新は何を解決しどこへ向かうのか
shuta13
0
230
Featured
See All Featured
The Cost Of JavaScript in 2023
addyosmani
55
10k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
740
Darren the Foodie - Storyboard
khoart
PRO
4
4k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
The Invisible Side of Design
smashingmag
301
52k
How Software Deployment tools have changed in the past 20 years
geshan
2
35k
Testing 201, or: Great Expectations
jmmastey
46
8.3k
Thoughts on Productivity
jonyablonski
76
5.4k
Making Projects Easy
brettharned
120
6.8k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.5k
BBQ
matthewcrist
90
10k
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