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
Azureで学ぶ 実践Kubernetes
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
shin5ok
April 10, 2018
Technology
2.5k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Azureで学ぶ 実践Kubernetes
Microsoft Azure上でマネージド型Kubernetesを構築し、
コンテナアプリケーションを展開し、運用します
実践的なノウハウに加えて、最新情報についても説明します
shin5ok
April 10, 2018
More Decks by shin5ok
See All by shin5ok
Amazon EKS Quick Dive
shin5ok
1
1.2k
Amazon EKS Overview and Updates
shin5ok
0
310
コンテナ実践入門
shin5ok
0
170
AWS Partner Champion Members コンテナ編
shin5ok
0
120
AKSでマイクロサービス Bootcamp
shin5ok
0
210
Kubernetes has come on Azure / デモでわかるAKS
shin5ok
0
450
Azureで学ぶ 実践Kubernetes ハンズオン用資料
shin5ok
2
190
Azure コンテナプラットフォーム クイックツアー
shin5ok
0
200
(Azure Antenna)AKSでコンテナアプリ DockerからKubernetesまで実践入門
shin5ok
4
2.1k
Other Decks in Technology
See All in Technology
TinyGo 開発サイクルを高速化する:Go で作るエミュレータ入門
zozotech
PRO
1
120
AI 駆動 Terraform 開発/SRE_BizReach_MIXI_2
visional_engineering_and_design
2
1.9k
AI-DLCって実際どう? 〜聞きたいこと全部聞いてみる〜
news_it_enj
0
240
[DroidKaigi 2026] Making UI specifications visible: Android UI development in the AI agent era supported by Compose Screenshot Testing and galleries
syarihu
0
600
SQL文一行も書けない人事がCortexもろもろを使って人事業務を楽にしてみる
ponponmikankan
0
120
Jetpack Compose で挑む新聞紙面UI ─ 複合ジェスチャー・ポリゴン記事領域・適応的ページ構成という3つの壁/droidkaigi2026
nikkei_engineer_recruiting
0
240
OpenTelemetry eBPF Instrumentationの舞台裏 / Behind the Scenes of OpenTelemetry eBPF Instrumentation
ymotongpoo
1
160
Nav2、Nav3 ... はたまた自作?〜 作って理解する Nav3 の設計意図 〜 / Nav2, Nav3 ... or Build Your Own? — Understanding Nav3's design intent by building it from scratch
yanzm
0
260
Multica × 長期記憶:40個のミニプロジェクト管理
eiei114
1
200
module Synths; end
asonas
1
120
DGX Sparkを2台使って いろいろ動かす話
sonoda_mj
1
140
GuardDuty 検知対応を DevOps Agent で効率化しようとしている話 / GuardDuty Investigations with DevOps Agent
masahirokawahara
1
330
Featured
See All Featured
For a Future-Friendly Web
brad_frost
183
10k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
890
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
470
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Being A Developer After 40
akosma
91
590k
A designer walks into a library…
pauljervisheath
211
25k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
Optimising Largest Contentful Paint
csswizardry
37
3.9k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
660
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
310
Transcript
None
Kubernetes on Azureの知識を持ち帰り、 (自社|自宅)で実践できるようになること
※5時間ではギリギリの内容なので、ハンズオンをスキップすることがあります あらかじめご了承ください!
None
None
None
None
None
※ 最新のDocker CEの利用について http://docs.docker.jp/engine/installation/docker-ce.html
None
None
None
None
# ubuntu最新版を実行して対話モードに入る > docker run –it ubuntu # exit でログアウト(コンテナ終了)
# Azure cli2.0最新版を取得してmycliという名前で起動、 # 対話モードに入る > docker run --name mycli -it azuresdk/azure-cli-python:2.0.20 # exit でログアウト(コンテナ終了) # apache 2.4.29を実行してデーモンモードで起動 # ホストの80番を、コンテナの80番に転送する > docker pull httpd:2.4.29 > docker inspect httpd:2.4.29 > docker run -d -p 80:80 httpd:2.4.29
None
# 'ubuntu'文字列を含むイメージの検索 > docker search ubuntu # ubuntuの14:10タグのイメージを取得(実行しない) > docker
pull ubuntu:14.10 # 現在起動中のコンテナの表示 > docker ps # コンテナの停止 > docker stop [コンテナID] # ローカルにあるコンテナイメージのリスト > docker images
None
None
None
FROM alpine:3.6 RUN apk update && apk add python2 py-pip
git openrc mongodb curl && mkdir -p /data/db RUN git clone https://
[email protected]
/shkawan/docker-appsample.git WORKDIR /docker-appsample RUN pip install -r requirements.txt USER nobody CMD [ "./entry.sh" ] localhost > docker build -t myappsample . localhost > docker tag myappsample shkawan/myappsample:v7.00 localhost > docker push shkawan/myappsample:v7.00 anotherhost > docker run -p 80:8000 -d --name myapache shkawan/myappsample:v7.00
None
None
None
None
None
None
None
None
None
None
bash > git clone https://
[email protected]
/shkawan/docker-appsample.git
FROM alpine:3.6 MAINTAINER
[email protected]
RUN apk update && apk add
python2 py-pip git openrc mongodb curl RUN mkdir -p /data/db COPY *.py ./ COPY entry.sh ./ COPY requirements.txt ./ COPY VERSION ./ RUN pip install -r requirements.txt USER nobody CMD [ "./entry.sh" ]
参考: Dockerコンテナで避けるべき10のこと https://developers.redhat.com/blog/2016/02/24/10-things-to-avoid-in-docker-containers/
None
version: '2' services: myappsample: # コンテナ名 image: shkawan/appsample:v7.00 # 取得するイメージ
environment: # 環境変数の設定 - MONGODB_PORT=27017 - MONGODB_HOST=mongodb ports: - 8000:8000 # ホストのポートをbind mymongodb: # コンテナ名 image: mongo:3.6.0 # DockerHub上のイメージを取得 volumes: # ホストのボリュームをマッピング - /tmp/mongodb:/data/db bash > docker-compose up -d
None
Dockerデーモン アプリ3 アプリ1 アプリ2
アプリ1 アプリ2 アプリ3 アプリ6 アプリ4 アプリ5 アプリ6 アプリ9 アプリ8 アプリ10
Dockerデーモン Dockerデーモン Dockerデーモン アプリ7
None
アプリ1 アプリ2 アプリ3 アプリ6 アプリ4 アプリ5 アプリ6 アプリ9 アプリ8 アプリ10
Dockerデーモン Dockerデーモン アプリ7
None
None
None
None
https://octoverse.github.com/
https://kubernetes.io/
None
None
None
None
# AKSが利用可能になっているか確認 shell > az provider show –n Microsoft.ContainerService –o
table Namespace RegistrationState -------------------------- ------------------- Microsoft.ContainerService Registered # 上記のように、’Registered’ でなかったら、registerを実行 shell > az provider register –n Microsoft.ContainerService # 再度、確認します shell > az provider show –n Microsoft.ContainerService –o table
# まず AKSの名前、リソースグループの名前、deployするリージョンを決めます shell > AKS_NAME=shkawan-aks shell > AKS_RESOURCE_GROUP=$AKS_NAME shell
> AKS_LOCATION=eastus # 準備 shell > az login shell > az group create -n $AKS_NAME -l $AKS_LOCATION # 1発 deploy shell > az aks create -n $AKS_NAME -g $AKS_RESOURCE_GROUP -l $AKS_LOCATION ¥ shell >> --generate-ssh-keys
# kubectlコマンドのインストール shell > az aks install-cli # 資格情報の取得 shell
> az aks get-credentials -g $AKS_RESOURCE_GROUP -n $AKS_NAME shell > kubectl version # 補完を有効に shell > echo "source <(kubectl completion bash)" >> ~/.bashrc shell > source ~/.bashrc
None
# なにも動いていないことを確認 shell > kubectl get pods # nginx公式1.13.5-alpineを取得して、mynginxという名前で実行 shell
> kubectl run mynginx --image=nginx:1.13.5-alpine # mynginxが動いていることを確認する shell > kubectl get pods NAME READY STATUS RESTARTS AGE mynginx-3071068301-pbvnz 1/1 Running 0 1h # IPを設定して公開、IPを確認する shell > kubectl expose deploy mynginx --port=80 --type=LoadBalancer shell > kubectl get services
None
None
https://Kubernetes.io/docs/tutorials/object-management-kubectl/object-management/ 管理手法 操作対象 推奨環境 学習コスト 主なツール 命令的コマンド 動作中のオブジェクト 開発 低い
kubectl 等 命令的設定ファイル ファイル プロダクション 普通 エディタ Git 宣言的設定ファイル ディレクトリ ファイル プロダクション 高い エディタ Git
None
None
None
None
None
None
None
None
None
# Dockerhub上のサンプルアプリを取得して実行 shell > kubectl run myappsample --image=shkawan/appsample:v7.00 --record #
サンプルアプリが動いていることを確認する shell > kubectl get pods # IPを設定して公開、IPを確認する shell > kubectl expose deploy myappsample --port=80 --type=LoadBalancer shell > kubectl get services
shell > kubectl scale --replicas=5 deployment myappsample # サンプルアプリのレプリカが増えていることを確認する shell
> kubectl get pods shell > kubectl set image deployment myappsample myappsample=shkawan/appsample:v5.11 # サンプルアプリのPodにローリングアップデートがかかっていることを確認する shell > kubectl get pods --watch
Deployment Service Replicaset Pods kube-system Pods User Namespace
None
None
None
shell > MONGODB_URI=外部のMONGODBを参照するURI shell > kubectl set env deploy myappsample
MONGODB_URI=$MONGODB_URI
None
None
None
None
SSL Gateway用 × 2 アプリ表示用 × 4 通知用 × 2
コメント用 × 2 Cosmos DB Log Analytics
None
SSL Gateway用 × 2 アプリ表示用 × 4 通知用 × 2
コメント用 × 2 Cosmos DB Log Analytics Immutable Immutable Immutable Immutable
SSL Gateway用 × 2 アプリ表示用 × 4 通知用 × 2
コメント用 × 2 Cosmos DB Log Analytics
None
管理手法 操作対象 推奨環境 学習コスト 主なツール 命令的コマンド 動作中のオブジェクト 開発 低い kubectl
等 命令的設定ファイル ファイル プロダクション 普通 エディタ Git 宣言的設定ファイル ディレクトリ ファイル プロダクション 高い エディタ Git
shell > cd k8s.demo/manifest/ # 値を編集します shell > vi ./1-configmap.yml
shell > vi ./2-secret.yml shell > kubectl apply -f ./0-namespace.yml shell > kubectl apply -f ./1-configmap.yml shell > kubectl apply -f ./2-secret.yml shell > kubectl apply -f ./3-deployment.yml shell > kubectl apply -f ./4-service.yml
SSL Gateway用 × 2 アプリ表示用 ×4 通知用 × 2 コメント用
× 2 Cosmos DB
None
shell > cd k8s.demo/manifest/ # 値を編集します shell > vi ./loganalytics/configmap.yml
shell > kubectl apply -f ./loganalytics/loganalytics.yml
SSL Gateway用 × 2 アプリ表示用 ×4 通知用 × 2 コメント用
× 2 Cosmos DB Log Analytics
None
shell > vim ./deployment.yml --- a/manifest/3-deployment.yml +++ b/manifest/3-deployment.yml @@ -7,7
+7,7 @@ metadata: name: myappsample namespace: myapp spec: - replicas: 2 + replicas: 4 strategy: rollingUpdate: maxSurge: 1 shell > kubectl apply -f ./3-deployment.yml
SSL Gateway用 × 2 アプリ表示用 ×4 通知用 × 2 Cosmos
DB Log Analytics コメント用 × 4
shell > vim ./deployment.yml --- a/manifest/3-deployment.yml +++ b/manifest/3-deployment.yml @@ -140,7
+140,7 @@ spec: value: myappsample - name: NOTIFY_URI value: http://mynotifypod/api/slack - image: shkawan/websample:v0.75 + image: shkawan/websample:v0.78 imagePullPolicy: IfNotPresent name: mywebsample dnsPolicy: ClusterFirst shell > kubectl apply -f ./3-deployment.yml
SSL証明書をsecretで管理 証明書更新時のコンテナbuildを不要に Ingressの導入
None
None
None
None
SHIP RUN AUTO TEST and BUILD RUN
None
# 現在のノード数を確認 # Azureで確認 shell > az aks show -n
$AKS_NAME -g $AKS_RESOURCE_GROUP | jq .properties.agentPoolProfiles # k8s上での確認 shell > kubectl get nodes # コマンド一発 shell > az aks scale -n $AKS_NAME -g $AKS_RESOURCE_GROUP --node-count 5 # Azure上、k8s上で確認
# 現在のバージョンと、アップグレード可能なバージョンを確認 shell > az aks get-versions -n $AKS_NAME -g
$AKS_RESOURCE_GROUP -o table shell > az aks upgrade --Kubernetes-version 1.8.1 -g $AKS_RESOURCE_GROUP -n $AKS_NAME
None
None
None
None
None
None
None
https://istio.io/docs/concepts/what-is-istio/overview.htm
None
PaaS型 サーバレス マネージド Kubernetes フル Kubenetes
None
None
None
None
$ az container create -n MyACI -g MyACI --ip-address Public
-l westus ¥ > --image shkawan/basicapi:v1
None
None
None
None
None
None