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
『Docker/Kubernetes 実践コンテナ開発入門』輪読会 #5
Search
nagaakihoshi
February 25, 2019
0
470
『Docker/Kubernetes 実践コンテナ開発入門』輪読会 #5
https://yourmystar.connpass.com/event/120903/
nagaakihoshi
February 25, 2019
Tweet
Share
More Decks by nagaakihoshi
See All by nagaakihoshi
短距離走チームから長距離走チームへの移行プロセス.pdf
nagaakihoshi
0
450
Backlog API x Zapier x Slack で お気づきだろうか!!!!
nagaakihoshi
0
1.3k
WEBサービス開発における仮説思考のための道具
nagaakihoshi
2
630
心理的安全性の 「持ちつ持たれつ」
nagaakihoshi
2
4.1k
レビューで 初心者インターンを 一人前に育てた話
nagaakihoshi
1
1.3k
Featured
See All Featured
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.4k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
13k
Rails Girls Zürich Keynote
gr2m
95
14k
Side Projects
sachag
455
43k
Balancing Empowerment & Direction
lara
4
690
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Optimising Largest Contentful Paint
csswizardry
37
3.5k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Principles of Awesome APIs and How to Build Them.
keavy
127
17k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.6k
Leading Effective Engineering Teams in the AI Era
addyosmani
5
420
Testing 201, or: Great Expectations
jmmastey
45
7.7k
Transcript
『Docker/Kubernetes 実践コン テナ開発入門』輪読会 #5 2019/02/25 1 @inase17000
Kubernetes入門 5.1 Kubernetesとは 5.2 ローカル環境でKubernetesを実行する 5.3 Kubernetesの概念 5.4 KubernetesクラスタとNode 5.5
Namespace 5.6 Pod 5.7 ReplicaSet 5.8 Deployment 5.9 Service 5.10 Ingress 2
5.1 Kubernetesとは 3 ホストOS Docker コンテナ1 コンテナ2 コンテナ3 ホストOS Kubernetes
Docker Kubernetes Master Node Node1 コンテナ1 コンテナ1 コンテナ1 コンテナ2 Deployment / ReplicaSet Node2 コンテナ1 コンテナ1 コンテナ1 コンテナ2 Deployment / ReplicaSet kube apiserver etcd kube scheduler kube controller manager Service Ingress
5.2 ローカル環境でKubernetesを実行する 4
5.2 ローカル環境でKubernetesを実行する 5 # 5.2.1 curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.10.4/bin/darwin/amd64/kubectl \ &&
chmod +x kubectl \ && mv kubectl /usr/local/bin/ kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.8.3/src/deploy/recommended/kubernetes-dashbo ard.yaml kubectl get pod --namespace=kube-system -l k8s-app=kubernetes-dashboard kubectl proxy http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/
5.2 ローカル環境でKubernetesを実行する 6 http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/
5.4 KubernetesクラスタとNode 7 # 5.4 kubectl get nodes
5.6 Pod YAMLについて補足 8 配列 ハッシュ - A - B
- - C-1 - C-2 A: a B: b C: C-1: c1 C-2: c2 [“A”, “B”, [“C-1”, “C-2”]] {“A” => “a”, “B” => “b”, “C” => {“C-1” => “c1”, “C-2” => “c2”}}
5.6 Pod YAMLのサンプル 9 https://magazine.rubyist.net/articles/0009/0009-YAML.html
5.6 Pod 10 # 5.6.1 # simple-pod.yml apiVersion: v1 kind:
Pod metadata: name: simple-echo spec: containers: - name: nginx image: gihyodocker/nginx-proxy:latest env: - name: BACKEND_HOST value: localhost:8000 ports: - containerPort: 80 - name: echo image: gihyodocker/echo:latest ports: - containerPort: 8080
5.6 Pod 11 # 5.6.1 kubectl apply -f simple-pod.yml kubectl
get pod kubectl exec -it simple-echo sh -c nginx kubectl logs -f simple-echo -c echo kubectl delete pod simple-echo kubectl delete -f simple-pod.yml
5.7 ReplicaSet 12 # 5.7 # simple-replicaset.yml apiVersion: apps/v1 kind:
ReplicaSet metadata: name: echo labels: app: echo spec: replicas: 3 selector: matchLabels: app: echo template: metadata: labels: app: echo spec: containers: - name: nginx image: gihyodocker/nginx-proxy:latest env: - name: BACKEND_HOST value: localhost:8080 ports: - containerPort: 80 - name: echo image: gihyodocker/echo:latest ports: - containerPort: 8080
5.7 ReplicaSet 13 # 5.6.1 kubectl apply -f simple-replicaset.yml kubectl
delete -f simple-replicaset.yml
5.8 Deployment 14 # 5.8 # simple-deployment.yml apiVersion: apps/v1 kind:
Deployment metadata: name: echo labels: app: echo spec: replicas: 3 selector: matchLabels: app: echo template: metadata: labels: app: echo spec: containers: - name: nginx image: gihyodocker/nginx-proxy:latest env: - name: BACKEND_HOST value: localhost:8000 ports: - containerPort: 80 - name: echo image: gihyodocker/echo:latest ports: - containerPort: 8080
5.8 Deployment 15 # 5.8.1 kubectl apply -f simple-deployment.yml --record
kubectl get pod,replicaset,deployment --selector app=echo kubectl rollout history deployment echo # 5.8.2 kubectl rollout history deployment echo --revision=2 kubectl rollout history deployment echo --revision=3 kubectl rollout undo deployment echo kubectl delete -f simple-deployment.yml
# 5.9 # simple-replicaset-with-label.yml apiVersion: apps/v1 kind: ReplicaSet metadata: name:
echo-spring labels: app: echo release: spring spec: replicas: 3 selector: matchLabels: app: echo release: spring template: metadata: labels: app: echo release: spring 5.9 Services 16 spec: containers: - name: nginx image: gihyodocker/nginx-proxy:latest env: - name: BACKEND_HOST value: localhost:8000 ports: - containerPort: 80 - name: echo image: gihyodocker/echo:latest ports: - containerPort: 8080 --- apiVersion: apps/v1 kind: ReplicaSet metadata: name: echo-summer labels: app: echo release: summer ...つづく
5.9 Services 17 # 5.9 kubectl apply -f simple-replicaset-with-label.yml kubectl
get pod -l app=echo -l release=spring kubectl get pod -l app=echo -l release=summer kubectl apply -f simple-service.yml kubectl get svc echo kubectl run -i --rm --tty debug --image=gihyodocker/fundamental:0.1.0 --restart=Never -- bash -il kubectl logs -f echo-summer-8qxmg -c echo
5.10 Ingress • L4バランサー ◦ IPアドレスとポート番号による負 荷分散 • L7バランサー ◦
URLやHTTPヘッダーで負荷分 散 18 https://academy.gmocloud.com/qa/20170810/4591
5.10 Ingress 19 # 5.10 kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.16.2/deploy/mandatory.yaml kubectl
apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.16.2/deploy/provider/cloud-generic.yaml kubectl -n ingress-nginx get service,pod # 5.10.2 kubectl apply -f simple-service.yml kubectl get ingress curl http://localhost -H 'Host: ch05.gihyo.local'