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
SkaffoldでKubernetesネイティブな開発環境を作ってみた
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
hhiroshell
June 01, 2018
Technology
2.7k
8
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
SkaffoldでKubernetesネイティブな開発環境を作ってみた
2018/06/01 Cloud Native MeetUp Tokyo #2での発表資料です。
hhiroshell
June 01, 2018
More Decks by hhiroshell
See All by hhiroshell
Kubernetes Multi-tenancy: Principles and Practices for Large Scale Internal Platforms
hhiroshell
0
240
Platform Engineering from the CNCF Perspective
hhiroshell
0
82
Maximizing the Launch Reliability: Ensuring Stable Application Lift-off and Orbit on Kubernetes
hhiroshell
0
120
CNCFの視点で捉えるPlatform Engineering - 最新動向と展望 / Platform Engineering from the CNCF Perspective
hhiroshell
0
360
Cloud Native Scalability for Internal Developer Platforms
hhiroshell
5
890
LINEヤフーにおける超大規模プラットフォーム実現への挑戦と学び / Challenges and Lessons in Building an Ultra-Large-Scale Platform at LY Corporation
hhiroshell
3
1.9k
Architecting Kubernetes-Based Internal Developer Platforms: Essential Patterns and Practices
hhiroshell
0
310
Discover Your Tailored Platform Strategy with Real-World Practice
hhiroshell
1
310
Kubernetesでアプリの安定稼働と高頻度のアップデートを両立するためのプラクティス / Best Practices for Applications on Kubernetesto Achieve Both Frequent Updates and Stability
hhiroshell
11
5.1k
Other Decks in Technology
See All in Technology
「勝手に広まる」人気 AI エージェントを爆速で作ろう!(AWS Summit Japan 2026講演資料)
minorun365
PRO
10
2.6k
トークン最適化のためのユーザーストーリー分析 / User Story Analysis for Token Optimization
oomatomo
0
130
AIをフル活用してオンコール機能のプロトタイプを2日で作った話 / Building an AI-Powered On-Call Prototype in Just Two Days
nari_ex
0
150
いまさら聞けない「仕様駆動開発入門」 〜AI活用時代の開発プロセスを考える〜
findy_eventslides
2
230
When Platform Engineering Meets GenAI
sucitw
0
200
クラウドファンディング版StackChan 3体(4体)をインタラクティブな体験型作品にして展示もした話 / スタックチャンお誕生日会2026
you
PRO
0
250
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
11k
Zenoh on Zephyr on LiteX
takasehideki
2
130
打造你的 AI 工作流:Agent Skill + MCP 實戰工作坊
appleboy
0
180
AIは、人間らしい仕事の夢を見るか?─ AI時代のtoB/toEプロダクトを再設計する
techtekt
PRO
0
160
水を運ぶ人としてのリーダーシップ
izumii19
4
1.1k
データレイクの「見えない問題」を可視化する
sansantech
PRO
1
230
Featured
See All Featured
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Claude Code のすすめ
schroneko
67
230k
Site-Speed That Sticks
csswizardry
13
1.2k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1k
Utilizing Notion as your number one productivity tool
mfonobong
4
330
Become a Pro
speakerdeck
PRO
31
6k
Statistics for Hackers
jakevdp
799
230k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.6k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
240
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.9k
Side Projects
sachag
455
43k
Transcript
Cloud Native Developers JP SkaffoldでKubernetesネイティブな 開発環境を作ってみた @hhiroshell 1
Cloud Native Developers JP • 早川 博(はやかわ ひろし) • 日本オラクル所属
– ソリューション・アーキテクト的な人 – Containers, Microservices, DevOps • Ergodoxユーザー 2 自己紹介 @hhiroshell
Cloud Native Developers JP Skaffoldの概要 3
Cloud Native Developers JP Skaffoldとは • Kubernetesに乗せるアプリケーションの開発作業を省力化してくれ るコマンドラインツール – https://github.com/GoogleContainerTools/skaffold
• Googleのエンジニアを中心に開発されているOSS (GoogleContainerTools配下のプロジェクト) – Apache License 2.0 • 2018年3月発表。最新バージョンはv0.6.1(2018/06/01現在) • 類似のツールに、Draft、keelというものがあるらしい 4
Cloud Native Developers JP 5 ★ 3,797(最多)
Cloud Native Developers JP 6 動作確認するだけでも結構手間がかかる…。 Kubernetesにのせるアプリを開発するときの作業 1 アプリの コードを編集
2 コンテナ イメージの Build 3 コンテナ レジストリへ Push 4 Kubernetesへ Deploy くりかえし
Cloud Native Developers JP 7 動作確認するだけでも結構手間がかかる…。 Kubernetesにのせるアプリを開発するときの作業 1 アプリの コードを編集
2 コンテナ イメージの Build 3 コンテナ レジストリへ Push 4 Kubernetesへ Deploy くりかえし K8sであるが故に必要な作業(面倒くさい)
Cloud Native Developers JP 2 Build 3 Push 4 Deploy
Skaffold Pipeline • Build, Push, Deployの各フェーズで、必要なコマンドを順次自動実 行してくれるイメージ • らくちん! 8 面倒なBuild, Push, DeployをSkaffoldで自動化 > docker build > docker push > kubectl apply
Cloud Native Developers JP 2 Build 3 Push 4 Deploy
Skaffoldのプラグインアーキテクチャ • dockerコマンドとkubectlを自動化する使い方 9 各フェーズの実態をプラグイン的に変更できる > docker build > docker push > kubectl apply Google Container Builder Google Container Registry > helm install
Cloud Native Developers JP > docker build > docker push
> kubectl apply Google Container Builder Google Container Registry > helm install Skaffoldのプラグインアーキテクチャ • GKEとhelmの場合 10 各フェーズの実態をプラグイン的に変更できる 2 Build 3 Push 4 Deploy
Cloud Native Developers JP 2 Build 3 Push 4 Deploy
Skaffoldのプラグインアーキテクチャ • PushなしでKubernetesにデプロイ。ローカル開発で便利 11 各フェーズの実態をプラグイン的に変更できる > docker build > docker push > kubectl apply Google Container Builder Google Container Registry > helm install
Cloud Native Developers JP skaffold dev と skaffold run •
> skaffold dev – コンソールのフォアグラウンドに常駐 – コンテナイメージの依存ファイルに対する変更を検知して、Skaffold Pipeline を自動で実行してくれる – 開発中のコンテナの標準出力を自動でtailする • > skaffold run – – Skaffold Pipelineを一度だけ実行して終わる – CI/CDの中で使うときや、アプリ開発が一段落した後のサニティチェックと して 12 ローカル開発ではdevの方を積極的に活用しよう
Cloud Native Developers JP skaffold.yaml ① imageNameでイメージ名を指 定(タグは自動で付与) ② デフォルトではworkspace直下
のDockerfileをビルド ③ skipPosh: trueによりコンテナ レジストリへのプッシュ不要で 直接k8sにデプロイ ④ デプロイ時は、manifestsに指 定したファイルを kubectl apply してくれる 13 Pipelineの定義ファイル 1 apiVersion: skaffold/v1alpha2 2 kind: Config 3 build: 4 artifacts: 5 - imageName: gcr.io/k8s-skaffold/skaffold-example 6 workspace: . 7 local: 8 skipPush: true 9 deploy: 10 kubectl: 11 manifests: 12 - k8s-* 13 profiles: 14 - name: gcb 15 build: 16 googleCloudBuild: 17 projectId: k8s-skaffold … ① … ② … ③ … ④
Cloud Native Developers JP skaffold.yaml ⑤ profileによって複数の Pipelineを切替えられる – この例ではGoogle
Container Builderでk8s-skaffoldプロジェ クトをビルド – > scaffold run -p gcb 14 Pipelineの定義ファイル 1 apiVersion: skaffold/v1alpha2 2 kind: Config 3 build: 4 artifacts: 5 - imageName: gcr.io/k8s-skaffold/skaffold-example 6 workspace: . 7 local: 8 skipPush: true 9 deploy: 10 kubectl: 11 manifests: 12 - k8s-* 13 profiles: 14 - name: gcb 15 build: 16 googleCloudBuild: 17 projectId: k8s-skaffold … ⑤
Cloud Native Developers JP Demo(基本編) ローカル開発で使う 15
Cloud Native Developers JP 2 Build 3 Push 4 Deploy
16 Helmと組み合わせると強力 Demoで紹介するSkaffold Pipeline > docker build > docker push > kubectl apply Google Container Builder Google Container Registry > helm install
Cloud Native Developers JP SkaffoldとHelmの組み合わせでできること • ProfileでHelmのパラメータのセットを切り替えてデプロイする 17 複数の構成パターンを切り替えつつmanifestを共通化 4
Deploy chart profile:dev chart profile:it AP svc:NodePort namespace: dev namespace: it AP AP redis redis Ingress
Cloud Native Developers JP 最近追加された機能 • bazel対応 – skaffoldのビルドフェーズでbazelが呼べる •
kaniko対応 – kaniko: Kubernetesクラスター内のPodでコンテナのビルドを行うツール • 特別な権限をつけなくてもビルドが実行できる • gVisor上でビルドすることでさらに安全にすることも可 • skaffoldのBuildフェーズで利用する 18 bazel / kaniko対応
Cloud Native Developers JP Qiitaに書きました(https://qiita.com/hhiroshell/items/4e3183d3890629f13dec) Demo(やってみた編) Jnekinsと組合せて使う 19
Cloud Native Developers JP CI/CDツールと組み合わせてみる • KubernetesでJenkinsが可動している状態 20 Jenkins on
Kubernetesの場合の動作イメージ Jenkins
Cloud Native Developers JP CI/CDツールと組み合わせてみる • SlaveがPodととして立ち上がり、そこでパイプラインが実行される 21 Jenkins on
Kubernetesの場合の動作イメージ Jenkins Jenkins Slave Build Push Deploy
Cloud Native Developers JP CI/CDツールと組み合わせてみる • パイプラインでSkaffoldが実行されアプリがデプロイされる 22 Jenkins on
Kubernetesの場合の動作イメージ Jenkins Jenkins Slave AP AP redis Ingress namespace: it
Cloud Native Developers JP CI/CDツールと組み合わせてみる • パイプラインが終了したらSlaveが消える 23 Jenkins on
Kubernetesの場合の動作イメージ Jenkins AP AP redis Ingress namespace: it
Cloud Native Developers JP 24 Jenkinsfile で定義
Cloud Native Developers JP 25 1 podTemplate( 2 label: 'skaffold',
3 containers: [containerTemplate( image: 'hhayakaw/skaffold-insider:v1.0.0', ttyEnabled: true, command: 'cat')], 4 volumes: [hostPathVolume(hostPath: '/var/run/docker.sock', mountPath: '/var/run/docker.sock')] 5 ) { 6 node('skaffold') { 7 … 8 stage('Info') {…} 9 stage('Test skaffold') { 10 git 'https://github.com/hhiroshell/cowweb.git' 11 container('skaffold-insider') { 12 sh """ 13 docker login --username=$DOCKER_ID_USR --password=$DOCKER_ID_PSW 14 skaffold run -p release 15 """ 16 } 17 … docker, kubectl, skaffoldをインストールしたコンテナ を作っておき、パイプラインで利用 Docker in Docker… (ビルド環境がコンテナ化されているため)
Cloud Native Developers JP 26 1 podTemplate( 2 label: 'skaffold',
3 containers: [containerTemplate( image: 'hhayakaw/skaffold-insider:v1.0.0', ttyEnabled: true, command: 'cat')], 4 volumes: [hostPathVolume(hostPath: '/var/run/docker.sock', mountPath: '/var/run/docker.sock')] 5 ) { 6 node('skaffold') { 7 … 8 stage('Info') {…} 9 stage('Test skaffold') { 10 git 'https://github.com/hhiroshell/cowweb.git' 11 container('skaffold-insider') { 12 sh """ 13 docker login --username=$DOCKER_ID_USR --password=$DOCKER_ID_PSW 14 skaffold run -p release 15 """ 16 } 17 … profileを指定してskaffoldを使う
Cloud Native Developers JP まとめ 27
Cloud Native Developers JP 使ってみた感想 - いいところ • 安定しているとは言えない –
かなり頻繁にアップデートされている(発表から3ヶ月で v0.1.0 → v0.6.1) – 約1週間使い込んだところ、バグと思しき挙動に2つ遭遇 – v0.xだからか、マイナーバージョンアップでも仕様が変わることがある • とはいえ一度動かしきればメリットは大きい – チーム開発に影響しない範囲で、個人として導入するには賛成 – コーディングが実に捗る • Helmとの相性が良い – 複数のパラメータのセットを切り替えてデプロイする時に便利 – skaffold devなら自動でchartのアンインストールまでしてくれる 28 ローカル開発で積極的に使っていきたい
Cloud Native Developers JP 使ってみた感想 – いまいちなところ • ひとつのコマンドでいろいろやってくれるのが逆に不便? –
Build/Push/Deployがひとつのコマンドに集約されており、別々に実行する手段がな さそう – パイプラインが失敗したときに、どこで問題が起きているのかが見通しが悪い • 怪しげなテクニックに依存しがち(Jenkins on k8sの場合) – Docker in Docker →kanikoが解決策になるか? – クラスター内のPodからkubectlやhelmを使うときの権限周り • manifestやHelm chartにこれば凝るほどDevとOpsの境が曖昧に… – 「DockerファイルまでがDevです」のような運用を超えてくる 29 CI/CDツールと組み合わせるのはまだ難あり
Cloud Native Developers JP 使ってみた感想 - おまけ • Draft、keel •
参考: 「SkaffoldとDraftを比べてみた」 https://qiita.com/watawuwu/items/7f5e287c91e5eab30419 30 他のツールもチェックしてみるとよいかも
Cloud Native Developers JP Fin. 31