How Kubernetes works

How Kubernetes works

Mini Tech Talk at GREE, inc. 2017.08.30

9f9df80ab6551776b49c4ad9432ba1b7?s=128

Kazuki Suda

August 30, 2017
Tweet

Transcript

  1. 5.

    ,VCFSOFUFT Ӝ ؝ٝذشؔ٦؛أزٖ٦ءّٝخ٦ٕ ؝ٝذشךꂁ⪒ծ鏣㹀ծ盖椚׾遤ֲ Ӝ ĜĦĔėģğήĥęςؘٔءٍ铂ד乼菭㡦 Ӝ (PPHMFך爡ⰻءأذيַ׵؎ٝأػ؎،ׁ׸׋  “Kubernetes

    is open source—a contrast to Borg and Omega,
 which were developed as purely Google-internal systems. “ Borg, Omega, and Kubernetes
 https://research.google.com/pubs/pub44843.html
  2. 8.

    ➭ךفٓحزؿؓ٦يהך嫰鯰  Ӝ *OGSBTUSVDUVSFBTB 4FSWJDF Ӝ 7. ر؍أؙ طحز ٙ٦ؙ

    ,VCFSOFUFT Ӝ $POUBJOFSBTB4FSWJDF Ӝ ؝ٝذشך盖椚ծ㹋遤 Ӝ ֮׵ײ׷،فٔ؛٦ءّٝ $MPVE'PVOESZ Ӝ 1MBUGPSNBTB4FSWJDF Ӝ ؝٦سַ׵رفٗ؎ Ӝ )551ծ"1*ծ8FC 0QFO4UBDL
  3. 10.

    ,VCFSOFUFTכؔ٦فٝד֮׷ Ӝ ؔ٦فٝا٦أاؿزؐؑ، HJUIVCDPNLVCFSOFUFTLVCFSOFUFT "QBDIF-JDFOTF  Ӝ ؔ٦فٝرؠ؎ٝ HJUIVCDPNLVCFSOFUFTDPNNVOJUZ Ӝ

    ؔ٦فٝ؝ىُصذ؍ 4QFDJBM*OUFSFTU(SPVQT 4*(T  4MBDL 4UBDL0WFSPX Ⰻ⚅歲ד⟃♳ךى٦ز،حف Ӝ $MPVE/BUJWF$PNQVUJOH'PVOEBUJPO $/$' 
  4. 11.

    $VSSFOU1SPKFDUT Kubernetes
 Orchestration Prometheus
 Monitoring OpenTracing
 Tracing flutentd
 Logging Linkerd


    Service Mesh GRPC
 Remote Procedure Call CoreDNS
 Service Discovery Containerd
 Container Runtime rkt
 Container Runtime CNI
 Networking https://www.cncf.io/projects/
  5. 13.

    

  6. 14.

    

  7. 16.

    ,VCFSOFUFTכه٦ةـٕד֮׷ Ӝ DMPVEQSPWJEFS --# ـٗحؙأزٖ٦آזוך乼⡲׾䬄韋⻉ ($1 "84 "[VSF 0QFO4UBDL 

    Ӝ $/* $POUBJOFS/FUXPSL*OUFSGBDF $BMJDP 'MBOOFM 0QFOW4XJUDI 8FBWF  Ӝ $POUBJOFS3VOUJNF %PDLFS SLU DSJP 
  8. 17.

    ,VCFSOFUFTכ䧭ꞿ׃גְ׷  Kubernetes Docker Swarm Apache Mesos All Time Statistics

    Contributors 1,473 201 288 Commits 49,619 3,331 24,308 12 Month Statistics Contributors 756 66 155 Commits 19,223 567 7,946 https://www.openhub.net/p/_compare?project_0=Kubernetes&project_1=docker+swarm&project_2=Apache+Mesos As of 17/06/12
  9. 18.
  10. 23.

    1PET Ӝ 醱侧ך؝ٝذشה
 醱侧ךنُٔ٦ي Ӝ رفٗ؎ך剑㼭⽃⡘ Ӝ *1QFS1PE  apiVersion:

    v1 kind: Pod metadata: name: nginx spec: containers: - name: nginx image: nginx:1.13.3 ports: - containerPort: 80
  11. 27.

    3FQMJDB4FUT Ӝ /⦐ך1PEָ
 㹋遤ׁ׸גְ׷朐䡾׾⥂א  apiVersion: extensions/v1beta1 kind: ReplicaSet metadata:

    name: nginx spec: replicas: 2 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.13.3 ports: - containerPort: 80
  12. 28.

    %FQMPZNFOUT  %FQMPZNFOU Replicas: 2 Selector: app=web
 image: app:v1 Pod


    Template 1PE app:v1 1PE app:v1 34 Replicas: 2 app:v1 Ӝ ٗ٦ؚٔٝ،حفر٦ز Ӝ ٗ٦ٕغحؙ
  13. 29.

    %FQMPZNFOUT  %FQMPZNFOU Replicas: 2 Selector: app=web
 image: app:v2 Pod


    Template 1PE app:v1 1PE app:v1 34 Replicas: 2 app:v1 Ӝ ٗ٦ؚٔٝ،حفر٦ز Ӝ ٗ٦ٕغحؙ
  14. 30.

    %FQMPZNFOUT  %FQMPZNFOU Replicas: 2 Selector: app=web
 image: app:v2 Pod


    Template 1PE app:v1 1PE app:v1 34 34 Replicas: 2 app:v1 Replicas: 1 app:v2 Ӝ ٗ٦ؚٔٝ،حفر٦ز Ӝ ٗ٦ٕغحؙ
  15. 31.

    %FQMPZNFOUT  %FQMPZNFOU Replicas: 2 Selector: app=web
 image: app:v2 Pod


    Template 1PE app:v1 1PE app:v1 34 34 Replicas: 2 app:v1 1PE app:v2 Replicas: 1 app:v2 Ӝ ٗ٦ؚٔٝ،حفر٦ز Ӝ ٗ٦ٕغحؙ
  16. 32.

    %FQMPZNFOUT  %FQMPZNFOU Replicas: 2 Selector: app=web
 image: app:v2 Pod


    Template 1PE app:v1 1PE app:v1 34 34 Replicas: 1 app:v1 1PE app:v2 Replicas: 1 app:v2 Ӝ ٗ٦ؚٔٝ،حفر٦ز Ӝ ٗ٦ٕغحؙ
  17. 33.

    %FQMPZNFOUT  %FQMPZNFOU Replicas: 2 Selector: app=web
 image: app:v2 Pod


    Template 1PE app:v1 34 34 Replicas: 1 app:v1 1PE app:v2 Replicas: 1 app:v2 Ӝ ٗ٦ؚٔٝ،حفر٦ز Ӝ ٗ٦ٕغحؙ
  18. 34.

    %FQMPZNFOUT  %FQMPZNFOU Replicas: 2 Selector: app=web
 image: app:v2 Pod


    Template 1PE app:v1 34 34 Replicas: 2 app:v2 Replicas: 1 app:v1 1PE app:v2 Ӝ ٗ٦ؚٔٝ،حفر٦ز Ӝ ٗ٦ٕغحؙ
  19. 35.

    %FQMPZNFOUT  %FQMPZNFOU Replicas: 2 Selector: app=web
 image: app:v2 Pod


    Template 1PE app:v1 1PE app:v2 34 34 Replicas: 2 app:v2 Replicas: 1 app:v1 1PE app:v2 Ӝ ٗ٦ؚٔٝ،حفر٦ز Ӝ ٗ٦ٕغحؙ
  20. 36.

    %FQMPZNFOUT Ӝ ٗ٦ؚٔٝ،حفر٦ز Ӝ ٗ٦ٕغحؙ  %FQMPZNFOU Replicas: 2 Selector:

    app=web
 image: app:v2 Pod
 Template 1PE app:v1 1PE app:v2 34 34 Replicas: 2 app:v2 Replicas: 0 app:v1 1PE app:v2
  21. 37.

    %FQMPZNFOUT Ӝ ٗ٦ؚٔٝ،حفر٦ز Ӝ ٗ٦ٕغحؙ  %FQMPZNFOU Replicas: 2 Selector:

    app=web
 image: app:v2 Pod
 Template 1PE app:v2 34 34 Replicas: 2 app:v2 Replicas: 0 app:v1 1PE app:v2
  22. 38.

    %FQMPZNFOUT Ӝ ٗ٦ؚٔٝ،حفر٦ز Ӝ ٗ٦ٕغحؙ  apiVersion: apps/v1beta1 kind: Deployment

    metadata: name: nginx spec: replicas: 2 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.13.3 ports: - containerPort: 80
  23. 39.

    4FSWJDFT Ӝ ⟎䟝*1הه٦ز Ӝ ٓكٕإؙٖةח״׷
 1PEךؚٕ٦ؾؚٝ Ӝ ؟٦ؽأة؎ف $MVTUFS*1 /PEF1PSU

    -PBE#BMBODFS   1PE app web 1PE app web 3FQMJDB4FU 4FSWJDF VIP: 10.0.0.249 Selector: app=web
  24. 40.

    4FSWJDFT Ӝ ⟎䟝*1הه٦ز Ӝ ٓكٕإؙٖةח״׷
 1PEךؚٕ٦ؾؚٝ Ӝ ؟٦ؽأة؎ف $MVTUFS*1 /PEF1PSU

    -PBE#BMBODFS   apiVersion: v1 kind: Service metadata: name: nginx spec: type: ClusterIP selector: app: nginx ports: - protocol: TCP port: 80 targetPort: 80
  25. 41.
  26. 42.

    *OHSFTT Ӝ -頾蚚ⴓ侔 Ӝ غ٦ثٍٕمأز Ӝ ػأח״׷䮶׶ⴓֽ Ӝ 5-4穄畭 

    apiVersion: extensions/v1beta1 kind: Ingress metadata: name: example-com spec: rules: - host: example.com http: paths: - path: /foo backend: serviceName: foo servicePort: 80 - path: /bar backend: serviceName: bar servicePort: 80
  27. 43.

    ׉ך➭ Ӝ /BNFTQBDFTؙٓأة׾ⴓⶴׅ׷ Ӝ $POH.BQT،فٔ؛٦ءّٝה鏣㹀ךⴓꨄ Ӝ 4FDSFUT،فٔ؛٦ءّٝהء٦ؙٖحزךⴓꨄ Ӝ 1FSTJTUFOU7PMVNFT 1FSTJTUFOU7PMVNF$MBJNT

    4UPSBHF$MBTT宕竲نُٔ٦ي Ӝ 4UBUFGVM4FUTأذ٦زؿٕ،فٔ؛٦ءّٝ Ӝ +PCTٙٝءّحزآّـ Ӝ $SPO+PCآّـך㹀劍㹋遤 Ӝ %BFNPO4FUTⰋגךظ٦سד1PE׾㹋遤 Ӝ )PMJ[POUBM1PE"VUP4DBMFSؔ٦زأ؛٦ٕ 
  28. 45.

     ،٦ؗذؙثٍ $POUSPMMFS
 .BOBHFS FUDE 4DIFEVMFS BQJTFSWFS CLI API UI

    Master Node 1 Node “n” $POUBJOFS
 3VOUJNF LVCFMFU LVCFMFU $POUBJOFS
 3VOUJNF
  29. 46.

     FUDE㈓♧ךر٦ةأز، $POUSPMMFS
 .BOBHFS FUDE 4DIFEVMFS BQJTFSWFS Master Ӝ $1㘗ךⴓ侔ؗ٦غُٔ٦أز،

    Ӝ أذ٦زכⰋגFUDEח⥂㶷ׁ׸׷ Ӝ ؐؓحث׾؟ه٦ز׃גֶ׶ծ
 أذ٦زך㢌刿כ׋׌׍ח➭ך
 ؝ٝه٦طٝزח鸐濼ׁ׸׷ Ӝ IUUQHJUIVCDPNDPSFPTFUDE CLI API UI
  30. 47.

     BQJTFSWFS3&45 $36% 钠鏾钠〳 $POUSPMMFS
 .BOBHFS FUDE 4DIFEVMFS BQJTFSWFS Master

    Ӝ 3&45Ⳣ椚הغٔر٦ءّٝ Ӝ 钠鏾钠〳 Ӝ ㈓♧FUDEחر٦ة׾剅ֹ鴥׬ Ӝ ؽآطأٗآحؙכ㹋鄲ׁ׸גְזְ CLI API UI
  31. 48.

     4DIFEVMFS1PEךأ؛آُ٦ؚٔٝ $POUSPMMFS
 .BOBHFS FUDE 4DIFEVMFS BQJTFSWFS Master Ӝ 1PEךٔا٦أ銲実זו罋䣁׃ג


    黝ⴖז/PEFחأ؛آُ٦ؚׅٔٝ׷ Ӝ أ؛آُ٦ٕׅ׷/PEF׾
 䭷㹀ׅ׷ֿה׮דֹ׷ resources: requests: memory: "64Mi" cpu: "250m" CLI API UI
  32. 49.

     $POUSPMMFS.BOBHFSؽآطأٗآحؙ $POUSPMMFS
 .BOBHFS FUDE 4DIFEVMFS BQJTFSWFS Master Ӝ 3FQMJDB4FUT

    4FSWJDFTזוծٔا٦أך
 ؽآطأٗآحָؙ㹋鄲ׁ׸גְ׷ CLI API UI
  33. 51.

    LVCFMFU $POUBJOFS
 3VOUJNF Node  LVCFMFU BQJTFSWFS Master Ӝ /PEFח䌢꽎ׅ׷ؒ٦آؑٝز

    Ӝ BQJTFSWFS׾ؐؓحث׃גծ荈魦ך
 /PEFח1PEָأ؛آُ٦ׁٕ׸׷ה
 ؝ٝذش؎ً٦آך《䖤ծ㹋遤׾遤ֲ Ӝ ؝ٝذشך朐䡾ח䘔ׄגBQJTFSWFS׾
 鸐ׄג1PEךأذ٦ز׾刿倜ׅ׷