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
2.3k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Helm Chart を Unit Test する / Unit Testing Helm Chart
Kubernetes Meetup Tokyo #42 で発表したスライドです
https://k8sjp.connpass.com/event/214286/
d-kuro
June 24, 2021
More Decks by d-kuro
See All by d-kuro
Giftech2025春_GhostWriter
daikurosawa
0
55
kube-state-metrics Sharding
daikurosawa
0
430
Understanding CPU throttling in Kubernetes to improve application performance #k8sjp
daikurosawa
12
16k
Leader Election in Kubernetes #k8sjp
daikurosawa
5
12k
Argo CD 実践ガイド #k8sjp / Argo CD Practice Guide
daikurosawa
13
9k
図で理解する Descheduler #k8sjp #ymju / Introduction to Descheduler
daikurosawa
12
24k
Kubernetes のソースコードとの付き合い方 #gounco / Kubernetes source code reading
daikurosawa
24
5.6k
GolangCI を使ってコードの品質を保ちながら快適な Golang 生活を送る話 #gounco / GolangCI
daikurosawa
4
6.1k
Introduction gRPC
daikurosawa
1
330
Other Decks in Programming
See All in Programming
[2026年度第1回ORセミナー] 計画最適化ベンチャーと競技プログラミング人材
terryu16
0
270
dRuby over BLE
makicamel
2
380
AI 輔助遺留系統現代化的經驗分享
jame2408
1
770
The ROI of Quarkus for Spring Boot Applications
hollycummins
0
120
AI 時代のソフトウェア設計の学び方
masuda220
PRO
29
13k
Oxcを導入して開発体験が向上した話
yug1224
4
320
正しくソフトウェアを作る、前提を疑うための認知の視点 / doubt-premise
minodriven
21
6.7k
Performance Engineering for Everyone
elenatanasoiu
0
180
技術的負債解消で開発者の未来を開く- AIの力でコード刷新
kmd2kmd
0
110
Honoでのサプライチェーン侵害対策 〜 3つのライブラリに学ぶ
yusukebe
6
1.3k
Snowflake Summitでの新機能 CoCo / CoWork / snowflake-summit-2026-overall-what-new-coco
tatsuhiro
1
150
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
1
260
Featured
See All Featured
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
230
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Balancing Empowerment & Direction
lara
6
1.2k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.5k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.5k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
860
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
1.7k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
460
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.6k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
360
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.1k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.3k
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