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
Helm Chart を Unit Test する / Unit Testing Helm C...
Search
d-kuro
June 24, 2021
Programming
0
2k
Helm Chart を Unit Test する / Unit Testing Helm Chart
Kubernetes Meetup Tokyo #42 で発表したスライドです
https://k8sjp.connpass.com/event/214286/
d-kuro
June 24, 2021
Tweet
Share
More Decks by d-kuro
See All by d-kuro
kube-state-metrics Sharding
daikurosawa
0
310
Understanding CPU throttling in Kubernetes to improve application performance #k8sjp
daikurosawa
12
15k
Leader Election in Kubernetes #k8sjp
daikurosawa
5
10k
Argo CD 実践ガイド #k8sjp / Argo CD Practice Guide
daikurosawa
13
8.3k
図で理解する Descheduler #k8sjp #ymju / Introduction to Descheduler
daikurosawa
12
23k
Kubernetes のソースコードとの付き合い方 #gounco / Kubernetes source code reading
daikurosawa
24
5k
GolangCI を使ってコードの品質を保ちながら快適な Golang 生活を送る話 #gounco / GolangCI
daikurosawa
4
5.8k
Introduction gRPC
daikurosawa
1
250
Go Cloud を触ってみる / gopher-dojo-lt
daikurosawa
2
2.1k
Other Decks in Programming
See All in Programming
ブラウザ単体でmp4書き出すまで - muddy-web - 2024-12
yue4u
2
460
【re:Growth 2024】 Aurora DSQL をちゃんと話します!
maroon1st
0
770
採用事例の少ないSvelteを選んだ理由と それを正解にするためにやっていること
oekazuma
2
1k
SymfonyCon Vienna 2025: Twig, still relevant in 2025?
fabpot
3
1.2k
テストケースの名前はどうつけるべきか?
orgachem
PRO
0
130
暇に任せてProxmoxコンソール 作ってみました
karugamo
1
720
Refactor your code - refactor yourself
xosofox
1
260
「Chatwork」Android版アプリを 支える単体テストの現在
okuzawats
0
180
今年一番支援させていただいたのは認証系サービスでした
satoshi256kbyte
1
250
Mermaid x AST x 生成AI = コードとドキュメントの完全同期への道
shibuyamizuho
0
160
たのしいparse.y
ydah
3
120
Semantic Kernelのネイティブプラグインで知識拡張をしてみる
tomokusaba
0
180
Featured
See All Featured
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
Scaling GitHub
holman
458
140k
Facilitating Awesome Meetings
lara
50
6.1k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
The Language of Interfaces
destraynor
154
24k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Speed Design
sergeychernyshev
25
670
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.2k
Automating Front-end Workflow
addyosmani
1366
200k
Transcript
Chart Λ Unit Test ͢Δ Kubernetes Meetup Tokyo #42 LT
I work for @ponde_m @d-kuro
Summary • Helm Chart ͷ Test ʹ͍ͭͯ • Helm Chart
Λ Unit Test ͢ΔͨΊͷϥΠϒϥϦΛ࣮ͨ͠ • ࣮ͷৄࡉ • “k8s.io” ϥΠϒϥϦΛͬͨ Tips ͷհ
Testing Helm Charts --set autoscaling.enabled=false --set replicaCount=3
Testing Helm Charts • Helm ʹςετػߏ͕ଘࡏ͢Δ • “helm.sh/hook: test” annotation
Λ༩ͨ͠ Pod ఆٛΛ༻ҙ͢Δ • “<chart-name>/templates/tests/“ ʹஔ͢Δ • “helm install” ͨ͋͠ͱʹ “helm test” Λ࣮ߦ͢Δ • Pod ͕ exit 0 Ͱऴྃ͢Εςετ͕ޭͨ͠ͱΈͳ͞ΕΔ
None
None
Testing Helm Charts • ͜ͷςετػߏͲͪΒ͔ͱ͍͑ Integration Test • values.yaml ʹఆٛͨ͠
Option ͕ҙਤͨ͠௨Γʹػೳ͢Δ͔ Ͳ͏͔ͳͲͷ Unit Test Ϩϕϧͷ֬ೝ͕͔ͨͬͨ͠
Unit Testing Helm Charts • Go Ͱ Helm Chart Λ
Unit Test ͢Δ • “helm.sh/helm/v3” Λ import ͯ͠ “helm template” ίϚϯυͰ༻͍ͯ͠ΔؔΛݺͼग़͢ • ϨϯμϦϯά͞Εͨ YAML ͕ string Ͱ͑ΔͷͰ ͍͍ײ͡ʹൺֱ͢Δ
Unit Testing Helm Charts • ࡞ͨ͠ϥΠϒϥϦ • github.com/d-kuro/helmut • “helm
template” ίϚϯυ૬ͷॲཧΛ࣮ߦ͢ΔϥΠϒϥϦ • Assert ༻ͷؔΛఏڙ • github.com/google/go-cmp Λ༻ͨ͠ diff Λදࣔ͢Δ
None
None
None
Unit Testing Helm Charts • ྨࣅͷϥΠϒϥϦ • github.com/gruntwork-io/terratest/modules/helm • ෦Ͱ
“helm tempalte —show-only” ίϚϯυΛ࣮ߦ͍ͯ͠Δ • github.com/Waterdrips/helmunit • Helm ͷύοέʔδΛ import ͢Δಉ༷ͷΞϓϩʔν • Assert ؔͳͲͳ͍
Architecture map[ObjectKey]runtime.Object Rendered Manifests Exec helm template Render Convert Get
User
Exec helm template
None
Split Manifests
None
Convert from Raw Manifest to runtime.Object
None
Assert • ݱࡏ Contains ͔࣮͍ؔͯ͠͠ͳ͍ • Contains ؔʹ͞Εͨ Object Λ
map ͔Β Get ͯ͠ google/go-cmp Ͱൺֱͯ͠ߏମͷ diff Λදࣔ͢Δ • runtime.Object Λ͢ํ๏ͱ YAML or JSON ͷ Manifest Λ͢ํ๏ͷ 2 ͭΛఏڙ • ͢ runtime.Object ͷ TypeMeta ۭͳΒಈతʹઃఆ
TypeMeta ͷهड़͕ෆཁʹͳΔ
Get GVK from runtime.Object
None
Assert • Helm ʹΑ͘ΘΕΔ label annotation ͳͲͷ ࠩΛແࢹ͢ΔͨΊͷ
Option Λఏڙ
Omit Metadata
None
Conclude • Helm Chart Λ Unit Test ͢ΔͨΊͷϥΠϒϥϦΛ࡞ͬͨ • github.com/d-kuro/helmut
• ྑ͚Ε͍ͬͯͩ͘͞
Thank You for Listening