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
1.9k
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
290
Understanding CPU throttling in Kubernetes to improve application performance #k8sjp
daikurosawa
12
14k
Leader Election in Kubernetes #k8sjp
daikurosawa
5
9.9k
Argo CD 実践ガイド #k8sjp / Argo CD Practice Guide
daikurosawa
13
8.2k
図で理解する Descheduler #k8sjp #ymju / Introduction to Descheduler
daikurosawa
12
23k
Kubernetes のソースコードとの付き合い方 #gounco / Kubernetes source code reading
daikurosawa
24
4.9k
GolangCI を使ってコードの品質を保ちながら快適な Golang 生活を送る話 #gounco / GolangCI
daikurosawa
4
5.8k
Introduction gRPC
daikurosawa
1
240
Go Cloud を触ってみる / gopher-dojo-lt
daikurosawa
2
2.1k
Other Decks in Programming
See All in Programming
弊社の「意識チョット低いアーキテクチャ」10選
texmeijin
5
23k
Content Security Policy入門 セキュリティ設定と 違反レポートのはじめ方 / Introduction to Content Security Policy Getting Started with Security Configuration and Violation Reporting
uskey512
1
420
Boost Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
0
830
カラム追加で増えるActiveRecordのメモリサイズ イメージできますか?
asayamakk
4
1.5k
アジャイルを支えるテストアーキテクチャ設計/Test Architecting for Agile
goyoki
7
2.8k
『ドメイン駆動設計をはじめよう』のモデリングアプローチ
masuda220
PRO
7
430
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
0
150
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
330
【Kaigi on Rails 2024】YOUTRUST スポンサーLT
krpk1900
1
240
シールドクラスをはじめよう / Getting Started with Sealed Classes
mackey0225
3
400
Kaigi on Rails 2024 - Rails APIモードのためのシンプルで効果的なCSRF対策 / kaigionrails-2024-csrf
corocn
5
3.4k
EventSourcingの理想と現実
wenas
6
2.1k
Featured
See All Featured
Producing Creativity
orderedlist
PRO
341
39k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
3
370
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
Code Review Best Practice
trishagee
64
17k
Why Our Code Smells
bkeepers
PRO
334
57k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
290
Ruby is Unlike a Banana
tanoku
96
11k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
790
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
Git: the NoSQL Database
bkeepers
PRO
425
64k
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