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
Kubernetes超入門 with java
Search
Yasunari Tanaka
October 27, 2017
Technology
1
150
Kubernetes超入門 with java
2017.10.27 広島Javaユーザーグループ で行ったKubernetes ハンズオン資料です。
Yasunari Tanaka
October 27, 2017
Tweet
Share
More Decks by Yasunari Tanaka
See All by Yasunari Tanaka
MicroProfile OpenTracing with Helidon
yasu7ri
2
190
Serverlessで行ってみよ~
yasu7ri
0
1.1k
DevOpsサンプルアプリをGitLabからGKEへデプロイしてみた
yasu7ri
1
250
知識ゼロからRancher2.0に触れてみた
yasu7ri
1
430
CloudGarageでServerlessだ!
yasu7ri
3
4.5k
Other Decks in Technology
See All in Technology
20241120_JAWS_東京_ランチタイムLT#17_AWS認定全冠の先へ
tsumita
2
250
強いチームと開発生産性
onk
PRO
34
11k
なぜ今 AI Agent なのか _近藤憲児
kenjikondobai
4
1.4k
AIチャットボット開発への生成AI活用
ryomrt
0
170
透過型SMTPプロキシによる送信メールの可観測性向上: Update Edition / Improved observability of outgoing emails with transparent smtp proxy: Update edition
linyows
2
210
スクラムチームを立ち上げる〜チーム開発で得られたもの・得られなかったもの〜
ohnoeight
2
350
Amplify Gen2 Deep Dive / バックエンドの型をいかにしてフロントエンドへ伝えるか #TSKaigi #TSKaigiKansai #AWSAmplifyJP
tacck
PRO
0
370
OCI 運用監視サービス 概要
oracle4engineer
PRO
0
4.8k
Terraform Stacks入門 #HashiTalks
msato
0
350
社内で最大の技術的負債のリファクタリングに取り組んだお話し
kidooonn
1
550
TypeScript、上達の瞬間
sadnessojisan
46
13k
リンクアンドモチベーション ソフトウェアエンジニア向け紹介資料 / Introduction to Link and Motivation for Software Engineers
lmi
4
300k
Featured
See All Featured
Building Adaptive Systems
keathley
38
2.3k
Adopting Sorbet at Scale
ufuk
73
9.1k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
840
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
Practical Orchestrator
shlominoach
186
10k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
47
2.1k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
Designing for Performance
lara
604
68k
Transcript
Kubernetes with Java Kubernetes Java #hirojug
1 - - $! +# &(# - ,%+&",
Java),,*,% '* Twitter-@7richi
2 5:)Oracle Code Japan Tour in Hiroshima*;)Cloud Native Java EE*LMJRT7KubernetesD14SFPIVNETHNQD56&,4
.UUU Kubernetes:%16+=@ .-544>'3; 7.CB4-+ =@7/6,9-54;. -54(W?>X 307'Kubernetes:%2A 9;8 ;OTKGTD "16Kubernetes<!#14,8 ,=2( $;
1.
4 ▪ Kubernetes.+CE7A-Kubernetes5%)Spring Boot* %'REST API5%)9D=?6E8<>BE;@D5&4 ▪:EA – Kubernetes.
– CE7A0Kubernetes.#43"-,4 – Kubernetes5%',9D=?6E8<>BE;@D. ▪%,!$+ – 9D=?(Docker)-&4 – Spring Boot. . – REST API-(!) . +:EA $$%,!+ 12/Java+/ ,!.*/
5 -2/=5 ▪Kubernetes& ▪<>1; & ▪8=30= – Pod#&69<. – Replica
Set+69<. – Deployment+69<. – Service& – Service+Blue/Green Deployment ▪ – 0>9=4:7>2018? ▪ – *# )!$(% – "',
2. Kubernetes
7 ▪miniKube – Windows exe (minikube-windows-amd64.exe) https://github.com/kubernetes/minikube/releases
8 mOp_uZzizJ n[xFDockerNG<IB=LYxbe"N =L[\bo{YxbeUzX\dvz[rxazu|1 GoogleA-/+:M@5LYxbeWs\_[\bo2Borg3AF gShSN/;@-:M>1GApachesQ]x\A, :M@5L Uzlx^z\^kdSTOA4L1 nQWwZzj\NEclwQ0O`lczd=L$B;@0YxbeF Uzd\Xzu0
Blue Green Deployment 0 Rolling Update DCF$ N7@5L1 ?DHE2Kubernetes3G0Vt[q(A2%F!32 #y,#3B56 94LB:M12k8s3B:M'*:ML9 51 {8GK8KsF.F N&;@5L| )HG2WzmzfPb\3J2WRifPb\3} KubernetesBG
9 ▪2014 66 ▪2015 76.5*141.0335+ ▪2015 76Linux Foundation&Cloud Native Computing
Fou ndation(CNCF)% (AT&TCiscoCoreOSDockerIBMIntelMicrosoftRed HatVM ware$#&% () ▪2017 86AWSCNCF%04.5&/2,- " )'!& $
10 ]udh+O NQR4 Wlq\v_ouOeltXP%N>4) %N*;SQ:NMGF5A<A1O/$JP,OWlq\v_ouU. @ CIHO^vj`KAIBS-=8S5w!NmX[t^vj`%MW ltvbJPxE?J]udh0O.= KMR2O&ML/$3 U(AF
4,]udhU'#BS_`dn=-KMGF5 6AWS76Microsoft Azure76Google Cloud Platform76IBM Bluemix7ML O-[pYgltiXav=CNCFONMGFNQR4"OK?T]u dhZv\`fsv_oucvrKAIKubernetesPekV[fK9;SN MRHH8S ▪KubernetesOZv\`fsv_oucvr Docker Swarm4Amazon EC2 Container ServiceML=8S MD]udhZv\`fsv_oucvr=-NMGFO<
11 ▪1%PGOCa frgp} – dy%YGCPAAWSLBJKXk8s_;GK7A='H]M(RUM `N)&GOC ▪jru2PGOCjru1% – jru2%Q8 PZ\Open Container
InitiativeE<WKC]j ru#LB^SDockerQjru2LXZC ▪3zmtPjru_syc – NQzmtPNQjru_>H]D_@0 ▪jru?Qvqt g,$ 6!XV – k xmsbmew +Q- ▪jruQ"*5 – jruE`I[Ajru_. L4: ▪jruQ9/ – -Q3jruTQagnmwlh- ▪jruQo mai l~ – jru PCPUo mY{| o mQ - KubernetesR_GKF^]QD
12 ▪ % #Ingress $ Kubernetes Cluster
Node Pod " ! Service Ingress internet Node Pod " ! Node Pod " ! Service
13 ▪Node/Cluster Node^cIk8sbvnpVlYgbVM`KT24w bR^J k8sn94Vl=dIxN) Vl \bvNRmj Node]@SmlJNodebHnCliuter^e ▪Pod k8s]bpb,!JPodc bvbH]INode
a"FSmlk8s-b0$J Podb3#c&TYvc \+aUNodeapSmlJRm aik<VlA*b{zv]1%SmYZbouy ]LKnBZQhVPTZbH^T\p/l zry^ouyIouyb^ sq `_b:W – Pod bvclocalhost;6]D ]Ol – EMj8(Podfcos{zc/`K – Label:k8s]94Sm\Kl|zc>a[O?7a.IpS mlNXbGa~`N?7a'jmlIXmjnBZQhVPVlY gPoda T\}tnVlR^N/l Kubernetesb5C[1/3]
14 ▪Service $Pod?8; IPK]hVJ G;Hk8s@"<.!? ServiceB@KRWV3Pod?G 5FIH@<ik]_ejT@?H #1/k8s<ATk`V[LVQ_fJ9H:@fXkV=7I;0H – Service@
- ▪ ClusterIP:ReVY)?Tk`VJ*8C9/6@J(9H=.ReVY2F@ DTk`V?KRWV<4C9([aPg\) ▪ NodePort: ^k]IP?+>ck\<Tk`VJ*8C9/ <NodeIP>l<NodePort>J%9H6=?EG.ReVY2FNodePortTk`V? KRWV<4C9 ▪ LoadBalancer:ReN]bi_MZ@ik]_ejTJ8;)?Tk`VJ* 8C9(minikubeA,) ▪ ExternalName:DNS@CNAMEhSk]J&9H6=?EG.ReVY) 5@OM fKVJ9H/6I?A_kUdj1.7@kube-dns3% Kubernetes@'[2/3]
15 ▪Ingress IngressYServiceW[]ICAdServiceW{joNaDHTTP vx|nW- MR8LbREa,CL7SXURLyqW_a~ sfl^SSL43 /VUX<]7FaD\PCIngressYk8sH2M REa0W_QR*6T8HGcaCGCPSYGCPXCAWSSYAWS X0W QPS{joH
Lba ▪Replica Set PodX{}i$PodXmsw$d5!/=Na*6DmswH" MP{}i$_`]VE Y%PWmswd? MCFNJRa Ymswd BM{}i$d5!Na ▪Deployment Pod^Replication SetsX:er{tu*6d#DDeploymenth zpgkuS(Na.d;@NbZDeployment ControllerH9+M P.W&MRKba OXW]Kubernetes'X)C1>H$Na KubernetesX1>[3/3]
3.
17 Minikube"k8s)#& %'8=.=! $ ;=*:7/=<!VM k8+901!,<24) '$ !-=6(Kubernetes
Master)5=3!k8s+901) (' >Minikube " Ingress" ? Minikube" ;=*:7/=< (Linux,Mac OS,Windows) VM(VirtualMachine) Kubernetes(minikube) Kubernetes Master Node (1!#)
18 ▪ – virtualBox 4Q<BRO#1(0"* ▪minikube-=@B3@H – miniKube-?5QPRC ▪ Windows
- exe (minikube-windows-amd64.exe) https://github.com/kubernetes/minikube/releases – minikube- ▪ minikube-windows-amd64.exe2minikube.exe *NDRJ$(F<-'&G7 O?,! ▪ AG7OB- vm driver 2 VirtualBox ,%0&.-9IQC – kubectl 4Q<BRO#1(+-)6MRK@=R; #10 – #1&URL / kubectl.exe 2?5QPRC$(F<-'&G7O?, – vm driver 2 VirtualBox ,%0&.9IQC2 %0 ▪Kubernetes8M<>- – -9IQC)8M<>2%0 – -9IQC):RERER;LQ2 &/ Windows,kubernetes 2%0 $ minikube config set vm-driver virtualbox $ minikube start $ minikube version
4.
20 /8*#8 Docker6()-4 Spring Boot REST APIDocker"29(! Kubernetes&8+.#9%)- 69'38!
▪Docker6()-4 – docker.io/uls555/getting-started-k8s-with-java ▪,07" /8*#8 Docker Hub 79$51'98 Docker Image REST API minikube push pull
21 REST API REST API Docker Hub
Docker Image REST API minikube
22 /%-Pod,6 4+Pod,@EL86#'04J>M< - GCD9<A).5YAML ($4 ▪Pod, ) – ,
(pod.yaml6 – Pod6 ▪Pod, – ",Pod-:I<?,EI8FMAIP7BK<#!&'*,(!3- 7:=<* – Dashboard(1#'02NURL:http://192.168.99.100:30000O Pod(,@EL8[1/2] apiVersion: v1 kind: Pod metadata: name: rest-api spec: containers: - image: docker.io/uls555/getting-started-k8s-with-java:v1 imagePullPolicy: Always name: rest-api $ kubectl create -f pod.yaml $ kubectl get pods NAME READY STATUS RESTARTS AGE rest-api 0/1 ContainerCreating 0 1m 8HM;,
23 nPod Pod [2/2] $ kubectl delete pod rest-api
24 Pod/ "$Pod "$+, /%$ +*) !.*Replica Set/"&+Pod/ #-
▪Replica Set+ ( – + 'replicaset.yaml/ – Replica Set/ Replica Set/"$1230[1/2] apiVersion: extensions/v1beta1 kind: ReplicaSet metadata: name: rest-api-rs spec: replicas: 3 template: metadata: labels: app: my-rest-api spec: containers: - image: docker.io/uls555/getting-started-k8s-with-java:v1 imagePullPolicy: Always name: rest-api $ kubectl create -f replicaset.yaml #-Pod+ Pod+
25 ▪Pod ▪Pod Replica SetPod " Pod"
Pod – Pod ▪Replica Set Replica Set" $%&#[2/2] $ kubectl get pod NAME READY STATUS RESTARTS AGE rest-api-rs-6xpqf 1/1 Running 0 1m rest-api-rs-m1x43 1/1 Running 0 1m rest-api-rs-pbsmk 1/1 Running 0 1m $ kubectl delete pod rest-api-rs-m1x43 $ kubectl get pod NAME READY STATUS RESTARTS AGE rest-api-rs-6xpqf 1/1 Running 0 4m rest-api-rs-m1x43 1/1 Terminating 0 4m rest-api-rs-n92wz 0/1 ContainerCreating 0 5s rest-api-rs-pbsmk 1/1 Running 0 4m !Pod !Pod $ kubectl delete replicaset rest-api-rs
26 Replica Set0!/$ k8s&-%Deployment0 !/$&,.6;?2' k8s&/"+'9A4=@& & /$/ ▪Deployment'
$6;?2 – ' #deployment.yaml0 – 6;?2 Deployment0 "6;?2[1/3] apiVersion: apps/v1beta1 kind: Deployment metadata: name: rest-api-dep spec: replicas: 3 template: metadata: labels: app: my-rest-api spec: containers: - image: docker.io/uls555/getting-started-k8s-with-java:v1 imagePullPolicy: Always name: rest-api <8:357:12>( RepulicsSet$)* $ kubectl create -f deployment.yaml
27 ▪Pod ▪Deployment – Replicas 4
Deployment [2/3] $ kubectl get pods NAME READY STATUS RESTARTS AGE rest-api-rs-6xpqf 1/1 Running 1 9h rest-api-rs-n92wz 1/1 Running 1 9h rest-api-rs-pbsmk 1/1 Running 1 9h apiVersion: apps/v1beta1 kind: Deployment metadata: name: rest-api-dep spec: replicas: 4 template: metadata: labels: app: my-rest-api spec: containers: - image: docker.io/uls555/getting-started-k8s-with-java:v1 imagePullPolicy: Always name: rest-api replica 4
28 ▪Deployment – Deployment ▪Pod – Pod14 Deployment
[3/3] $ kubectl get pods NAME READY STATUS RESTARTS AGE rest-api-rs-6xpqf 1/1 Running 1 9h rest-api-rs-9b0sl 1/1 Running 0 10s rest-api-rs-fbcdf 0/1 ContainerCreating 0 10s rest-api-rs-pbsmk 1/1 Running 1 9h $ kubectl apply -f deployment.yaml
29 Service7 (,&62- (*Pod7+0/(*8=;97 5..3/#407Pod/)5 ▪Service0 . – 0 -service.yaml7
– Service7 ▪Service0 Service0 [1/3] kind: Service apiVersion: v1 metadata: name: rest-api-service spec: type: NodePort selector: app: my-rest-api ports: - port: 8080 targetPort: 8080 $ kubectl create -f service.yaml Service01Nodeport7)5 minikube-1LoadBalancer1 Pod0Lavel/ app:my-rest-api!$ '6,"5Pod7%5 )5Service0<=:.Pod0<=:7 %5 $ kubectl get services NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes 10.0.0.1 <none> 443/TCP 11h rest-api-service 10.0.0.51 <nodes> 8080:31372/TCP 1m
30 ▪ Service – Node IP –
▪Deployment – v2 Service [2/3] $ minikube ip 192.168.99.100 http://192.168.99.100:31372 apiVersion: apps/v1beta1 kind: Deployment metadata: name: rest-api-dep spec: replicas: 4 template: metadata: labels: app: my-rest-api spec: containers: - image: docker.io/uls555/getting-started-k8s-with-java:v2 imagePullPolicy: Always name: rest-api v2
31 ▪Deployment – ▪ Deployment &)-'!"%+ #/ $*&0'
.0,/ $*&0' – ▪Deployment.0-($ – .0-($ – Service[3/3] $ kubectl apply -f deployment.yaml deployment "rest-api-dep" replaced $ curl 192.168.99.100:31372 {"message":"Hello World!","version":"v2"} $ kubectl rollout undo deployment/rest-api-dep deployment "rest-api-dep" rolled back $ curl 192.168.99.100:31372 {"message":"Hello World!","version":"v1"}
32 Deployment0 #.!'&:<9;31586<7+% )- ,/( Blue/Green Deployment*(0- +Service 0"-. .
▪)Deployment0 – * &deployment-v3.yaml0 – 68:2 Service0"$Blue/Green Deployment[1/2] apiVersion: apps/v1beta1 kind: Deployment metadata: name: rest-api-dep-v3 spec: replicas: 3 template: metadata: labels: app: my-rest-api-v3 spec: containers: - image: docker.io/uls555/getting-started-k8s-with-java:v1 imagePullPolicy: Always name: rest-api Deployment* '4 30v3) $ kubectl create –f deployment-v3.yaml
33 – Deployment ▪Service – ServicePod selector –
ServiceBlue/Green Deployment[2/2] $ kubectl get deployment NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE rest-api-dep 4 4 4 4 3h rest-api-dep-v3 4 4 4 4 23m kind: Service apiVersion: v1 metadata: name: rest-api-service spec: type: NodePort selector: app: my-rest-api-v3 ports: - port: 8080 targetPort: 8080 PodLavel app:my-rest-api-v3 Pod $ kubectl apply -f service.yaml service "rest-api-service" configured $ curl 192.168.99.100:31372 {"message":"Hello World!","version":"v3"}
5.
35 ▪minikube start%* – Node –
”.minikube”!("& minikube "%#'$* ) $ minikube stop $ minikube delete $ minikube start
36 > ▪ WEB1-5 – Using Kubernetes on Google
Container Engine https://www.slideshare.net/enakai/using-kubernetes-on-google-container-engine – Docker& %$2 @Kubernetes@ https://oss.sios.com/yorozu-blog/yorozu-20151216 – Docker0=46, )!(Kubernetes http://tech.uzabase.com/entry/2015/02/13/180743 – minikube Windows " Kubernetes , ) http://takaya030.hatenablog.com/entry/2017/04/30/191727 – kubernetes +)23-; 9-.<1?72'!&'! http://sssslide.com/speakerdeck.com/sgeengineer/kubernetesdebian-warukai-fa-sutairu- maikurosabisuziyanakutemoiiziyanai – Kubernetes +*) http://qiita.com/t-yotsu/items/f565b2d788a3b98fe762 ▪ – 8</:9#%#Google Cloud Platform – WEB+DB-PRESS Vol.99