Slide 1

Slide 1 text

Kubernetes IBUFOBJOUFSO 

Slide 2

Slide 2 text

舅䄕磆☭ ˝ JENBTBZPTV ˝ 䇗僖⪌炘 ˝ ؤ٤ط٤صوٚشعنؚ٭ّכ لةؾتوٚشعنؚ٭ّס43& ך׌ 

Slide 3

Slide 3 text

铺紶ס⯥מ ׆ס铺紶⫂ךעLVCFSOFUFTסـ٤ث؛٤؅㲔产׌׾סך ׆׿־׼䣆⩕ס.BDמص٭ٜ؅ؕ٤تع٭ٜ׊ױ׌ 

Slide 4

Slide 4 text

ؕ٤تع٭ٜ ˝ %PDLFS %PDLFSGPS.BD ˝ CSFXJOTUBMM % brew update % brew install kubectl kustomize minikube mysql skaffold 

Slide 5

Slide 5 text

׆ס铺紶ך㰢؆ך׮׊ַ׆כ ˝ ם׏LVCFSOFUFT؅⮵榫׌׾ס־յLVCFSOFUFT؅⮵榫׌׾׆כ סْٛشع؅䣆؅Ⳃ־׊םֿ׼䚉׋׮׊ַ ˝ ⺱侇מLVCFSOFUFTס邾ꥭ׈׵䚉׋י׮׊ׂיյ舅骰ך䤗软鹟㲊 ׌׾侇ס免乢כ׊י׮׊ַ 

Slide 6

Slide 6 text

,VCFSOFUFTכע ˝ LVCFSOFUFT LT ˝ ؤ٤طػ؛٭آتعٝ٭ب٘٤סג״סخنعؘؗؓ ˝ ؤ٤طػסظوٞؕյ؛٭عتآ٭ٛ٤ءםלס畘杼؅舅Ⳃ⴫׌׾ג ״סوٚشعنؚ٭ّ ˝ 舅⯥ס擻杼ُب٤┕מوٚشعنؚ٭ّ؅啶疣׌׾׆כ׵⺎耆 ˝ قهٛشؠؠٚؗغך׵وٚشعنؚ٭ֿّ䬠❠׈׿יַ׾ ˝ "84&,4 ($1(,& "[VSF",4 

Slide 7

Slide 7 text

ם׏,VCFSOFUFT؅✳ֹס־ ˝ وٞرؠب٘٤梪㗞ךؤ٤طػ؅Ⳃ־׌ ˝ 냕⺎榫䓪؅㲔杯׌׾ג״מؤ٤طػ؛٭آتعٝ٭ب٘٤ֿ 䑒釐 ˝ ؤ٤طػסَ٭ذلٛطؔ؅孨־׊י냕ئؕؠٜםꝧ氦 ˝ ؓوٛآ٭ب٘٤յؕ٤نٚꝴסٕٝؕ٭؅LVCFSOFUFTֿ䥩 霄⴫׊יׂ׿׾ג״斻玮׊גꝧ氦٬鷞榫ֿ⺎耆 

Slide 8

Slide 8 text

ם׏,VCFSOFUFT؅✳ֹס־ ˝ ؤ٤طػ؛٭آتعٝ٭ب٘٤סظنؒؠعتذ٤ر٭غ ˝ 䇗㍑סٛٛ٭تئؕؠٜס╈ך䷉ャ׈׿י׀ג ˝ $MPVE/BUJWF$PNQVUJOH'PVOEBUJPO $/$' כַֹؤِٖؼ طؔס䡗捘 ˝ LVCFSOFUFTꝧ氦؅ئَ٭ع׌׾ג״סخنعؘؗؓ׵㛡丗㰆㏇ ˝ 㛻䣆قهٛشؠؠٚؗغךסLVCFSOFUFTئ٭لتס氦辐 

Slide 9

Slide 9 text

LVCFSOFUFTך⛰ֿך׀׾ס־ ˝ 㲚銧氳ם啶䡗畘杼 *OGSBTUSVDUVSFBT$PEF ˝ ؤ٤طػ鿥糋סتآةٖ٭ٛ٤ء ˝ 靷蕔⮆丆ئ٭لتظؔت؜فٛ٭ ˝ جٜنك٭ٛ٤ء ˝ ؛٭عتآ٭ٛ٤ء 

Slide 10

Slide 10 text

,VCFSOFUFTס啶䡗 

Slide 11

Slide 11 text

$MVTUFS ˝ ُتذ٭ؿ٭غכ٠٭؜٭ؿ٭غך啶䡗׈׿׾ ˝ ُتذ٭ؿ٭غ ˝ ؤ٤عٞ٭ٜوٝ٭٤ ˝ ؠٚتذ؅畘杼؅䥵䎎 ˝ قهٛشؠؠٚؗغךעُؾ٭ةغמ䬠❠׈׿׾ ˝ ٠٭؜٭ؿ٭غ ˝ ظ٭ذوٝ٭٤ ˝ ؤ٤طػ؅㲔车׌׾ג״סؤ٤مٖ٭طؔ٤ءٛ خ٭تס꥗ױ׽ ˝ 邾丗סOPEF؅玮ה┕ׅ׾׆כך냕⺎榫䓪؅䐂׾׆ כֿך׀׾ 

Slide 12

Slide 12 text

/PEF ˝ 擻杼PS♞䘶סئ٭ف٭ ˝ 邾丗ס1PE ؤ٤طػ ؅㲔车׌׾ג״סؤ٤ مٖ٭طؔ٤ءٛخ٭ت ˝ LVCFMFUֿ颯Ⳃ׊יַיُتذ٭ؿ٭غס "1*כ׷׽כ׽؅׌׾ ˝ /PEFע邾丗⺏ך颯Ⳃ׈׿ؠٚؗغ梪㗞ךע تآ٭ٜ׌׾☼磝ײ؅㵵⪌׊יַ׾㕙⺬ֿ 㛡ַ 

Slide 13

Slide 13 text

1PE ˝ ظوٞؕס僃㵸ⶡ⛣ ˝ 1PEעח♓┕סؤ٤طػ־׼啶䡗׈׿׾ ˝ ْؕ٤סؓوٛآ٭ب٘٤ؤ٤طػכא׿؅ 遨Ⲃ׌׾ئهؤ٤طػ־׼啶䡗׈׿׾ 

Slide 14

Slide 14 text

1PEסظاؕ٤قذ٭٤ ˝ ئؕغ؜٭قذ٭٤ ˝ ئهؤ٤طػעْؕ٤ؤ٤ط ػ؅ئَ٭ع׌׾׻ֹם䏔Ⱏ ؅䥵ֹ ˝ ❆ 1SPYZ ٞء鬇鴜 泃釱 ؙ٭ةؘ٤ع 

Slide 15

Slide 15 text

,VCFSOFUFTסٛخ٭ت 

Slide 16

Slide 16 text

LVCFSOFUFTסٛخ٭تכ؜طإٛ ˝ 8PSLMPBET ؤ٤طػס㲔车מ꞊׌׾ٛخ٭ت ˝ 4FSWJDF ؤ٤طػ؅㛙鼧⪜ꝧ׌׾׻ֹםؙ٤غَؕ٤ع؅䬠❠׌׾ٛخ٭ت ˝ $POH4UPSBHF 錃㲊٬嚀㳡䗯㕔٬姧禈⴫ٍٖٛ٭ّםלמ꞊׌׾ٛخ٭ت ˝ $MVTUFS ج؞ٖٛطؔ׷ؠؚ٭ذםלמ꞊׌׾ٛخ٭ت ˝ .FUBEBUB ؠٚتذ⫂ס☽סٛخ٭ت؅䳩⛼׌׾ג״סٛخ٭ت /BNFTQBDFכַֹ♞䘶氳םؠٚتذס⮆ꦕ嚀耆 

Slide 17

Slide 17 text

8PSLMPBET؜طإٛ ˝ 1PE ח♓┕סؤ٤طػ־׼啶䡗׈׿יַ׾ 1PE⫂מ⻠ױ׿׾ؤ٤طػע⺱׋ؾشع٠٭ ؠ⫂מ㰆㏇׊⺱┉*1؅䧏ח ˝ 3FQMJDBTFU 1PEסٝوٛ؜؅⛼䡗׊י䧗㲊׊ג丗ס1PE ؅禴䧏׌׾ جٜنك٭ٛ٤ء ⺱׋ؓوٛآ٭ب٘٤ֿⳂ⛼׊יַ׾邾丗ס 1PEֿ姡䇖מ㷣ꝧ׈׿׾ ˝ %FQMPZNFOU 邾丗ס3FQMJDBTFU؅畘杼׊יٞ٭ٛ٤ءؓش وظ٭ع׷ٞ٭ٜفشؠםל؅⺎耆מ׌׾ 

Slide 18

Slide 18 text

8PSLMPBET؜طإٛ ☪㍑סـ٤ث؛٤ךע⮵榫ם׊ ˝ +PC ؤ٤طػ؅⮵榫׊י٠٤؛نס⭚杼؅㲔车׈׎׾ٛخ٭ت ˝ $SPO+PC تآةٖ٭ٜ׈׿ג侇ꝴמKPC؅㲔车׌׾ٛخ٭ت 

Slide 19

Slide 19 text

4FSWJDF؜طإٛ ؤ٤طػ؅㛙鼧⪜ꝧ׌׾׻ֹםؙ٤غَؕ٤ع؅䬠❠׌׾ٛخ٭ت ⹨⟓׊גعٚنؔشؠ؅邾丗ס1PEמٞ٭غفٚ٤ب٤ء׌׾ ˝ 4FSWJDF ˝ -ٞ٭غفٚ٤ئ ˝ ئ٭لتظؔت؜فٛ ˝ *OHSFTT ˝ -ٞ٭غفٚ٤ئ 

Slide 20

Slide 20 text

LVCFSOFUFTؠٚتذ⫂ס鵟⟓ ˝ ⺱׋1PE⫂סؤ٤طػמ鵟⟓׌׾㕙⺬עMPDBMIPTU㲌מ鵟⟓׌׾ ˝ ⮯ס1PE⫂סؤ٤طػמ鵟⟓׌׾㕙⺬ע1PEס*1㲌מ鵟⟓׌׾ ˝ *1㲌ס鵟⟓ע⺎耆דֿؓوٛآ٭ب٘٤־׼*1؅䧗㲊׌׾כ㲔 鷞榫┕ך鐐갭ֿ氦榟׌׾ ˝ 1PEס*1ע1PEֿ⪌׿僀؂׾䈱מ樟ם׾*1ֿⰟ׽䎎י׼׿׾ ˝ 1PEֿ⢥塛׊ג㕙⺬מئ٭لت了ֿ氦榟׌׾ 

Slide 21

Slide 21 text

4FSWJDFٞ٭غفٚ٤ئ ˝ 邾丗ס1PEמ㵚׌׾ٞ٭غفٚ٤ب٤ء؅舅Ⳃ氳מ啶䡗׌׾ ˝ ٞ٭غفٚ٤ب٤ء 靷蕔⮆丆 ס⪌׽⹾כם׾ؙ٤غَؕ٤ع؅䬠❠ ˝ ؙ٤غَؕ٤عמעⶡ┉ס♞䘶*1ֿⰟ׽䎎י׼׿׾ ˝ ؙ٤غَؕ٤عס牊걉ע榫鵍מ׻זי喋չ ˝ $MVTUFS*1 ⫂鼧⺸ׄ ˝ /PEF1PSU 㛙鼧⺸ׄ ˝ -PBE#BMBODFS 㛙鼧⺸ׄ ˝ FUD 

Slide 22

Slide 22 text

4FSWJDFئ٭لتظؔت؜فٛ ˝ Ⳃ氳מ1PEֿ⪌׿僀؂׾ؠٚتذ٭⫂ך䗯㕔؅ 氧ꎰյ氦釤׌׾ג״ס☼磝ײ ˝ ؠٚتذ⫂%/4ס⮵榫ֿ䫟㝢׈׿יַ׾ ˝ ٞ٭غفٚ٤ب٤ءס⪌׽⹾כם׾ؙ٤غَ ؕ٤ع؅ؠٚتذ⫂%/4מ舅Ⳃ氳מ氧ꎰ׌׾ ˝ BDDPVOUئ٭لتעaccount.hatena- intern-2021.svc.cluster.localכַֹ 䎬䌋ך%/4"ٝؤ٭غמⰟ׽䎎י׼׿׾ 

Slide 23

Slide 23 text

*OHSFTT ˝ *OHSFTT ˝ -סٞ٭غفٚ٤ئ ˝ 㲔逷ע喋չ "84"-# ($1($-# ؠٚتذ⫂/HJOY ˝ )5514ס磙珷 ˝ *OHSFTT$POUSPMMFS ˝ *OHSFTTٛخ٭تֿ氧ꎰ׈׿׾כ┕鋗㲔逷ס㲔⛮؅⛼䡗׌׾ ˝ "84-PBE#BMBODFS$POUSPMMFS ˝ (,&*OHSFTT$POUSPMMFS ˝ /HJOY*OHSFTT$POUSPMMFS 

Slide 24

Slide 24 text

ٛخ٭ت畘杼מחַי 

Slide 25

Slide 25 text

.BOJGFTU ˝ ٛخ٭ت㲊紶ֿ傴־׿ג:".- ˝ kubectl apply -f מ׻זיLTؠٚتذמ 鸵榫 ˝ ׆׿מ׻׽㲚銧氳םؤ٭غמ׻׾畘杼ֿ⺎耆כם׾ ˝ *OGSBTUSVDUVSFBT$PEF 

Slide 26

Slide 26 text

ٛخ٭ت⯆꡾ ˝ 1PEמ㵚׊יⰟ׽䎎י׾$16׷ْٓٛס⯆꡾؅车ֹ׆כֿך׀ ׾ ˝ $16ؤؓ W$16 ؅N NJMMJDPSFT כ׊י䧗㲊 ˝ 釐姲כ⯆꡾ ˝ ┖꡾כ┕꡾؅䧗㲊ך׀׾ ˝ ؿ٭غמ1PE؅鿥糋׌׾꤀מ縒䜡׈׿׾ 

Slide 27

Slide 27 text

ىٜتزؘشؠ ˝ 1PEֿ塜׊ׂⳂ⛼׊יַ׾־澬鏀׌׾ג״ס☼磝ײ ˝ -JWFOFTT1SPCF ˝ ؓوٛآ٭ب٘٤ֿ颯Ⳃ׊յؤ٤طػֿ塜׊ׂⳂ⛼׊יַ׾־לֹ־ ˝ زؘشؠֿ鵟׼ם־זגכ׀ע1PE؅⫋颯Ⳃ׌׾ ˝ 3FBEJOFTT1SPCF ˝ 1PEֿٛؠؙتع؅⹨ׄ♀ׄ׾嶖⤓ֿך׀יַ׾־לֹ־ ˝ زؘشؠֿ鵟זגכ׀מعٚنؔشؠ؅⹨ׄ⪌׿׾ 

Slide 28

Slide 28 text

⺎榫䓪כ䦡䍖䓪מחַי 

Slide 29

Slide 29 text

⺎榫䓪 ˝ جٜنك٭ٛ٤ء ˝ 3FQMJDBTFUֿؤ٤طػסوٞجت泃釱؅车 ֹ ˝ زؘشؠמ㜊䷴׌׾כ.BOJGFTUך錃㲊׊ג ٝوٛ؜丗؅禴䧏׌׾׻ֹמ⥸ׂ ˝ /PEF꤃㲹侇מ׵1PE؅塜䅻ם/PEFמتآ ةٖ٭ٜ׊泡׌ 

Slide 30

Slide 30 text

䦡䍖䓪 ˝ 姡䇖؛٭عتآ٭ٜ ˝ )PSJ[POUBM1PE"VUPTDBMFS )1" ˝ $16璡סْعٛؠت؅⹆拨׊י1PEסٝوٛ؜؅舅Ⳃך鴑ⱶ׌׾ ˝ 㑈泡؛٭عتآ٭ٜ ˝ 7FSUJDBM1PE"VUPTDBMFS 71" ˝ $16 ْٓٛס✳榫ꄈ؅⮆冪׊יٛؠؙتع⡁؅䬠勅׊ג׽舅Ⳃ氳מ催 二׊ג׽׌׾ 

Slide 31

Slide 31 text

ـ٤ث؛٤ך⮵榫׌׾ص٭ٜ磆☭ 

Slide 32

Slide 32 text

.JOJLVCF ˝ ٞ٭؜ٜ梪㗞ךLVCFSOFUFTסؠٚتذ٭؅玮ה┕ׅ׾סמ؛ت تْ IUUQTNJOJLVCFTJHTLTJPEPDTTUBSU ˝ LVCFSOFUFTסف٭ة٘٤؅䧗㲊׊יؠٚتذ٭؅啶疣ך׀׾ ˝ ☽מ׵LJOEכַזגص٭ٜ׷%PDLFSGPS.BDמ♀㷯׊יַ׾ LVCFSOFUFT׵ٞ٭؜ٜךؠٚتذ٭啶疣ֿ⺎耆 

Slide 33

Slide 33 text

,VTUPNJ[F ˝ IUUQTHJUIVCDPNLVCFSOFUFTTJHTLVTUPNJ[F ˝ LTסُؼنؘتعס啶䡗؅؜تذُؕث׌׾ג״סص٭ٜ ˝ %FW 4UH 1SE璡ס邾丗ס梪㗞⮆.BOJGFTU؅傴ׂסע⫛Ꝏםס ךյ⪦鵟סي٭تכם׾ُؼنؘتع؅⛼׽חחյ梪㗞夵ס䄐 ⮆؅قشزنٜؒؕכ׊י畘杼ך׀׾׻ֹמם׾ ˝ kustomization.yamlמלסُؼنؘتع؅✳ֹ־յTFDSFU ׷DPOHס錃㲊םל؅鋗鳭׌׾ 

Slide 34

Slide 34 text

4LBPME ˝ IUUQTTLBPMEEFW ˝ نٜؒؕס㚺催؅吾湳׊יؤ٤طػْؕ٭ةסلٜغյ LT梪㗞׫⹚何׌׾ص٭ٜ ˝ skaffold.yamlמ㵚霄כם׾نٜؒؕյEPDLFSْؕ٭ةյ ُؼنؘتع؅鋗鳭׌׾ 

Slide 35

Slide 35 text

,VCFSOFUFTـ٤ث؛٤ 

Slide 36

Slide 36 text

ؓةؘ٤ر ˝ 瑬┉鼧)BUFOB*OUFSO梪㗞ך鷛ׯֹ ˝ 瑬◅鼧鋗嫎㚺䬵ئ٭لتס鴑ⱶ ˝ 瑬└鼧-FUTUSZ؛٭عتآ٭ٜ؅錃㲊׊׻ֹ 

Slide 37

Slide 37 text

瑬┉鼧 )BUFOB*OUFSO梪㗞ך鷛ׯֹ 

Slide 38

Slide 38 text

׆ס侇ꝴעـ٤ث؛٤ך׌ ˝ ┉稇מ䣆؅Ⳃ־׊י䣆⩕ס,VCFOFUFT梪㗞؅鉴זיײױ׊׺ֹ ˝ ؅ ⩕מ׊גَٛةعٛ┕ך⛼哅׊ױ׌ ⹆縒鐐갭َٛةعٛ ˝ 鋗鬼׈׿יַ׾ؤُ٤غעյَٛةعٜٛ٭عך㲔车׊יׂד׈ַ ˝ ױ׍עHJUסCSBODI؅⮉׽ױ׊׺ֹ % git switch -c k8s-handson 

Slide 39

Slide 39 text

ئ٭لتס啶䡗 

Slide 40

Slide 40 text

ُؼنؘتعס啶䡗 k8s ├── account │ ├── app.yaml │ ├── config │ │ └── schema.sql │ ├── db.yaml │ ├── kustomization.yaml │ ├── secret │ │ └── ecdsa-private.pem │ └── test.yaml ├── blog │ ├── app.yaml │ ├── config │ │ └── schema.sql │ ├── db.yaml │ ├── kustomization.yaml │ ├── secret │ │ └── account-ecdsa-public.pem │ └── test.yaml ├── kustomization.yaml ├── namespace.yaml ├── renderer-go │ ├── app.yaml │ └── kustomization.yaml └── system └── sa.yaml ˝ k8sظؔٝؠعֿُٛؼنؘتع糋׀㕙 ˝ BDDPVOUCMPHSFOEFSFSHPכُؕؠٞئ٭لتׇכ מظؔٝؠعٛ؅⮆ׄ׾ ˝ kustomization.yamlֿLVTUPNJ[Fס錃㲊نٜؒؕ 

Slide 41

Slide 41 text

apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - app.yaml - db.yaml - test.yaml secretGenerator: - name: blog-app-secret files: - secret/account-ecdsa-public.pem configMapGenerator: - name: blog-app-env-vars literals: # (snip) - name: blog-db-schema-config files: - config/schema.sql 

Slide 42

Slide 42 text

颯Ⳃ # Minikube Λىಈ % minikube start !"kubernetes-version v1.19.8 !"driver docker % eval $(minikube docker-env) # context Λઃఆ % kubectl config set-context hatena-intern-2021 !"cluster=minikube !"user=minikube !"namespace=hatena-intern-2021 % kubectl config use-context hatena-intern-2021 # skaffold Λىಈ % make up skaffold dev !"cleanup=false 

Slide 43

Slide 43 text

澬鏀 % minikube -n hatena-intern-2021 service blog ˝ services/blog/templates/index.html؅傴׀䬵ֻיյ 㚺催ֿ⹚何׈׿׾׆כ؅澬鏀׊ױ׊׺ֹ 梪㗞ס⯡ꢜ % skaffold delete 

Slide 44

Slide 44 text

LVCFDUM؅✳ֹ嶖⤓ CBTI[TIךסؤُ٤غ遨㱭ס錃㲊 # bash source <(kubectl completion bash) # zsh source <(kubectl completion zsh) ֽ׌׌״ ؙؕٛؓتס錃㲊؅׊יֽׂ alias k=kubectl 

Slide 45

Slide 45 text

ئ٭لتֿ颯Ⳃ׊יַ׾׆כ؅澬鏀׌׾ DPOUFYUס⮉׽僀ֻ % kubectl config use-context hatena-intern-2021 

Slide 46

Slide 46 text

1PEֿ颯Ⳃ׌׾喋㯸؅釤׻ֹ ┉䈱梪㗞؅⯡ꢜ׊יյ颯Ⳃ׊泡׊ױ׊׺ֹ % skaffold delete % make up ⮯ס珷儕ך㲔车׊י1PEס敯䛜؅釤׾ % kubectl get pods -w % kubectl describe pods 1PEֿ颯Ⳃ׊ג׆כ؅澬鏀׊י % minikube -n hatena-intern-2021 service blog ؅㲔车յهٞء؅⛼䡗׊יײױ׊׺ֹ 

Slide 47

Slide 47 text

ظفشء # Podͷৄࡉ৘ใͷදࣔ % kubectl describe pod blog # ωʔϜεϖʔε্ʹ͋ΔϦιʔεͷ৘ใΛදࣔ % kubectl get all # ىಈ͍ͯ͠ΔPodͰγΣϧΛىಈ͢Δ % kubectl exec -it svc/account !" /bin/sh ˝ 颯Ⳃ׊יַ׾وٞجتע ! ps ˝ CMPHئ٭لتמؓؠجت ! wget -q -O - blog:8080 ˝ ! nslookup blog 

Slide 48

Slide 48 text

ظ٭ذي٭تסظفشء 䣆⩕מNZTRMDMJFOUֿםַ㕙⺬עت؞شو׊יׂד׈ַ # ϙʔτͷసૹ % kubectl port-forward svc/blog-db 13306:3306 # ϗετ͔ΒMySQLʹ઀ଓͰ͖ΔΑ͏ʹͳΔ % mysql -u root -h 127.0.0.1 -P 13306 

Slide 49

Slide 49 text

NFUSJDTTFSWFSס㵵⪌ ˝ IUUQTHJUIVCDPNLVCFSOFUFTTJHTNFUSJDTTFSWFS % minikube addons enable metrics-server 

Slide 50

Slide 50 text

OPEFյQPEסْعٛؠت؅⹦䐂 ⹦䐂ך׀׾ױךמ侇ꝴֿ־־׾סך㵼׊䏨זי־׼㲔车׌׾ % kubectl top nodes NAME CPU(cores) CPU% MEMORY(bytes) MEMORY% docker-desktop 469m 5% 1873Mi 32% % kubectl top pods NAME CPU(cores) MEMORY(bytes) account-86649c57b4-jq26g 2m 3Mi account-db-55579cb588-mmfv6 15m 345Mi account-test-59c689cdd4-q89rh 0m 1Mi blog-db-6f7f4c8797-rxtnz 15m 406Mi blog-test-86cff5d98c-ttp2z 0m 0Mi renderer-go-7d8d7fdf64-qhn95 5m 13Mi 

Slide 51

Slide 51 text

,VCFSOFUFT%BTICPBSEס㵵⪌ ˝ IUUQTHJUIVCDPNLVCFSOFUFTEBTICPBSE % minikube dashboard 

Slide 52

Slide 52 text

瑬◅鼧 鋗嫎㚺䬵ئ٭لتס鴑ⱶ 

Slide 53

Slide 53 text

鋗嫎㚺䬵ئ٭لتSFOEFSFS ˝ services/renderer-tsמֵ׾㲔逷؅LT┕ךⳂ־׌ ˝ ظنؚٜعךעservices/renderer-goֿⳂַיַ׾ ˝ k8s/renderer-go؅⹆縒מյk8s/renderer-ts؅鴑ⱶ 

Slide 54

Slide 54 text

ُؼنؘتع ˝ 鴑ⱶ׌׾ُؼنؘتع ˝ k8s/renderer-ts/kustomization.yaml ˝ k8s/renderer-ts/app.yaml ˝ 稴꥗׌׾ُؼنؘتع ˝ skaffold.yaml ˝ k8s/kustomization.yaml ˝ k8s/blog/kustomization.yaml 

Slide 55

Slide 55 text

ُؼنؘتعס鴑ⱶ % cp -R k8s/renderer-go k8s/renderer-ts % perl -i -pe 's/renderer-go/renderer-ts/g' k8s/renderer-ts/*.yaml ˝ k8s/renderer-goظؔٝؠعٛ؅ؤم٭׊יk8s/ renderer-ts؅⛼䡗 ˝ ُؼنؘتع⫂סrenderer-go؅renderer-tsמ糋׀䬵ֻ 

Slide 56

Slide 56 text

ُؼنؘتعס稴꥗ TLBPMEZBNM apiVersion: skaffold/v2beta5 kind: Config metadata: name: hatena-intern-2021 build: artifacts: # (snip) - image: hatena-intern-2021-renderer-go context: services/renderer-go - image: hatena-intern-2021-renderer-ts # ! context: services/renderer-ts # ! local: # (snip) ˝ services/renderer-tsסEPDLFSْؕ٭ةסلٜغכLTؠٚتذ׫ס⹚何ֿ׈׿׾׻ֹמ׌׾ 

Slide 57

Slide 57 text

ُؼنؘتعס稴꥗ LTLVTUPNJ[BUJPOZBNM apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization namespace: hatena-intern-2021 resources: - namespace.yaml - account - blog - renderer-go - renderer-ts # ! 

Slide 58

Slide 58 text

ُؼنؘتعס稴꥗ LTCMPHLVTUPNJ[BUJPOZBNM apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization # (snip) configMapGenerator: - name: blog-app-env-vars literals: - MODE=development - DATABASE_DSN=root@(blog-db:3306)/intern_2021_blog?time_zone=UTC&parseTime=true&loc=UTC - ACCOUNT_ADDR=account:50051 - RENDERER_ADDR=renderer-ts:50051 # ! - name: blog-test-env-vars # (snip) ˝ CMPHئ٭لتס鋗嫎㚺䬵ئ٭لت׫ס⺸׀⩝؅SFOEFSFSHP־׼SFOEFSFSUTמ㚺 ֻ׾ 

Slide 59

Slide 59 text

1PEֿ塜䅻מ颯Ⳃ׊םַ㕙⺬ ˝ kubectl get pods؅㲔车׊י⺨1PEֿ塜׊ׂ颯Ⳃ׊יַ׾ ־לֹ־澬鏀׌׾ ˝ kubectl describe pod renderer-tsך鎋碷䗯㕔؅澬鏀 ˝ ם׏塜䅻מ颯Ⳃ׊םַ־⸉㍔؅䫒؀ֹ 

Slide 60

Slide 60 text

⸉㍔ ˝ SFOEFSFSUTס1PEס敯䛜ֿOOMKilledך䍚⯆磙▼׈׿יַ׾ ˝ SFOEFSFSHPך錃㲊׊יַ׾ْٓٛס⯆꡾עSFOEFSFSUTךע餉׽ם־זגג״յ1PE颯 Ⳃ侇מْٓٛ┘餉ך䍚⯆磙▼׈׿יַג ˝ k8s/renderer-ts/app.yaml؅稴꥗׊յ$16ْٓٛ⯆꡾؅㚺催׌׾ resources: requests: cpu: 100m memory: 20Mi limits: cpu: 200m memory: 40Mi 

Slide 61

Slide 61 text

㲔꤀מSFOEFSFSUTֿⳂׂ׆כ؅澬鏀׌׾ ˝ kubectl get pods׻׽׌׬יס1PEֿ塜䅻מ颯Ⳃ׊יַ׾׆ כ؅澬鏀 ˝ minikube -n hatena-intern-2021 service blog ؅㲔车׊יهٚؗا־׼ئؕ٤ؓشو؅车ֹ ˝ 鋗◄؅⛼䡗׊renderer-tsئ٭لتֿⳂׂ׆כ؅澬鏀 

Slide 62

Slide 62 text

瑬└鼧 -FUTUSZ؛٭عتآ٭ٜ؅ 錃㲊׊׻ֹ 

Slide 63

Slide 63 text

CMPHئ٭لت؅؛٭عتآ٭ٜ׈׎׾ ˝ 㛻ꄈמ׷זיׂ׾ٛؠؙتعמ㵚׊יٝتَ٤تס䑴璻侇ꝴס ף׼ח׀ֿםַ׻ֹמ׌׾ ˝ ⯆硜 ˝ SFTPVSDFTMJNJUTע㚺催׊םַ׆כ ˝ 僃⮣מ錃㲊׌׾1PEסٝوٛ؜丗עסױױמ׌׾׆כ ˝ ؓوٛآ٭ب٘٤ס錃㲊ע㚺催׊םַ׆כ 

Slide 64

Slide 64 text

BC "QBDIF#FODI מ׻׾靷蕔طتع % kubectl exec deploy/blog-test !" ab -n 1000 -c 10 http:!#blog:8080/ ˝ -n鴜⟓׌׾ٛؠؙتعס丗 ˝ -c⺱侇מٛؠؙتع׌׾丗 ˝ CMPHئ٭لتסطتع㲔车榫סؤ٤طػ־׼BC؅㲔车ך׀׾׻ ֹמ׊יֵ׾ 

Slide 65

Slide 65 text

⹆縒؛٭عتآ٭ٜס錃㲊؅׊יַיַםַ1PEסٝوٛ؜丗ֿס敯䛜 % ab -n 1000 -c 10 http:!"localhost:8080/ (snip) Server Software: Server Hostname: localhost Server Port: 8080 Document Path: / Document Length: 831 bytes Concurrency Level: 10 Time taken for tests: 97.873 seconds Complete requests: 1000 Failed requests: 42 (Connect: 0, Receive: 0, Length: 42, Exceptions: 0) Total transferred: 1099784 bytes HTML transferred: 796098 bytes Requests per second: 10.22 [#/sec] (mean) Time per request: 978.730 [ms] (mean) Time per request: 97.873 [ms] (mean, across all concurrent requests) Transfer rate: 10.97 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.1 0 1 Processing: 1 975 605.9 897 3696 Waiting: 0 910 579.2 798 3696 Total: 1 975 605.9 898 3696 Percentage of the requests served within a certain time (ms) 50% 898 66% 1099 75% 1299 80% 1399 90% 1798 95% 2098 98% 2498 99% 2798 100% 3696 (longest request) ˝ 靷蕔طتعמ־־זג侇ꝴע T ˝ ٛؠؙتعֵג׽ס䇖㏯侇ꝴע NT 

Slide 66

Slide 66 text

)PSJ[POUBM1PE"VUPTDBMFS )1" ˝ $16✳榫曍מ׻זי1PEס丗؅㘃峎׈׎י姡䇖מ؛٭عتآ٭ ٜ׌׾☼磝ײ ˝ ؛٭عتآ٭ٜסꝴꣴעظنؚٜعךע熮ׇכםסך嫰䙫׌ ׾ ˝ ⛰䈱־BCؤُ٤غ؅㲔车׌׾䑒釐ֵֿ׾־׵׊׿םַ 

Slide 67

Slide 67 text

؛٭عتآ٭ٜס錃㲊 % kubectl autoscale deployment blog !"cpu-percent=50 !"min=1 !"max=10 ˝ !"cpu-percent泘嘅כם׾1PE⪒⛮ס䇖㏯$16✳榫曍 ˝ !"min؛٭عتآ٭ٜ׌׾꤀ס1PE丗ס┖꡾ ˝ !"max؛٭عتآ٭ٜ׌׾꤀ס1PE丗ס┕꡾ 

Slide 68

Slide 68 text

澬鏀׌׾׆כ ˝ BCס磵冽־׼⛰ֿ؂־׾־ ˝ ٛؠؙتعֵג׽ס䇖㏯侇ꝴע ˝ ,VCFSOFUFT%BTICPBSE־׼⮆־׾׆כע ˝ CMPH1PEעַׂחױך㘃ֻג־ ˝ kubectl get hpa blogך؛٭عتآ٭ٜס敯䛜؅澬鏀׊׻ֹ ˝ ┉㲊僿ꝴؓؠجت׎׍מ䷑糋׊יتآ٭ٜرؗ٤ס喋㯸׵釤יײ׾ 

Slide 69

Slide 69 text

撴טׄ % kubectl delete hpa blog 

Slide 70

Slide 70 text

ױכ״ ˝ LVCFSOFUFTס哭鈝כ㓹儖氳ם嚀耆؅磆☭׊ג ˝ ؤ٤طػ؛٭آتعٝ٭ب٘٤׌׾ג״ס☼磝ײ؅⤓ֻגوٚشعنؚ٭ّ ˝ 㲚銧氳מؕ٤نٚ؅畘杼ך׀յ냕⺎榫ך䦡䍖䓪סֵ׾㓹泅؅啶疣ך׀׾ ˝ قهٛشؠؠٚؗغך׵䬠❠׈׿יַ׾ؤ٤طػ؛٭آتعٝ٭ب٘٤סظنؒؠعتذ٤ ر٭غ ˝ ـ٤ث؛٤؅鵟׊יLVCFSOFUFT؅⛮꽦׊ג ˝ LVCFSOFUFT梪㗞؅啶疣׊יئ٭لت؅Ⳃ־׌׆כע哧׊ַ ˝ .BOJGFTU־׼䣆鬭מتآ٭ٜ⺎耆ך䦡䍖䓪ס냕ַئ٭لت؅⛼׾׆כֿך׀׾ ˝ 䣆鬭׈ס遊מע邾ꥭםؕ٤نٚ׷ؾشع٠٭ؠֿ㰆㏇׊יַ׾ 

Slide 71

Slide 71 text

