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
Haze - Real time background blurring
chrisbanes
1
510
103 Early Hints
sugi_0000
1
230
42 best practices for Symfony, a decade later
tucksaun
1
180
nekko cloudにおけるProxmox VE利用事例
irumaru
3
430
数十万行のプロジェクトを Scala 2から3に完全移行した
xuwei_k
0
270
Cloudflare MCP ServerでClaude Desktop からWeb APIを構築
kutakutat
1
550
採用事例の少ないSvelteを選んだ理由と それを正解にするためにやっていること
oekazuma
2
1k
[JAWS-UG横浜 #76] イケてるアップデートを宇宙いち早く紹介するよ!
maroon1st
0
460
Monixと常駐プログラムの勘どころ / Scalaわいわい勉強会 #4
stoneream
0
280
競技プログラミングへのお誘い@阪大BOOSTセミナー
kotamanegi
0
360
Effective Signals in Angular 19+: Rules and Helpers @ngbe2024
manfredsteyer
PRO
0
140
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
1
440
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
405
66k
How GitHub (no longer) Works
holman
311
140k
Designing for Performance
lara
604
68k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.2k
Faster Mobile Websites
deanohume
305
30k
VelocityConf: Rendering Performance Case Studies
addyosmani
326
24k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
A Tale of Four Properties
chriscoyier
157
23k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
Site-Speed That Sticks
csswizardry
2
190
A Modern Web Designer's Workflow
chriscoyier
693
190k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
520
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