- ã¯ããã«
- ãªãããã¡Kubernetesï¼
- ãã¼ãã¦ã§ã¢ã®é¸å®
- ã¯ã©ã¹ã¿ã®ãã¼ãã¹ãã©ãã
- cybozu-go/neco-apps
- éçºç°å¢
- ä»åãã¦ãããã®
- ãããããããããã¨
- ã¾ã¨ã
ã¯ããã«
ãããã¯Cybozu Advent Calendar 2021 7æ¥ç®ã®è¨äºã§ããæ¯éä»ã®è¨äºãèªãã§ã¿ã¦ãã ããã
ãKubernetesã®åãèãããã«ãªã£ã¦ä¹ ãããçæ§ãæ¥åã»ãã©ã¤ãã¼ãåããæ¥ã YAMLãæ¸ããã¦ãããã¨ã§ããããèªåå°ç¨ã®ãã©ã¤ãã¼ãã¯ã©ã¹ã¿ã欲ããã¨æããã¦ããæ¹ããã£ã¨ããããå± ãããã¯ãï¼ä»æ¥ã¯èªåããã©ã¤ãã¼ãã§éãã§ããKubernetesã¯ã©ã¹ã¿ãç´¹ä»ãããã¨æãã¾ãã
ã注æ ããã®è¨äºã§ã¯ç§è²»ã§æ©æãè³¼å ¥ããããã©ã¤ãã¼ãã§Kubernetesã«ã¤ãã¦å¦ãã ããã¦ãã¾ãããå®å ¨ã«çè ã®è¶£å³ã§ãããã¾ãã¾å®çãå ¼ãã¦ããã ãã§ããä¼ç¤¾ã¨ãã¦ãããã®è¡çºãæ示åã³æ¨å¥¨ãããã®ã§ã¯ããã¾ããã
ãªãããã¡Kubernetesï¼
ãDocker Desktopã®Kubernetesãminikubeãkindãªã©ã§æ軽ã«ã¯ã©ã¹ã¿ã建ã¦ããã¨ãã§ããç°¡åãªéçºç°å¢ã§ããã°é常ã«å®¹æã«ä½æãããã¨ãã§ããã®ãKubernetesã®é
åã§ãã
ããããããããã§ä½æããã¯ã©ã¹ã¿ã¯ã¯ã©ã¦ããããã¤ãã®æä¾ããããã¼ã¸ããµã¼ãã¹ã¨æ¯è¼ãã¦ããã¤ã足ããªãæ©è½ãããã¾ãã
type: LoadBalancer
ãªãµã¼ãã¹ã使ããªã/使ãã®ã大å¤PersistentVolumeClaim
ã¯local-path-provisionerããhostPathã§PVãç¨æããããããããªã- ããããä¸å°ã®ãã·ã³ã®ä¸ã§åãã¦ããã®ã§ãè¤æ°ã®ãã·ã³ããã¢ã¯ã»ã¹ããã®ã«åãã¦ããªããåããç¶ããã®ã«åãã¦ããªã
ããªã©ãªã©ãã¡ããã¨ç¬ç«ããã¯ã©ã¹ã¿ã§èªç±ã«ãããããªãã¾ããã§ã¯ãªãã¯ã©ã¦ããããã¤ãã®ããã¼ã¸ãKubernetesã§ã¯ãªãããããããªã³ãã¬ãã¹ãªã®ãï¼
â¦â¦ã
家ã«Kubernetesã¯ã©ã¹ã¿ãããã¨ãªãããã£ããã
ã§ã¯ãã£ã¦ããã¾ãããï¼*1
ãã¼ãã¦ã§ã¢ã®é¸å®
ãæ å ±åéãã¦ããã¨ãRaspberry Piã使ã£ã¦ã¯ã©ã¹ã¿ãçµãã§ããããæ¹ãå¤ãããã§ãã
ãRasPiã®å°ããªã¯ã©ã¹ã¿ãé常ã«ããããããé åçãªã®ã§ãããä¸ã¯å¤§åå°ä½ä¸è¶³æ代ãRaspberry Piã®å¤æ®µãé«æ¢ã¾ããã¦ãã¾ããå¨åº«ãå ¨ç¶ããã¾ããã
PoE Hatãè²·ã£ããPoEã¹ã¤ãããè²·ã£ããmicroSDã¯ä¸å®ã ããSSDã§â¦â¦ã¨ããã£ã¦ããã¨ã³ã¹ãçã«ãä¸å¤ã§x86ã®PCãè³¼å ¥ããã®ã¨å¤§å·®ç¡ããã¨ã«æ°ä»ãããããNUCãä¸å¤ã§4å°è³¼å ¥ãã¾ããã
å°ããã¦ããããã§ããã2ã³ã¢4ã¹ã¬ãããã¡ã¢ãªæ大32GBæè¼å¯è½ãªã¢ãã«ã§ããSSDã¯M.2 NVMeãªãã®ãä¸ã¤æè¼ã§ããã®ã¿ãNICãä¸ã¤ãããªãã®ãä¸æºã§ã¯ããã¾ãããã¾ãå®ç¨ä¸å°ããã¨ã¯ãªãã§ãããã
vPro対å¿ããã»ããµã¼ãæè¼ãã¦ãããIntel AMT*2ã«ãã£ã¦ãªã¢ã¼ãé»æºç®¡çå¯è½ãªProã¢ãã«ã§ã*3ã
ãNUCæ¬ä½ã4å°ã§7ä¸åã8GBã¡ã¢ãªã4æã»500GB SSDã4æã§4ä¸åãåè¨11ä¸åç¨åº¦ã§æãã¾ããã
ã¯ã©ã¹ã¿ã®ãã¼ãã¹ãã©ãã
ãcybozuã®Kubernetesã¯ã©ã¹ã¿ã¯sabakanãããã¦CKEãç¨ãã¦ç®¡çããã¦ãã¾ãã
ãããã使ããã¨ãæ¤è¨ãã¾ããããIntel AMTããµãã¼ããã¦ããMAAS*4ããããããã ã£ãã®ã§ãMAAS + kubesprayã§ã¯ã©ã¹ã¿ãæ§ç¯ãããã¨ã«ãã¾ãããMAASã¯å®¶ã«å ã ãã£ããµã¼ãã«ã¤ã³ã¹ãã¼ã«ãã¦ãã¾ãã
ãæåã«Intel AMTã®è¨å®ããã¦ããã°ãå¾ã¯èªåã§Ubuntuãã¤ã³ã¹ãã¼ã«ã»ã»ããã¢ãããããã¨ãã§ããããã«ãªãã¾ãããåNUCã«ãã£ã¹ãã¬ã¤ããã¼ãã¼ããç¹ãã§ä½åº¦ã試è¡é¯èª¤ãããããå¿ è¦ãç¡ã便å©ã§ãããã ãMAASãDHCPãµã¼ããªã©ãæä¾ããããã家ã®ä¸ã§ä»ã®ç«¯æ«ã使ããã®ã¨ã¯å¥ã®VLANãåã£ã¦ããã§éç¨ãã¦ãã¾ãã
cybozu-go/neco-apps
ãããã¾ã§ã§ç´ ã®Kubernetesã¯ã©ã¹ã¿ã¯ãã¡ã¾ãããããã®ã¾ã¾ã§ã¯ã¡ãã£ã¨ã¹ããã¯ã®ããMinikubeç¨åº¦ã®æ©è½ããç¡ãã®ã§ãã©ãã©ãã³ã³ãã¼ãã³ãããããã¤ãã¦ããã¾ãã
ãã¾ãããããããã¨ã決ãããããå®ç¾ã§ããã³ã³ãã¼ãã³ãããããã¤ãããã¨ã«ãã¾ãããèªåãå½å決ããè¦ä»¶ã¯ä»¥ä¸ã®éãã§ãã
type: LoadBalancer
ãªServiceãå©ç¨ã§ãããããã«ã¯æå®ããç¹å®ã®ã¬ã³ã¸ã®IPã¢ãã¬ã¹ãå²ãå½ã¦ããã¨ãã§ãããã¨ã- èªåã§SSL証ææ¸ãçºè¡ã»æ´æ°ããhttpsã§ãµã¼ãã¹ãæä¾ã§ããã
- ãªãããã®Ingress controllerã«ãã£ã¦ãªã¯ã¨ã¹ãã®ã«ã¼ãã£ã³ã°ãã§ããã
PersistentVolumeClaim
ã使ã£ã¦ãã¼ã¿ã®æ°¸ç¶åé åãåçã«åãåºãã¦å©ç¨ã§ããããã¼ãé害èæ§ãããã¨ããã- GitOpsã«ãã£ã¦å¤é¨ããã¢ã¯ã»ã¹ããããã¨ãªããµã¼ãã¹ãCDã§ããã
- ã¡ããªã¯ã¹ã®åéã»å¯è¦åãããã³ç£è¦ãã§ããã
ããããå®ç¾ããããã«ã¯æ§ã
ãªã³ã³ãã¼ãã³ããå©ç¨å¯è½ã§ãããä¸ä½ä½ãé¸æããã°ããã®ãâ¦â¦
ãã¼ãâ¦â¦
ãã£ãcybozu-go/neco-appsã§å®éã«ä½¿ããã¦ããã³ã³ãã¼ãã³ããå ¬éããã¦ãããã¼ã¼ãï¼ github.com
ã¨ãããã¨ã§åæã«åèã«ãã¾ããã
ã注æãçè ã¯Necoã®ããã¸ã§ã¯ãã¡ã³ãã¼ã§ã¯ããã¾ããã以ä¸ã¯åæã«åèãã¦ããã ãã§ãã
Metallb
ãããã¡Kubernetesã§LoadBalancerã使ãããã«ã¯å®è³ªã»ã¨ãã©é¸æè¢ãããã¾ããã§ããã
ãMetallbã¯Kubernetesã«ããã¦type: LoadBalancer
ãªServiceãæä¾ããããã®ã³ã³ãã¼ãã³ãã§ããBGPã§çµè·¯ãåºåããBGPã¢ã¼ãã¨ãARP*5ã使ã£ã¦VIPã«ç´ä»ããã¼ãã®ä»ãæ¿ããè¡ãL2ã¢ã¼ããããã¾ããBGPã¢ã¼ãã®å ´åã¯ã«ã¼ã¿å´ã§ECMPï¼Equal-cost multipathï¼ã使ããã¨ã§è¤æ°ã®ãã¼ãã«åæ£ãã¦ãã©ãã£ãã¯ãéããã¨ãã§ãã¾ãããL2ã¢ã¼ãã®å ´åã¯ãªã¼ãã¼ã¨ãªã£ãç¹å®ã®ãã¼ãã®ã¿ã«ãã©ãã£ãã¯ãéä¸ãã¾ããä»åã¯ãä¸è¬çãªã«ã¼ã¿ã§ãå©ç¨å¯è½ãªL2ã¢ã¼ããå©ç¨ãããã¨ã«ãã¾ããã
ãKubesprayã®ãªãã·ã§ã³ãæå¹ã«ãããã¨ã§ã¤ã³ã¹ãã¼ã«ã§ããã®ã§ããã使ãã¾ãããè¨å®æ¹æ³ã¯ https://kubespray.io/#/docs/metallb ã«ããéãã§ããæå®ããIPã¢ãã¬ã¹ã¬ã³ã¸ããtype: LoadBalancer
ãªServiceã«ã¢ãã¬ã¹ãå²ãå½ã¦ãã®ã§ãä»ã¨è¢«ããªãã¬ã³ã¸ãæå®ãã¾ã*6ãMAASã®UIããDHCPã§å²ãå½ã¦ãããªãIPã¢ãã¬ã¹ã¬ã³ã¸ãæå®ã§ããã®ã§ãããã使ã£ã¦LoadBalancerç¨ã®IPã¢ãã¬ã¹ã¬ã³ã¸ã確ä¿ãã¦ããå¿
è¦ãããã¾ããã
cert-manager
ãããªãã¿è¨¼ææ¸ç®¡çã®ããã®ã³ã³ãã¼ãã³ãã§ããç¹ã«èª¬æãããã¨ã¯ç¡ãã¨æãã¾ãã
ããããKubesprayã§ã¤ã³ã¹ãã¼ã«ã§ãããããããã使ãã¾ãã https://kubespray.io/#/docs/ert_managerã証ææ¸çºè¡ã¯Let's Encryptããããã¼ã¸ãDNSãµã¼ãã¹ã¨ãã¦Google Cloud DNSãå©ç¨ãã¦ãã¾ãã便å©ãªæ代ã«æè¬ð
Contour
ãContourã¯HTTPProxyã¨ããã«ã¹ã¿ã ãªã½ã¼ã¹ã使ãIngress controllerã§ãããã®å®æ
ã¨ãã¦ã¯Envoyã®ã³ã³ããã¼ã«ãã¬ã¼ã³ã§ããHTTPProxyãªã½ã¼ã¹ã¯å人çã«ã¯Ingressããã好ãã§ãã
ãã¤ã³ã¹ãã¼ã«ããæ¹æ³ã¯é常ã«ç°¡åã§ã以ä¸ã«ãããã®ãã»ã¼ãã®ã¾ã¾å©ç¨ããã ãã§ããèªåã¯kustomizeã使ã£ã¦ã¤ã¡ã¼ã¸ã®ãã¼ã¸ã§ã³ãåºå®ããªã½ã¼ã¹ã®è¨å®ã追å ãã¾ããã
ãHTTPProxyãªã½ã¼ã¹ã¯Ingressãªã½ã¼ã¹ããã簡便ã«æ¸ãã¦è¯ãã¨èªåã¯æã£ã¦ãã¾ãããä¸æ¹ã§ä»ã®ã³ã³ãã¼ãã³ãã¨ã®ã¤ã³ãã°ã¬ã¼ã·ã§ã³ã¯Ingressã¨æ¯ã¹ãã¨å¼±ãã§ããä¾ãã°cert-managerç¨ã«ã¢ããã¼ã·ã§ã³ä»ä¸ãããã¨ã«ãã証ææ¸ãèªåçºè¡ããæ©è½ãªã©ã¯å©ç¨ã§ãã¾ããããã®ããCybozuã§ã¯HTTPProxyãªã½ã¼ã¹ãç£è¦ããExternalDNSã®ããã«DNSEndpointãªã½ã¼ã¹ããcert-managerã®ããã«Certificateãªã½ã¼ã¹ãèªåã§çæããæ©è½ã追å ããã«ã¹ã¿ã ã³ã³ããã¼ã©ã§ããcybozu-go/contour-plusãéçºã»å©ç¨ãã¦ãã¾ããããã«ããHTTPProxyãªã½ã¼ã¹ãä½ãã ãã§ä»¥ä¸ã追å ã§èªåçã«è¡ãããã«ãã¦ãã¾ãã
- DNSã¬ã³ã¼ãã®ç»é²
- 証ææ¸ã®çºè¡
ä»åèªåã¯å¤é¨ã¸ã®ãµã¼ãã¹å ¬éãã»ã¨ãã©èãã¦ããªã*7ãã¨ããæ¡ç¨ãã¹ããããã¾ããããé常ã«ä¾¿å©ãªã®ã§å¤é¨ã«ãµã¼ãã¹å ¬éãèãã¦ããå ´åã¯æ¯é使ã£ã¦ã¿ã¦ãã ããã
TopoLVM
ãCybozuãéçºã»éç¨ãã¦ãããLVMã使ã£ã¦PersistentVolumeãæä¾ããCSIãã©ã°ã¤ã³ã§ãã詳ããã¯ä»¥ä¸ãã覧ä¸ããã
ãå¾è¿°ããRookã§PVC basedãªã¯ã©ã¹ã¿ãæ§ç¯ããããmocoã§MySQLã¯ã©ã¹ã¿ãæ§ç¯ããããã«å©ç¨ãã¦ãã¾ããPVã¨ãã¼ããç´ä»ãããããã®ãã¼ããå©ç¨ã§ããªããªã£ãå ´åãã®PVã®æ
å ±ã¯å¤±ããã¦ãã¾ãã¾ããå©ç¨ããå´ã§ãã¼ã¿ã®åé·æ§ã確ä¿ããå¿
è¦ãããã¾ãã
ãKubernetes v1.21ããbetaã¨ãªã£ãGeneric Ephemeral Volumeã¨ãã¦å©ç¨ãããã¨ãã§ãã¾ããTopoLVMç¨ã®VGããããªã¥ã¼ã ãåãåºããããemptyDirã§ãã¹ãOSã®ã¹ãã¬ã¼ã¸é åãå§è¿«ããã¦ãã¾ããã¨ãé²ããã¨ãã§ãã¾ãã
Rook
ãåæ£ã¹ãã¬ã¼ã¸ã½ããã¦ã§ã¢ã§ããCephãKubernetesã§ç®¡çããããã®ãªãã¬ã¼ã¿ã§ããCephãRookã«ã¤ãã¦ã¯ä»¥ä¸ã®è¨äºããåç §ãã ããã
ãTopoLVMã«ãã£ã¦PVCããDynamic Provisioningã§ããããã«ãªã£ã¦ãããããRookã§ã¯PVC basedãªã¯ã©ã¹ã¿ãä½æãã¾ãããid:tenzen_hgst ããã®ä»¥ä¸ã®è¨äºãåèã«ãã¾ããã
ã¨ã¯ããä»åã®ã¯ã©ã¹ã¿ã«ã¯3ã¤ã®ã¯ã¼ã«ã¼ãã¼ããåãã¼ãã«1å°ã®ã¹ãã¬ã¼ã¸ãè¼ã£ã¦ããã®ã¿ãªã®ã§ã大ããã®ããªã¥ã¼ã ã®OSDãåãã¼ãã«ä¸å°ããã¨ããæãã®ç°¡åãªæ§æã«ãªã£ã¦ãã¾ããããã¾ãOSDã®å²ãå½ã¦ãªã©ã§æ©ãä½å°ãããã¾ããã§ãããRook/Cephå ¨ç¶ããããã¨è¨ããªãã使ã£ã¦ãã¾ãã
ãTopoLVMã¨ã¯ç°ãªããå¯ç¨æ§ã®ããPVãæä¾ãããã¨ãã§ãã¾ããã¾ããS3äºæãªAPIãåãããªãã¸ã§ã¯ãã¹ãã¬ã¼ã¸ãæä¾ãã¦ãããMinioãªã©ãå¥é建ã¦ãªãã¦ããªãã¸ã§ã¯ãã¹ãã¬ã¼ã¸ãå©ç¨ã§ãã¾ãããã¯ããªãã¸ã§ã¯ãã¹ãã¬ã¼ã¸ãããã¨ãã£ã¨ã¯ã©ã¦ããã¤ãã£ãã£ã½ããªãã¾ããï¼ï¼ï¼ã
https://rook.io/docs/rook/v1.7/ceph-object.html
SealedSecret
ãGitOpsã®ããã«ã¯SecretãGit管çãããã¨ããã§ããããã©ã¤ãã¼ããªãã¸ããªã«ããã¨ãã¦ãæµåºã«åãã¦æå·åã§ãããªããã¦ããããã¨ããã§ããBitnamiã®SealedSecretã³ã³ããã¼ã©ã¨kubesealã³ãã³ãã使ãã°ãç°¡åã«æ¢åã®Secretãæå·åãã¦å©ç¨ãããã¨ãã§ãã¾ãã
ã詳ããå°å
¥ã»å©ç¨æ¹æ³ã«ã¤ãã¦ã¯ä»ã®ãµã¤ãã«è²ãã¾ãããArgoCDã§ãã¤ã¾ã§çµã£ã¦ãSealedSecretã®Syncãå®äºããªãåé¡ãv0.17.0ã§è§£æ¶ãã¦ãã*8ã®ã§ç´¹ä»ãã¦ããã¾ãã
ArgoCD
ãGitOpsã®ããã®ã³ã³ããã¼ã©ã§ããããã¡Kubernetesã§ã¯å¯è½ãªéãå¤å´ã«é²åºããã¢ã¿ãã¯ãã¤ã³ããæ¸ããã¦ãæ¯æ¥ã¡ã³ãã§ããªãä¸å®ã軽æ¸ããããã®ã§ããGitOpsãªãã°ãå¤å´ããã¢ã¯ã·ã§ã³ãå®è¡ãããããªå£ãéãããã¨ãªãç¶ç¶çã«ã¢ããªã±ã¼ã·ã§ã³ããããã¤ãããã¨ãã§ãã¾ããä»ã«æåãªGitOpsã®ããã®ãã¼ã«ã¨ãã¦Flux 2ãªã©ãç¥ããã¦ãã¾ãã
ãåºæ¬çãªã¤ã³ã¹ãã¼ã«æ¹æ³ã¯å ¬å¼ããã¥ã¡ã³ãã®éãã§ãããã ãä¸é¨ãããããç®æããã£ãã®ã§ãkustomizeã使ã£ã¦ä¸é¨å¤æ´ãã¦ãã¾ãã
GitHubã¢ã«ã¦ã³ãã§SSOãã
ãä¸äººãªã®ã§adminã®ãã¹ã¯ã¼ããkubectlã³ãã³ãã§ã¶ã£ãæãã¦ä½¿ã£ã¦ãè¯ãã®ã§ããããã£ãããªã®ã§GitHubã§SSOãããã¨ã«ãã¾ãããã¾ãèªè¨¼ã®ããã®orgãå¿ è¦ãªã®ã§ãé©å½ãªorgãç¨æãã¾ãããã®orgã®è¨å®ãããGitHubã®OAuth Applicationãç¨æãã¾ãã
ç¨æããOAuth Appã®Client IDã¨Client Secretãç¨æããSecretãªã½ã¼ã¹ã¨ãã¦ä½æãã¾ããå®éã«ã¯ãããkubesealã³ãã³ãã使ã£ã¦SealedSecretãªã½ã¼ã¹ã¨ãã¦æå·åãã¦ãã¾ãã
apiVersion: v1 kind: Secret type: Opaque metadata: name: argocd-github-client-secret namespace: argocd spec: stringData: clientID: Client ID clientSecret: Client Secret
ä¸è¨Secretã使ãããã«ArgoCDãè¨å®ãã¾ãã以ä¸ã¯æä½éã®è¨å®ã§ããå¿ è¦ãªä»ã®è¨å®ã¯å ¬å¼ã®ãµã³ãã«ãè¦ã¦ãã ããã
apiVersion: v1 kind: ConfigMap metadata: name: argocd-cm data: # ArgoCDã«ã¢ã¯ã»ã¹å¯è½ãªURLãæå®ãããã³ã¼ã«ããã¯ã®FQDNããããæãã url: https://argocd.sample.com # falseãªãã°adminã¦ã¼ã¶ãä½æããªã admin.enabled: "false" dex.config: | connectors: - type: github id: github name: GitHub config: # $ã·ã¼ã¯ã¬ããå:key ã®å½¢ã§æå®ãã clientID: $argocd-github-client-secret:clientID clientSecret: $argocd-github-client-secret:clientSecret orgs: # ã©ã®orgã許å¯ããã - name: orgå teamNameField: slug --- apiVersion: v1 kind: ConfigMap metadata: name: argocd-rbac-cm data: # ã©ã®orgã®ã©ã®teamã«ã©ã®æ¨©éãå²ãå½ã¦ãããroleã¯adminã¨read-onlyã®ã¿ãããã©ã«ãã§ç¨æããã¦ããã # https://argo-cd.readthedocs.io/en/stable/operator-manual/rbac/#basic-built-in-roles policy.csv: | g, orgå:teamå, role:admin # ã©ã®ãã¼ã ã«ãæå±ããªãã¦ã¼ã¶ã«ä½ãå²ãå½ã¦ããã空æåã«ããã¨ä½ãå²ãå½ã¦ãªã == é²è¦§æ¨©éããç¡ãã policy.default: ""
ããããé©ç¨ãããã¨ã§ArgoCDã«GitHubã§ãã°ã¤ã³ãããã¿ã³ã表示ãããããã«ãªãã¾ãã
gRPCç¨ã¨Web UIç¨ã§ãµã¼ãã¹ãåãã
ãneco-appsãè¦ã¦ããã¨ãArgoCD Serverç¨ã«ãªãã2種é¡ã®serviceããããã¨ã«æ°ä»ãã¾ããã
- neco-apps/service.yaml at release-2021.12.01-27858 · cybozu-go/neco-apps · GitHub
- neco-apps/service.yaml at release-2021.12.01-27858 · cybozu-go/neco-apps · GitHub
çæ¹ã«ã¯ projectcontour.io/upstream-protocol.tls: 443,https
ããããçæ¹ã«ã¯ projectcontour.io/upstream-protocol.h2: 443,https
ãä»ãã¦ãã¾ãããããã¯Contourç¨ã®annotationã§ãEnvoyã§TLSçµç«¯ããã«upstreamã®ãµã¼ãã¹ã«ãããã·ããããã®è¨å®ã§ãã
https://projectcontour.io/docs/v1.19.1/config/upstream-tls/
ã©ããContourã¯åããã¹ãã»ãã¼ãã«å¯¾ãã¦ç°ãªããããã³ã«ï¼http/https or gRPC (http/2)ï¼ã§ãµã¼ããããã¨ã許ãã¦ããªãããã§ããã¾ãåããªããªã£ã¦ãã¾ãã¨ããæåã«å¯¾ããã¯ã¼ã¯ã¢ã©ã¦ã³ãã®ããã§ãã2ã¤ã®ã¢ããã¼ã·ã§ã³ãä¸ã¤ã®Serviceã«ä»ä¸ãã¦åããã¦ã¿ããããã¾ããããå®éã«argocdã³ãã³ãããã¾ãåããªãã£ããããããèªåãåæ§ã«äºã¤ã®Serviceã«åãã¾ãããHTTPProxyãªã½ã¼ã¹ã®æ¸ãæ¹ã¯ä¸è¨ã®éãã§ãã
neco-apps/httpproxy.yaml at release-2021.12.01-27858 · cybozu-go/neco-apps · GitHub
VictoriaMetrics
ãæ®éã«Prometheusã使ã£ã¦ãè¯ãã£ãã®ã§ãããä¸è¨ã®è¨äºãèªãã§VictoriaMetricsã使ã£ã¦ã¿ããã¨ã«ãã¾ããã
ãããã¡Kubernetesãããä¸ã§å¬ãããã¨ã¨ãã¦ã¯ã以ä¸ã®è¾ºãã§ããããã
https://docs.victoriametrics.com/Single-server-VictoriaMetrics.html#prominent-features
- It uses 10x less RAM than InfluxDB and up to 7x less RAM than Prometheus, Thanos or Cortex when dealing with millions of unique time series (aka high cardinality).
- It provides high data compression, so up to 70x more data points may be crammed into limited storage comparing to TimescaleDB and up to 7x less storage space is required compared to Prometheus, Thanos or Cortex.
- It is optimized for storage with high-latency IO and low IOPS (HDD and network storage in AWS, Google Cloud, Microsoft Azure, etc). See disk IO graphs from these benchmarks.
ã¾ã¨ããã¨RAMã®ä½¿ç¨éãå°ãªãï¼ãã¼ã¿ã®å§ç¸®çãè¯ãï¼é
ãã¹ãã¬ã¼ã¸ã§ã大ä¸å¤«ï¼ï¼ä»åã¯NVMe SSDã ãã©ï¼
ç¹ã«ã¹ãã¬ã¼ã¸å®¹éã¯æ¯è¼çå°ããã§ãããã¨ãå¤ãã¨æãã®ã§ããã¼ã¿å§ç¸®çãè¯ãã®ã¯å¬ããã§ãããå ãã¦æ¯è¼çæ§æãã·ã³ãã«ã§ãããã¨ãå°å³ã«å¬ããç¹ã§ããç解ã楽ãªã®ã§ã
ãä»åã¯Victoria Metrics operatorã使ã£ã¦ã¯ã©ã¹ã¿ãæ§ç¯ãã¾ãããå°å ¥èªä½ã¯å²ã¨ç°¡åã§ãã
å ¨ç¶ä¸è¦ãªã®ã«èª¿åã«ä¹ã£ã¦HAæ§æã§çµãã ã®ã§ããã®ãã¡é£½ããã解ä½ãã¾ããä»ã®ã¨ããã¡ããã¨åãã¦ãã¦è¯ãããã
Grafana operator
ãVictoriaMetricsã¯Web UIãæããªãã®ã§ãå¯è¦åã®ããã«Grafanaãå ¥ãã¾ããGitOpsãããã®ã§Grafana operatorãå°å ¥ããããã·ã¥ãã¼ãããã¼ã¿ã½ã¼ã¹ãã³ã¼ãã§ç®¡çãã¾ããã¾ãããã£ããArgoCDã§ã¯GitHubã§SSOããããã«ããã®ã§ãGrafanaãåæ§ã«ãã¾ããâããããçç¥ãã¦èªè¨¼å¨ãã®ã¿ã«çµã£ã¦ãã¾ãã
apiVersion: integreatly.org/v1alpha1 kind: Grafana metadata: name: grafana spec: config: auth: disable_login_form: False disable_signout_menu: True auth.anonymous: enabled: False # GitHubã§ã®SSOã®è¨å® auth.github: enabled: true allow_sign_up: true scopes: user:email,read:org auth_url: https://github.com/login/oauth/authorize token_url: https://github.com/login/oauth/access_token api_url: https://api.github.com/user allowed_organizations: orgå server: domain: å ¬éãããã¡ã¤ã³å root_url: https://å ¬éãããã¡ã¤ã³å users: viewers_can_edit: true auto_assign_org_role: Viewer deployment: envFrom: - secretRef: # ãã®secretã«client idãclient secretãå ¥ãã¦ãã name: grafana-github-client-secret
Secretã§ã¯ç¹å®ã®ç°å¢å¤æ°ã«å¤ã渡ãã¾ãããã®è¾ºãã®è¨å®ã¯ããã¨ãããã«ããã®ã§ããã®è¾ºããåç §ããã°ä»ã®ãããã¤ãã§ãSSOåºæ¥ãã¨æãã¾ãã
apiVersion: v1 kind: Secret type: Opaque metadata: name: grafana-github-client-secret spec: stringData: GF_AUTH_GITHUB_CLIENT_ID: Client ID GF_AUTH_GITHUB_CLIENT_SECRET: Client Secret
DataSourceãé©å½ã«è¶³ãã¾ããä»ã®ã¨ããVictoriaMetricsããããªãã®ã§ããã ãã§ãã
apiVersion: integreatly.org/v1alpha1 kind: GrafanaDataSource metadata: name: vm-source spec: name: victoriametrics.yaml datasources: - name: victoriametrics type: prometheus access: proxy # vmselectã®serviceãæå® url: http://vmselect-vmcluster.monitoring.svc:8481/select/0/prometheus version: 1 isDefault: true editable: false jsonData: tlsSkipVerify: true timeInterval: "30s"
ããã·ã¥ãã¼ãã grafana.comã§å ¬éããã¦ããããã·ã¥ãã¼ã ã¯ä»¥ä¸ã®æ§ã«ç°¡åã«è¿½å ã§ãã¾ããä¾ãã°Node Exporterã®ããã·ã¥ãã¼ãã®revision 23ããããã¤ããå ´åã¯ä»¥ä¸ã®ããã«ãã¾ã*9ã
apiVersion: integreatly.org/v1alpha1 kind: GrafanaDashboard metadata: name: node-exporter spec: url: "https://grafana.com/api/dashboards/1860/revisions/23/download" datasources: - inputName: "DS_PROMETHEUS" datasourceName: "victoriametrics"
åNodeã«Node Exporterããã¦ã¦ãããVMNodeScrape
ãªã½ã¼ã¹ãªã©ã使ã£ã¦æ
å ±ãåéããã¦ããã°ä»¥ä¸ã®æ§ã«ããã·ã¥ãã¼ãã表示ã§ãã¾ãã
moco
ãããã¾ã§ã§åºæ¬çãªãã¨ã¯ã ãããã§ããKubernetesã¯ã©ã¹ã¿ãã§ãã¾ãããã¤ãã§ãªã®ã§ããä¸å使ããã³ã³ãã¼ãã³ãããããã¤ãã¦ããã¾ãã
ãmocoã¯Cybozuãéçºãã¦ããMySQLãªãã¬ã¼ã¿ã§ãMySQLã®Semi-sync replicationã使ã£ãã¯ã©ã¹ã¿ãæä¾ãã¾ãã使ãåæãé常ã®MySQLã¨å¤ãããªããã¨ãææªã©ããããããªããªã£ãã社å
ã§èãã°ãªãã¨ããªãããã¨æã£ãã®ã§å°å
¥ãã¦ã¿ã¾ãããã¤ã³ã¹ãã¼ã«ãâã®ããã¥ã¡ã³ãã«å¾ãã ãã§ãããé常ã«ç°¡åã§ãã
ãä½æããMySQLClusterãªã½ã¼ã¹ã§æ°¸ç¶åããªã¥ã¼ã ã®å¤§ãããæå®ã§ããã®ã§ãããä¾ã§ã¯1GBã¨ãªã£ã¦ãã¾ããèªåã®æå
ã§ã¯å®¹éä¸è¶³ã§èµ·åããªãã£ããããããã5ï½10GBç¨åº¦ã¯å²ãå½ã¦ã¦ããã¨è¯ãã¨æãã¾ããã¾ãname㯠mysql-data
ã§åºå®ã§ããæåé©å½ãªååãä»ãã¦å¤±æãã¾ãã*10ã
apiVersion: moco.cybozu.com/v1beta1 kind: MySQLCluster metadata: name: test spec: ... volumeClaimTemplates: - metadata: name: mysql-data spec: accessModes: [ "ReadWriteOnce" ] resources: requests: storage: 10Gi
éçºç°å¢
ã大ããªå¤æ´ããããªãæ¬çªã¯ã©ã¹ã¿ã«å½ã¦ãã®ã¯æãã§ããããã¨ããããã§ããã¡Kubernetesã¯ã©ã¹ã¿ãéçºç°å¢ãç¨æããããã«ãã¾ããã
ãã¯ã©ã¦ãã§ã¤ã³ã¹ã¿ã³ã¹ãä½ããã¨ãèãã¾ãããããã¾ãã¾æå
ã«ããããã¹ããã¯ã®è¯ãWindowsãã¹ã¯ããããã·ã³ãããã®ã§ãããã«VMãç«ã¦ã¾ãããã¨ã«ãã¾ããã
- CPUï¼Ryzen7 3700Xï¼8ã³ã¢ 16ã¹ã¬ããï¼
- RAMï¼64GB
- SSDï¼2TB
VMã5ã¤å»ºã¦ã¾ãããããã以ä¸ã®å½¹å²ãæã¡ã¾ãã
- maas-masterï¼MAASãã¤ã³ã¹ãã¼ã«ãã¦ãããµã¼ã
- maas-node1ï¼Kubernetesã®Masterãã¼ã
- maas-node2ï¼Kubernetesã®Workerãã¼ããã®1
- maas-node3ï¼Kubernetesã®Workerãã¼ããã®2
- maas-node4ï¼Kubernetesã®Workerãã¼ããã®3
éã«ä½ã£ã¦ãã£ããã¹ããã¯ãã¾ã¡ã¾ã¡ã«ãªã£ã¦ãã¾ããã§ãã¾ãå°ã£ã¦ãªãã®ã§ããããªã¨ãããã¨ã§ãã®ã¾ã¾ã«ãªã£ã¦ããã¨ããéãªå³ã§ããåä½ç¢ºèªã®ããã«ãã¹ã¯ãããPCãèµ·åãã¦ããå¿ è¦ãããã¨ããGitOpsã§ãããã¤ã¯ã§ãããå¤é¨ããã®ã¢ã¯ã»ã¹ã¯è¨±å¯ãã¦ããªãã®ã§å®è³ªéçºç°å¢ããã®ãã¹ã¯ãããPCã«åºå®åããã¦ããã¨ãããã¤ã±ã¦ãªãã¨ããã§ãã
ãåºæ¬çã«ãã®ç°å¢ã§åä½ãæ¤è¨¼ããåé¡ãªããã°å¤æ´ãreleaseãã©ã³ãã«ãã¼ã¸âæ¬çªç°å¢ã®ArgoCDããããsyncãã¦é©ç¨ã¨ããæµãã«ãªã£ã¦ãã¾ããã¨ã¯ããæ¬çªç°å¢ã§ããèµ·ããªãåé¡ãªã©ã度ã å¼ãã¦ããããªããªããã¾ããããªããªã¨ããæãã§ã*11
ä»åãã¦ãããã®
ãæ±ç¨çãªWebã¯ãã¼ã©ã¼ã®ãããªãã®ãæ¸ãã¦æ°çéç¥ãããããã¦ãã¾ããç¹ã«éå ±æ§ã¯æ±ãã¦ããªãã®ã§ããªãç·©ãããªãã¼ã¹ã§ã®éç¥ã§ãããDBããªãã¨ã¤ããAWS LambdaãGoogle Cloud Functionsã«å°å³ã«ä¹ãã¥ããã£ããã®ã§ããDBã¹ãã¼ãã®å¤æ´ã¾ã§GitOpsã§å®çµãã¦ããã®ã§ãã³ã¼ããæ¸ãã¦ãªãªã¼ã¹ã¾ã§ã¯ã©ã¹ã¿ã«è§¦ããå¿
è¦ãããã¾ããããã®ãããã«ã¤ãã¦ã¯ã¾ããããè¨äºãæ¸ããã°è¯ããªã¨æã£ã¦ãã¾ãã
ãä»ã¯æ°ã«ãªã£ãç©ãã¨ãã©ããããã¤ããç¨åº¦ã§ããã¾ãå®å®çã«åãã¦ãã³ã³ãã¼ãã³ãã¯ããã¾ãããä½ãé¢ç½ããã®ãæãã¤ãã®ãå¾
ã£ã¦ãã¾ãã
ãããããããããã¨
ããã¯ã¢ããã¨ãªã¹ãã¢
ãä»ã®ã¨ããRook/Cephãå´©å£ããã¨ãã¼ã¿ãå ¨ãã¹ããã¾ãããã¡ã«ã¯NASãããã®ã§ãå®æçã«ãã¼ã¿ã®ããã¯ã¢ãããåãããã¨ããã§ããã¾ããããã¯ã¢ããã¯åã£ãã ãã§ã¯æå³ãç¡ããããããªã¹ãã¢ã§ããå¿ è¦ãããã®ã§ãªã¹ãã¢ã®æ¹æ³ã«ã¤ãã¦ãæ¢æ±ãã¦ããããã¨æã£ã¦ãã¾ãã ãããã¡ã¯ã©ã¹ã¿ã§ã¯è»½ãæ°æã¡ã§ãã¼ã¸ã§ã³ä¸ãããæ°ãããã®ãå ¥ãããããã¡ãªä¸ãå£ããã¨ç´ãã®ãé¢åã«ãªã£ã¦æ¾ç½®ããã¡ã§ããææªã¯ã©ã¹ã¿ãä¸åº¦å£ãã¦ä½ãç´ãã¦ãOKã¨ããä½å¶ãæ´ãã¦é·ã使ã£ã¦ããããã§ããã
ç£è¦ã®å å®
ãVictoriaMetricsã¨Grafanaãå ¥ããã¨ã¯ãããã¾ã ã¾ã ä¸èº«ã追ãã¤ãã¦ãã¾ãããå°ããã¤æ¡å ãã¦ãããã°ãªã¨æã£ã¦ãã¾ããPromQLãé£ããããâ¦â¦
ã¾ã¨ã
- ããã¡Kubernetesã¯ã©ã¹ã¿ãIntel NUCã§çµã¿ã¾ãã
- ãããã¯ã·ã§ã³ç°å¢ã§åä½ãã¦ããcybozu-go/neco-appsãåèã«ãããã¤ããã³ã³ãã¼ãã³ãã決ããå®éã«éç¨ãã¦ãã¾ã
- 楽ããã
以ä¸ã§ããçããã®ç´ æµãªããã¡Kubernetesã¯ã©ã¹ã¿æ å ±ãå¾ ã¡ãã¦ããã¾ãã
ææ¥ä»¥éã®Cybozuã¢ããã³ãã«ã¬ã³ãã¼ãã楽ãã¿ãã ããï¼
*1:çé¢ç®ãªãã¨ãè¨ã£ã¦ããã¨ãç¾å®ä¸çã®è¤éãªé¨åãã¯ã©ã¦ããããã¤ãã«æ¼ãä»ãã£ã±ãªãã«ããã ãã§ãªããèªåã§ä½æããæ¹ãããã¨æã£ã¦ããããã§ããããã°ããã»ã©ããã¼ã¸ããµã¼ãã¹ã®ããããä½æã§ãã¦å®ãæããã®ã§ãå¾ã§ãã
*2:インテル® アクティブ・マネジメント・テクノロジー (インテル® AMT) | インテル
*3:NUCã§vPro対å¿ãã¦ãããã®ã¯é常ã«å°ãªãããã¬ã¢ã§ãããLenovoãDELLã»HPãªã©ããåºã¦ããå°åPCã«ã¯å¯¾å¿ãã¦ãããã®ãè±å¯ã«ããã¾ããå ¥ææ§ã¯ãããã®æ¹ãè¯ãã§ãããã
*5:IPv4ã®å ´åãIPv6ã®å ´åã¯NDPã
*6:ããã§å²ãå½ã¦ãIPã¢ãã¬ã¹ã¯ãã©ã¤ãã¼ãIPã¢ãã¬ã¹ã§ããå¤é¨ã«ãµã¼ãã¹ãå ¬éãããå ´åãã«ã¼ã¿ã®NAPTã使ã£ã¦ã«ã¼ãã£ã³ã°ããå¿ è¦ãããã¾ãã
*7:主ã«å®¶ã®ä¸ã§å¼ããã°è¯ãã®ã§ãåå解決ã«ã¯ã«ã¼ã¿æè¼ã®ç°¡æDNSãµã¼ãã使ã£ã¦ãã¾ãã証ææ¸ã¯å¿ è¦ã§ããDNS-01ãã£ã¬ã³ã¸ãªãã°HTTPãµã¼ããå ¬éãã¦ããå¿ è¦ããªããå¤é¨ã«ä¸åå ¬éããã«éç¨ãå¯è½ã§ã
*8:æ£ç¢ºã«ã¯v0.16.0ã®æç¹ã§è¿½å ã®ãã©ã°ãä¸ãããã¨ã§è§£æ¶ã§ããããã«ãªããv0.17.0ã§ãã®ãªãã·ã§ã³ãããã©ã«ãã§æå¹åããã¾ããã github.com
*9:é©ç¨ç´å¾ãã°ããã¯ããã·ã¥ãã¼ãã®åå¾æã« Too Many Requests ã®ãããªã¨ã©ã¼ãåºã¦ããã®ã§ããããã°ããæ¾ç½®ããã¨åå¾ã§ããã®ãããã·ã¥ãã¼ããè¦ããããã«ãªã£ã¦ãã¾ãã
*10:ã¡ããã¨ããã¥ã¡ã³ããèªãâ¦â¦
*11:éã«Grafana operatorã§ã¯èªåã®éçºç°å¢ã§ã®ã¿èµ·ããåé¡ãå¼ãå½ã¦ã¦ãã¾ããç¾ç¶æ¬çªç°å¢ã«å½ã¦ãªãã¨åä½ç¢ºèªã§ããªãã¨ããææªãªç¶æ³ã«ãªã£ããããã¦ãã¾ãã github.com