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
形式手法特論:位相空間としての並行プログラミング #kernelvm / Kernel VM Study Tokyo 18th
ytaka23
3
1.8k
AWS と定理証明 〜ポリシー言語 Cedar 開発の舞台裏〜 #fp_matsuri / FP Matsuri 2025
ytaka23
10
4.3k
問 1:以下のコンパイラを証明せよ(予告編) #kernelvm / Kernel VM Study Kansai 11th
ytaka23
3
860
AWS のポリシー言語 Cedar を活用した高速かつスケーラブルな認可技術の探求 #phperkaigi / PHPerKaigi 2025
ytaka23
11
2.9k
NilAway による静的解析で「10 億ドル」を節約する #kyotogo / Kyoto Go 56th
ytaka23
4
740
形式手法の 10 メートル手前 #kernelvm / Kernel VM Study Hokuriku Part 7
ytaka23
7
1.4k
普通の Web エンジニアのための様相論理入門 #yapcjapan / YAPC Hakodate 2024
ytaka23
12
3.4k
kcp: Kubernetes APIs Are All You Need #techfeed_live / TechFeed Experts Night 28th
ytaka23
1
570
サーバーレスアーキテクチャの数理的理解と分析 #devsumi / Developers Summit 2023 Summer
ytaka23
9
5.5k
Other Decks in Technology
See All in Technology
JTCにおける内製×スクラム開発への挑戦〜内製化率95%達成の舞台裏/JTC's challenge of in-house development with Scrum
aeonpeople
0
250
株式会社ログラス - 会社説明資料【エンジニア】/ Loglass Engineer
loglass2019
4
65k
Modern Linux
oracle4engineer
PRO
0
150
初めてAWSを使うときのセキュリティ覚書〜初心者支部編〜
cmusudakeisuke
1
270
KotlinConf 2025_イベントレポート
sony
1
140
AWSで始める実践Dagster入門
kitagawaz
1
680
slog.Handlerのよくある実装ミス
sakiengineer
4
380
会社紹介資料 / Sansan Company Profile
sansan33
PRO
6
380k
複数サービスを支えるマルチテナント型Batch MLプラットフォーム
lycorptech_jp
PRO
1
780
AWSを利用する上で知っておきたい名前解決のはなし(10分版)
nagisa53
10
3.2k
Autonomous Database - Dedicated 技術詳細 / adb-d_technical_detail_jp
oracle4engineer
PRO
4
10k
ハードウェアとソフトウェアをつなぐ全てを内製している企業の E2E テストの作り方 / How to create E2E tests for a company that builds everything connecting hardware and software in-house
bitkey
PRO
1
160
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
A designer walks into a library…
pauljervisheath
207
24k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
358
30k
Documentation Writing (for coders)
carmenintech
74
5k
Automating Front-end Workflow
addyosmani
1370
200k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
15k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.9k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4k
Building Flexible Design Systems
yeseniaperezcruz
329
39k
How to Think Like a Performance Engineer
csswizardry
26
1.9k
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