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
Azureで学ぶ 実践Kubernetes
Microsoft Azure上でマネージド型Kubernetesを構築し、
コンテナアプリケーションを展開し、運用します
実践的なノウハウに加えて、最新情報についても説明します
shin5ok
April 10, 2018
More Decks by shin5ok
See All by shin5ok
Amazon EKS Quick Dive
shin5ok
1
1.1k
Amazon EKS Overview and Updates
shin5ok
0
290
コンテナ実践入門
shin5ok
0
160
AWS Partner Champion Members コンテナ編
shin5ok
0
110
AKSでマイクロサービス Bootcamp
shin5ok
0
200
Kubernetes has come on Azure / デモでわかるAKS
shin5ok
0
450
Azureで学ぶ 実践Kubernetes ハンズオン用資料
shin5ok
2
170
Azure コンテナプラットフォーム クイックツアー
shin5ok
0
190
(Azure Antenna)AKSでコンテナアプリ DockerからKubernetesまで実践入門
shin5ok
4
2.1k
Other Decks in Technology
See All in Technology
Azure Lifecycle with Copilot CLI
torumakabe
3
890
非エンジニア職からZOZOへ 〜登壇がキャリアに与えた影響〜
penpeen
0
450
Zero-Downtime Migration: Moving a Massive, Historic iOS App from CocoaPods to SPM and Tuist without Stopping Feature Delivery
kagemiku
0
240
CDK Insightsで見る、AIによるCDKコード静的解析(+AI解析)
k_adachi_01
2
160
Proxmox超入門
devops_vtj
0
220
DevOpsDays Tokyo 2026 見えない開発現場を、見える投資に変える
rojoudotcom
3
190
サイボウズ 開発本部採用ピッチ / Cybozu Engineer Recruit
cybozuinsideout
PRO
10
78k
ぼくがかんがえたさいきょうのあうとぷっと
yama3133
0
120
Eight Engineering Unit 紹介資料
sansan33
PRO
3
7.2k
Bill One 開発エンジニア 紹介資料
sansan33
PRO
5
18k
みんなで作るAWS Tips 100連発 (FinOps編)
schwrzktz
1
220
Sansan Engineering Unit 紹介資料
sansan33
PRO
1
4.2k
Featured
See All Featured
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
150
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.4k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
220
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
110k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
260
Ruling the World: When Life Gets Gamed
codingconduct
0
190
The Pragmatic Product Professional
lauravandoore
37
7.2k
How to make the Groovebox
asonas
2
2.1k
BBQ
matthewcrist
89
10k
Mind Mapping
helmedeiros
PRO
1
150
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