ããã«ã¡ã¯ï¼ã¹ã¿ãã£ãµããªå°ä¸é«SREã®@_a0iã§ãã ãã®è¨äºã¯ã¹ã¿ãã£ãµããªProduct Team Advent Calendar 2024ä¸æ¥ç®ã®è¨äºã§ãï¼
ç§ãã¡ã¯ããæ°å¹´Kubernetesã®Node管çã楽ã«ã»å¹ççã«è¡ããã¨Karpenterã®å°å ¥ã«å±ãã§ãã¾ããã
Karpenterå°å ¥æã®ãã©ãã«ã«é¢ããããã°ãæ¸ãã¦ãã1å¹´ã
ç§ãã¡ã¯ãAmazon EKS on AWS Fargateï¼ä»¥éEKS on Fargateï¼ãã®å°å ¥ã試ã¿ããã¨ã§ããã«Node管çã楽ã«ãããã¨ããããã¾ããã ããããæ¬çªç°å¢ã§å®å®ç¨¼åãã¦ãã¾ããããããã¾ã§ã«è²ã ã¨è©¦è¡é¯èª¤ããã®ã§ãã®ç¥è¦ãå ±æãããã¨æãã¾ãã
ãªãEKS on Fargateï¼
Karpenterã¯èªåã§Nodeã管çãã¦ãããé常ã«ä¾¿å©ãªãã¼ã«ã§ããç§ãã¡ã¯Node管çã®å¤§é¨åãKarpenterã«ä»»ãã¦ãã¾ãã
ããããä¸é¨ã®Nodeã¯Karpenter管çã§ã¯ãªãAWSã®Managed Node Groupã¨ããä»çµã¿ã使ã£ã¦ãã¾ãã
ãªããªããæ°è¦ã¯ã©ã¹ã¿ãä½æããéãKarpenterãèµ·åããããã®Nodeããå¿ è¦ã«ãªãããã§ãã
Managed Node Groupèªä½é常ã«ä¾¿å©ã§ãKarpenterãå°å ¥ããåã¯å ¨ã¦Managed Node Groupã«ä»»ãã¦ãã¾ããã
ãããä»ãç¶æ³ãå¤ãããKarpenterã®èµ·åã®ããã ãã«Managed Node Groupãã¡ã³ããã³ã¹ãç¶ãããã¨ãå¾ã ã«æéã«ãªã£ã¦ãã¾ããã
ããã§AWSããæ°ãã«æ©è½è¿½å ã¨ãªã£ããEKS on Fargateããç§ãã¡ã®ç¨éã«åãã®ã§ã¯ã¨ãããã¨ã§KarpenterãEKS on Fargateã«è¼ãæ¿ãããã¨ã«ãªãã¾ããã
ã¾ããããå®å®çãªNodeã¨ãã¦Managed Node Groupã«è¼ãã¦ããCoreDNSããããã¦EKS on Fargateã«è¼ãæ¿ããè¨ç»ã§ããã
EKS on Fargateã¨ã¯ï¼
試è¡é¯èª¤ããããããã¤ã³ãã説æããåã«ãã¾ãã¯EKS on Fargateã«ã¤ãã¦ç°¡åã«ç´¹ä»ãã¾ãã
AWSå ¬å¼ãã¼ã¸ã«ã¯AWS Fargateã«ã¤ãã¦ä»¥ä¸ã®ããã«æ¸ããã¦ãã¾ãã
AWS Fargate ã¯ããµã¼ãã¼ã¬ã¹ã§å¾éå¶æéã®ã³ã³ãã¥ã¼ãã£ã³ã°ã¨ã³ã¸ã³ã§ããããµã¼ãã¼ã管çãããã¨ãªãã¢ããªã±ã¼ã·ã§ã³ã®æ§ç¯ã«éä¸ãããã¨ãã§ãã¾ãããµã¼ãã¼ç®¡çããªã½ã¼ã¹å²ãå½ã¦ãã¹ã±ã¼ãªã³ã°ãªã©ã®ã¿ã¹ã¯ã AWS ã«ç§»è¡ããã¨ãéç¨æ å¢ãæ¹åãããã ãã§ãªããã¢ã¤ãã¢ããã¯ã©ã¦ãã§ã®æ¬çªç°å¢ã¾ã§ã®ç§»è¡ããã»ã¹ãå éãããç·ä¿æã³ã¹ããåæ¸ããã¾ãã AWS Fargateã¯ãã¨ãã¨ECSã§å©ç¨å¯è½ã ã£ããã®ãã2019å¹´ã«EKSã§ãå©ç¨å¯è½ã«ãªãã¾ããã
EKS on Fargateã¨ã¯ç°¡åã«ããã¨Kubernetesã®Worker Nodeããµã¼ãã¼ã¬ã¹ã«ãããã¨ãã§ããã¨ãããã®ã§ãã
Fargateã«ã¯ããã¤ãã®èæ ®äºé ãããããã©ããªç¶æ³ã§ãããããã¨ããããã§ã¯ãªãã§ãããç§ãã¡ã®è¦ä»¶ã«åè´ããããEKS on Fargateã¸ã®ç§»è¡ãé²ãããã¨ã«ãã¾ããã
ããã¤ãã®è½ã¨ãç©´
ã§ã¯ããã¤ãããã£ããã¤ã³ãã説æãã¾ãã
CloudWatchã§ãã°ãè¦ããããã«ãªãã«ã¯Fluent Bitã®è¨å®ãå¿ è¦
ããã¥ã¡ã³ãã«ãã¡ãã¨æ¸ããã¦ããã®ã§ãããã¯ãããã¥ã¡ã³ãã«æ¸ããã¦ãããã¨ãã§ãã¦ããªãã£ããã¨ããããããã¤ã³ãã«ãªãã¾ãã
å ·ä½çã«ã¯ä»¥ä¸ã§ãããã¾ãã
- aws-observability Namespaceãä½æãã¦ãã®Namespaceã«ConfigMapãç½®ãå¿ è¦ããã
- ConfigMapã®ååã¯aws-loggingã§ããå¿ è¦ããã
éã«ããã¨ãaws-observability Namespaceã«aws-loggingã¨ããååã®ConfigMapãä½ããããã«Fluent Bitã®è¨å®ãæ¸ãã°CloudWatchã§ãã°ãè¦ããããã«ãªããã¨ä¾¿å©ã§ã¯ããã¾ããFluent Bitã®Agentã®ã¤ã³ã¹ãã¼ã«ãªã©ã¯å¿ è¦ããã¾ããã
ãªã½ã¼ã¹ã®ä½¿ããæ¹ãå¤ãã
ãããããã¥ã¡ã³ãã«æ¸ããã¦ãã¾ã
Amazon EKS Fargate ã¯ãã¼ããã¨ã« 1 ã¤ã® Pod ããå®è¡ããªãããããªã½ã¼ã¹ãå°ãªãå ´åã« Pods ãåé¤ããã·ããªãªã¯çºçãã¾ããããã¹ã¦ã® Amazon EKS Fargate Pods ã¯ä¿è¨¼ãããåªå 度ã§å®è¡ãããããããªã¯ã¨ã¹ãããã CPU ã¨ã¡ã¢ãªã¯ããã¹ã¦ã®ã³ã³ããã®å¶éã«çãããªããã°ãªãã¾ããã詳細ã«ã¤ãã¦ã¯ãKubernetes ããã¥ã¡ã³ãã®ãPods ã«ãµã¼ãã¹ã®å質ãè¨å®ããããåç §ãã¦ãã ããã Fargate Pod 設定の詳細を理解する - Amazon EKS
Kubernetesã§ã¯CPUãã¡ã¢ãªã®requests/limitsãããããå¥ã®å¤ã«æå®ããããããããlimitãæå®ããªããã¨ãã§ãã¾ãã
ç§ãã¡ã®ç°å¢ã§ã¯ããã¾ã§CPU limitsãæå®ãã¦ãã¾ããã§ããããçµæã¨ãã¦Fargateã§ã¯äºæãã¦ããªãå¤ã«ãªã£ã¦ãã¾ã£ã¦ãã¾ããã
ã¡ãªã¿ã«Fargateã§ã¯ä»¥ä¸ã®ããã«Annotationãåç §ãããã¨ã§ã©ã®ãããªãªã½ã¼ã¹ãå²ãå½ã¦ãããã決ã¾ãã¾ãã
apiVersion: v1 kind: Pod metadata: annotations: CapacityProvisioned: 4vCPU 8GB
Fargate Profileã®å¤æ´ã§åããªããªã
ãããããã¥ã¡ã³ãã«è¨è¼ããã¦ã¯ããã®ã§ãããã¨ã©ã¼ã¡ãã»ã¼ã¸ãªã©ãããããããåå ã ã¨ç¹å®ã§ããããã§ã¯ãªãã®ã§ãããã¾ããã
Fargate ãããã¡ã¤ã«ã¯å¤æ´ã§ãã¾ããããã ããæ°ããæ´æ°ããããããã¡ã¤ã«ãä½æãã¦æ¢åã®ãããã¡ã¤ã«ãç½®ãæãããã®å¾å ã®ãããã¡ã¤ã«ãåé¤ãããã¨ã¯ã§ãã¾ãã docs.aws.amazon.com
ç§ãã¡ã¯Fargate Profileã«ç´ã¥ãIAM Roleã®ååå¤æ´ãè¡ã£ãã¨ãããFargate Profileãåããªããªã£ã¦ãã¾ããããã¾ããã
Fargate Profileã«é¢é£ããå¤æ´ã¯é¢é£ãããªã½ã¼ã¹ãæ°è¦ä½æãã¦åãæ¿ããã®ãããããã§ãã
CoreDNSã§ã¯ä½¿ããªãã£ã
CoreDNSãFargateã«è¼ãããã¨ãã¦ããã®ã§ãããæçµçã«Fargateã«è¼ããªã決å®ãè¡ãã¾ããã
CoreDNSã¯ãããã¯ã¼ã¯ãæ ãéè¦ãªã³ã³ãã¼ãã³ãã§ãããããã¨ãç§ãã¡ã®ç°å¢ã§ãã»ãã¥ãªãã£ã°ã«ã¼ãã®æ¥ç¶ã®è¿½è·¡ã®ä¸éãã«éãã¦ãã¾ãã¾ããã
ã»ãã¥ãªãã£ã°ã«ã¼ãã®æ¥ç¶ã®è¿½è·¡ã®ä¸éã«ã¤ãã¦ã¯è©³ããã¯ä»¥ä¸ã®å ¬å¼ããã¥ã¡ã³ããåç §ãã¦ãã ãããããã¯EC2ã¤ã³ã¹ã¿ã³ã¹å«ãã¦çºçããå¶ç´ã§ãæ¥ç¶ã®è¿½è·¡ã®ä¸éã«éããã¨ããã±ãããããããçºçãã¦ãã¾ãã¾ãã
ä¸éã¯ã¤ã³ã¹ã¿ã³ã¹æ°ã«ãã£ã¦å¤ãç°ãªããä¾ãã°CoreDNSã®Podãè¤æ°ã®ã¤ã³ã¹ã¿ã³ã¹ã«åæ£ããããã¨ã§1ã¤ã³ã¹ã¿ã³ã¹ãããã®æ¥ç¶æ°ãæ¸ããã¨ãã対çãåããã¨ãã§ãã¾ãã
æ¥ç¶ã®è¿½è·¡ã®ä¸éã«éãããã©ããããããã¯ä¸éã«éããã¾ã§ã«ã©ããããä½è£ããããã¯conntrack_allowance_availableãconntrack_allowance_exceededã¨ãã£ãã¡ããªã¯ã¹ã§ã¢ãã¿ãªã³ã°å¯è½ãªã®ã§ãããFargateã§ã¯ãã®ã¡ããªã¯ã¹ãåå¾ã§ããªãã¨ã®ãã¨ã§ããã
ãã±ãããã¹ã¯ãµã¼ãã¹ã«å¤§ããªå½±é¿ãä¸ããä¸ã«ã¡ããªã¯ã¹ãåå¾ã§ããªãã®ã§ã¯ç§ãã¡å´ã§åå ãç¹å®ãããã¨ãå°é£ã§ãã
ãã®ä»¶ã¯AWSã®ãµãã¼ãã®æ¹ã«èª¿æ»ãä¾é ¼ãã¦ããããåå ãå¤æããããããããã¾ãããããã¦ä»å¾ã®éç¨ã«æ¯éãåºãã¨å¤æããCoreDNSã¯Fargate ã«ã®ããã®ãããã¾ããã
DaemonSetã使ããªãã®ã§ãDatadog Agentã®å©ç¨æ¹æ³ãå¤ããå¿ è¦ããã
ããã¯Datadogãå©ç¨ãã¦ããæ¹ã«ã ããã¦ã¯ã¾ã話ã§ããããç´¹ä»ãã¾ãã
ç§ãã¡ã¯Datadog AgentãDaemonSetã¨ãã¦Nodeã«ã¤ã³ã¹ãã¼ã«ãã¦ããã®ã§ãããEKS Fargateã§ã¯DaemonSetã使ããªãããè¨å®ãå¤æ´ããå¿ è¦ãããã¾ããã
å ¬å¼ããã¥ã¡ã³ãã«æ¹æ³ãæ¸ãã¦ããã®ã§ãåºæ¬çã«ããã¥ã¡ã³ãã«æ¸ããã¦ããéãã«ããã°åé¡ããã¾ããã
ã¨è¨ã£ã¦ã権éå¨ãã§ãããã¾ãã...ã
åé¡ã«ã¯ãªã£ã¦ããªãããã©å°ãæ°ã«ãªã£ã¦ãããã¨
ä»ã®ç§ãã¡ã®ä½¿ãæ¹ã§ããã°åé¡ã«ãªã£ã¦ãã¾ããããä»å¾ä»ã®ç¨éã§ä½¿ãå ´åã«ã¯åé¡ã«ãªãããã¨æã£ããã¨ãããã¤ãããã¦ããã¾ãã
- èµ·åãå°ãé
ã
- EKS Fargateã§ã¯1Podã«å¯¾ãã¦ä»®æ³çã«1ã¤ã®Nodeãå²ãå½ã¦ãé½åä¸ãã³ã³ãããããå²ã¨èµ·åãé ãã§ã
- EBSã使ããªã
- ã³ã¹ã
- å価ãEC2ãããé«ãã®ã§ã常æèµ·åããã³ã³ããã¯è²»ç¨ãããªãå¢ããå¯è½æ§ãããã¾ã
- 1Podã«ä»®æ³çã«1Nodeãå²ãå½ã¦ãé½åä¸ãèªç±ã«CPUãã¡ã¢ãªã決ããããããã§ã¯ãªãçµã¿åããã決ã¾ã£ã¦ãã¾ããããã¦æ±ºã¾ã£ãã¹ããã¯ã«å¿ãã¦å©ç¨æã決ã¾ããããã¹ããã¯ãããå°ãªã使ãå ´åã¯ã³ã¹ããå¤ãã«ãããå¯è½æ§ãããã¾ã
ãããã«
以ä¸ãããã¤ãã®ããããã¤ã³ãã§ããï¼
è¿ã EKS Upgradeãè¡ãäºå®ãªã®ã§ãæãååEKS Fargateã®ä¾¿å©ãã享åãããã¨æãã¾ã
(ãã¾ããããªãã£ããã¾ãããã°æ¸ãã¾ã...)