Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
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.2k
Amazon EKS Overview and Updates
shin5ok
0
320
コンテナ実践入門
shin5ok
0
170
AWS Partner Champion Members コンテナ編
shin5ok
0
130
AKSでマイクロサービス Bootcamp
shin5ok
0
210
Kubernetes has come on Azure / デモでわかるAKS
shin5ok
0
460
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
Snapshot Testing in Practice: Predictable and Reliable SwiftUI Views
fespinoza
0
210
触りたくないデータに、どう触るか AI時代のRBACアクセスガバナンス
ivry_presentationmaterials
0
140
WasmをRustにする
sansantech
PRO
0
200
おそらく日本で唯一のDevRelインターン生として
husengs7
0
180
AI駆動開発の時代になったのでトヨタ生産方式から見直す
terurou
7
5.9k
「Docker Desktop不要の時代」は 来たのか?
ueponx
0
580
V8のArray.prototype.flatを最大約20倍速くするまでと、巨大OSSへの大規模コミットの道のり
riyaamemiya
0
270
AgentCoreで実践するハーネスエンジニアリング
yakumo
1
300
Railsで挑む大量データ永続化 〜600億件を永続化するための設計とボトルネックとの戦い〜
occhi
0
120
全PRの83%が AIレビューだけでマージできるようになった開発組織は その後どうなったか @2026/10
athug
0
140
実践!Cloud Run ハンズオン!! / Cloud Run handson
y0hgi
0
250
大型犬好きによるPugの紹介
yamanoku
1
150
Featured
See All Featured
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
Discover your Explorer Soul
emna__ayadi
2
1.3k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
2
360
Raft: Consensus for Rubyists
vanstee
142
7.8k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
360
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
Fireside Chat
paigeccino
43
4.1k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
520
Everyday Curiosity
cassininazir
0
350
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
590
Skip the Path - Find Your Career Trail
mkilby
1
250
How to make the Groovebox
asonas
2
2.5k
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