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
AWS CDK との比較で見る cdk8s / cdk8s+ の現在地 #k8sjp / Ku...
Search
y_taka_23
August 26, 2020
Technology
2
1.6k
AWS CDK との比較で見る cdk8s / cdk8s+ の現在地 #k8sjp / Kubernetes Meetup Tokyo 33rd
Kubernetes Meetup Tokyo #33 で使用したスライドです。
y_taka_23
August 26, 2020
Tweet
Share
More Decks by y_taka_23
See All by y_taka_23
NilAway による静的解析で「10 億ドル」を節約する #kyotogo / Kyoto Go 56th
ytaka23
4
560
形式手法の 10 メートル手前 #kernelvm / Kernel VM Study Hokuriku Part 7
ytaka23
6
1.2k
普通の Web エンジニアのための様相論理入門 #yapcjapan / YAPC Hakodate 2024
ytaka23
9
2.5k
kcp: Kubernetes APIs Are All You Need #techfeed_live / TechFeed Experts Night 28th
ytaka23
1
370
サーバーレスアーキテクチャの数理的理解と分析 #devsumi / Developers Summit 2023 Summer
ytaka23
9
5.1k
形式手法による分散システムの検証 〜S3 の一貫性モデルを例として〜 #ourdevday2023 / Our DevDay 2023
ytaka23
2
1.3k
Amazon S3 の一貫性モデル超入門 #ハードル激低LT大会 / Low-hurdle LT Meetup 2nd
ytaka23
3
2.1k
謎は全て解けた!安楽椅子探偵に捧げる AWS ネットワーク分析入門 #CNDT2022 / CloudNative Days Tokyo 2022
ytaka23
2
3.9k
サーバーレスは操作的意味論の夢を見るか? #AWSDevDay / AWS Dev Day 2022 Japan
ytaka23
4
6.8k
Other Decks in Technology
See All in Technology
あれは良かった、あれは苦労したB2B2C型SaaSの新規開発におけるCloud Spanner
hirohito1108
2
810
実は強い 非ViTな画像認識モデル
tattaka
0
360
OpenID Connect for Identity Assurance の概要と翻訳版のご紹介 / 20250219-BizDay17-OIDC4IDA-Intro
oidfj
0
430
【内製開発Summit 2025】イオンスマートテクノロジーの内製化組織の作り方/In-house-development-summit-AST
aeonpeople
1
190
深層学習と古典的画像アルゴリズムを組み合わせた類似画像検索内製化
shutotakahashi
1
280
コンピュータビジョンの社会実装について考えていたらゲームを作っていた話
takmin
1
520
Classmethod AI Talks(CATs) #17 司会進行スライド(2025.02.19) / classmethod-ai-talks-aka-cats_moderator-slides_vol17_2025-02-19
shinyaa31
0
160
Amazon S3 Tablesと外部分析基盤連携について / Amazon S3 Tables and External Data Analytics Platform
nttcom
0
150
2025-02-21 ゆるSRE勉強会 Enhancing SRE Using AI
yoshiiryo1
1
430
Active Directory攻防
cryptopeg
PRO
8
4.6k
Reading Code Is Harder Than Writing It
trishagee
2
110
わたしがEMとして入社した「最初の100日」の過ごし方 / EMConfJp2025
daiksy
2
830
Featured
See All Featured
Designing for humans not robots
tammielis
250
25k
Bootstrapping a Software Product
garrettdimon
PRO
306
110k
Being A Developer After 40
akosma
89
590k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
40
2k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Testing 201, or: Great Expectations
jmmastey
42
7.2k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Faster Mobile Websites
deanohume
306
31k
Practical Orchestrator
shlominoach
186
10k
How to Ace a Technical Interview
jacobian
276
23k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.3k
Git: the NoSQL Database
bkeepers
PRO
427
65k
Transcript
AWS CDK との比較で見る cdk8s / cdk8s+ の現在地 チェシャ猫 (@y_taka_23) Kubernetes
Meetup Tokyo #33 (26th Aug. 2020) #k8sjp
#k8sjp 例:静的 Web ホスティング <html>
#k8sjp 例:静的 Web ホスティング <html> serviceName servicePort selector --from-file volume
Selector port 表からは見えないが一貫性がないと動かない
\Manifest の Boilerplate 多過ぎ/ #k8sjp
#k8sjp https://github.com/awslabs/cdk8s シーディーケイツ!
YAML 嫌いのための cdk8s • 高級プログラミング言語で記述 ◦ 型検査、IDE、ライブラリ管理などが利用可能 ◦ 基本は TypeScript、その他
Python、Java、.NET • ビルドすると YAML を生成 ◦ コマンドを直接実行するわけではない(宣言的) • AWS Cloud Development Kit (CDK) 派生 ◦ リソースを Construct としてカプセル化 #k8sjp
export class MyChart extends Chart { constructor(scope: Construct, name: string)
{ super(scope, name); new Service(this, ‘mysvc’, { spec: { selector: { app: ‘myapp’ }, ports: [{ port: 80, targetPort: 8080 }] } }); } } #k8sjp
export class MyChart extends Chart { constructor(scope: Construct, name: string)
{ super(scope, name); new Service(this, ‘mysvc’, { spec: { selector: { app: ‘myapp’ }, ports: [{ port: 80, targetPort: 8080 }] } }); } } #k8sjp this (= MyChart) を親要素として 参照を貼っている YAML: MyChart Service: mysvc scope
(たいして YAML と変わらない?) #k8sjp
#k8sjp cdk8s/packages/cdk8s-plus cdk8s+
Layer 1 / Layer 2 Construct • L1 Construct ◦
生 YAML のリソースと原則 1 : 1 で対応 ◦ cdk8s に相当、AWS SDK では通常使用しない • L2 Construct ◦ 内部的に L1 を呼び出して Boilerplate を隠蔽 ◦ AWS CDK では通常こちらのレイヤを触る ◦ cdk8s+ として API 策定中(一部仮実装済み) #k8sjp
import { Deployment } from ‘cdk8s-plus’; export class MyChart extends
Chart { constructor(scope: Construct, name: string) { super(scope, name); const deploy = new Deployment(this, ‘mydeploy’) { spec: { ... } } deploy.expose({ port: 80 }); } } #k8sjp 子要素が一つのみの
import { Deployment } from ‘cdk8s-plus’; export class MyChart extends
Chart { constructor(scope: Construct, name: string) { super(scope, name); const deploy = new Deployment(this, ‘mydeploy’) { spec: { ... } } deploy.expose({ port: 80 }); } } #k8sjp 子要素が一つのみの deploy に対応する selector / port を 内部的に生成して対応づけてくれる
サポート外のリソースは自前で実装? #k8sjp
cdk8s のコード生成ツール • cdk8s import ◦ CRD の YAML を取り込んで
Construct に変換 ◦ 必要な Construct は imports 以下に出力 • jsii ◦ TypeScript の実装を他言語に変換する謎技術 ◦ もともと CDK 用だったツールを cdk8s も踏襲 ◦ 自作 Construct を多言語でライブラリ登録できる #k8sjp
プログラミング言語だから 単体テストも書ける #k8sjp
AWS CDK のテスト • Snapshot Test ◦ 生成される YAML が変化していないことを確認
• Fine-Grained Assertion ◦ 単なる等価性以上も判定できる専用ライブラリ ◦ YAML の部分一致、リソースの個数指定など • Validation ◦ Construct 生成時にパラメータをチェック #k8sjp
cdk8s のサポート状況 • Snapshot Test(利用可能) ◦ 生成される YAML が変化していないことを確認 •
Fine-Grained Assertion(Roadmap のみ) ◦ 単なる等価性以上も判定できる専用ライブラリ ◦ YAML の部分一致、リソースの個数指定など • Validation(利用可能) ◦ Construct 生成時にパラメータをチェック #k8sjp
#k8sjp \CNCF Sandbox 申請予定/
まとめ • Kubernetes Manifest 書きたくない ◦ YAML は「実装の詳細」が露出し過ぎている • cdk8s
による YAML 生成 ◦ 言語機能やエコシステムに乗ることができる • AWS CDK より未成熟だが使用感は近い ◦ L2 Construct と テストの充実が今後の課題か #k8sjp
DEMO:静的 Web ホスティング #k8sjp https://github.com/y-taka-23/cdk8s-hosting
Construct Your Cool Constructs! Presented by チェシャ猫 (@y_taka_23) #k8sjp