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
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.1k
Amazon EKS Overview and Updates
shin5ok
0
300
コンテナ実践入門
shin5ok
0
170
AWS Partner Champion Members コンテナ編
shin5ok
0
120
AKSでマイクロサービス Bootcamp
shin5ok
0
200
Kubernetes has come on Azure / デモでわかるAKS
shin5ok
0
450
Azureで学ぶ 実践Kubernetes ハンズオン用資料
shin5ok
2
180
Azure コンテナプラットフォーム クイックツアー
shin5ok
0
200
(Azure Antenna)AKSでコンテナアプリ DockerからKubernetesまで実践入門
shin5ok
4
2.1k
Other Decks in Technology
See All in Technology
日本 Fintech 未来予測レポート 2027〜2028年(手動編集版)
8maki
0
2.1k
[モダンアプリ勉強会]今更聞けないGit/GitHub入門
tsukuboshi
0
370
爆速でマルチプロダクトを立ち上げる時 事業・CTO目線で大事にしたい事
miyatakoji
0
110
失敗を経て、Harness Engineering で 大切にしたいことを考える / Learning from Failure: What Matters in Harness Engineering
bitkey
PRO
1
330
Claude Code の Sandbox 機能を Anthropic Sandbox Runtime(srt) で試そう!/lets-play-anthropic-sandbox-runtime
tomoki10
1
560
Claude Code×Terraform IaC テンプレート駆動開発
itouhi
1
510
200個のGitHubリポジトリを横断調査したかった
icck
0
120
Oracle AI Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
6
1.5k
エラーバジェットのアラートのタイミングを考える.pdf
kairim0
0
130
エンジニアリング戦略の作り方 / Crafting Engineering Strategy
iwashi86
21
6.7k
2026TECHFRESH畢業分享會 - Lightning Talk - E起 See See : 電商推薦讀心術? 數據說了算
line_developers_tw
PRO
0
880
就職⽀援サービスにおけるキャリアアドバイザーのシフトスケジューリング
recruitengineers
PRO
1
140
Featured
See All Featured
It's Worth the Effort
3n
188
29k
Darren the Foodie - Storyboard
khoart
PRO
3
3.4k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.8k
Docker and Python
trallard
47
3.9k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.5k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
Designing for Performance
lara
611
70k
Un-Boring Meetings
codingconduct
0
310
Evolving SEO for Evolving Search Engines
ryanjones
0
210
Utilizing Notion as your number one productivity tool
mfonobong
4
320
A designer walks into a library…
pauljervisheath
211
24k
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