Deis Workflow v2.13.0ã§Kubernetesã®Ingressããµãã¼ãããã件
Deisãverupãã
æ¬æ¥ãDeis Workflowãverupãããã§ãããChangelogãè¦ã¦ãã¨Ingressã¨ãããã®ããªããå°å ¥ããã¦Deis/routerãªãã¦ããããã¿ãããªãã¨ãã
ããããWhat is Ingress?
Kubernetesã®ãããããããªã½ã¼ã¹ã®ã¿ã¤ãã®ãã¡ã®ä¸ã¤ã®Ingressã ããã«ã¤ãã¦å¦ç¿ãããã®è¨é²ãæ®ãã
Kubernetesã®ãªã½ã¼ã¹ Service
ã¾ããIngressãç解ããåã«Kubernetesã«ãããServiceãç解ããå¿
è¦ããããServiceãKubernetesã®ãªã½ã¼ã¹ã®ã¿ã¤ãã®ãã¡ã®ä¸ã¤ã§ãç°¡åã«è¨ãã¨clusterã¨å¤é¨ãæ¥ç¶ãæ½è±¡åãããã®ãä¾ãã°ããã®serviceã®typeãLoadBalancer
ã¨æ¸ãã°ãkubernetesãããæãã«ããã¯ã¨ã³ãã®ã¯ã©ã¦ããããã¤ãã¼ãè¦ã¦åæã«LBãä½ã£ã¦ãããã
ããã¯ã¨ã³ããAWSãªãELBãGCPãªãGoolge Load Balancingã¨ããå
·åã«ã
ããããæ¦å¿µã«ãªãã
internet | ------------ [ Service ] (ä¾: ELBãªã©) | [ App ]
:point_up: ããã§ã¯åãããããã®ããã«Appã£ã¦æ¸ãã¦ããã©ãæ¬å½ã¯Kubernetesã®å ´åãã³ã³ããã®ã»ããã®Podã¨ããåä½ãåºæ¬ãæ¬å½ã¯ãã®PodãéåããReplicaSetããããå¸ãDeploymentã¨ãããããã ãã©ããã®è¾ºã¯å²æãã¾ãã¢ããªã±ã¼ã·ã§ã³ãåãã¦ããã³ã³ãããããã¨æã£ã¦ãããã°OKã
ä»ã«å¢ãããã«ã¼ãã£ã³ã°ã©ãããã®
ãã£ãã®ä¾ã ã¨ä¸ã¤ã®Serviceã¨ããããã¯ã¨ã³ãã®ã¢ããªã±ã¼ã·ã§ã³ã¨ããæãã ã£ãããããè¤æ°ã®ã¢ããªã±ã¼ã·ã§ã³ç«ã¡ä¸ãããã¨ããã¨ã©ããªããã£ã¦ããã¨ãServiceãããããå¢ããã¦ãããã°ãããã ãã©ãããããã¨ãã®åãå¤é¨ããæ¥ç¶ããããã®IPã¢ãã¬ã¹ãããããçæãããããDNSã¬ã³ã¼ãã®ç®¡çã¨ãé¢åã«ãªã£ã¦ãããDNSã ã¨ãã£ãã·ã¥ã¨ãããããè¿ éã§æè»ãªå¤æ´ãé£ããããï¼ã£ã¦è©±ãã©ã£ãã«æ¸ãã¦ãã£ããã ãã©å¿ãã¦ãã¾ã£ãã»ã»ï¼
internet | [ dns ] |-----------|-----------| ------------------------------------ IP:1.2.3.4 IP:5.6.7.8 IP:9.1.2.3 [ Service ] [ Service ] [ Service ] | | | [ App ] [ App ] [ App ]
ãããDeisåã¯ã«ã¼ãã£ã³ã°ã©ããã¦ãã®ã
Deis/routerã£ã¦ããcomponentããã£ã¦ããããLBã¨æ¯ãåããè¡ãnginxã§æ§æããã¦ããGCPä¸ã§ä½ãã¨ãããªããLoad Balancerã¯1ã¤ãªã®ã§IPã¢ãã¬ã¹ãä¸ã¤ã
internet | [ dns ] | ------------------------------------- IP:1.2.3.4 [ Service ] <- Google LoadBalnacing | [ Deis/router ] <- ç°¡åã«è¨ãã°ãã ã®nginxãvirtual hostã§backendã«æµã | ------------------------ | | | [ App ] [ App ] [ App ]
Deis/routerã®ä»£ããã«Kubernetesã®ãªã½ã¼ã¹ Ingress
Ingressã¯åServiceã¸ã®ã«ã¼ãã£ã³ã°ã®ã«ã¼ã«ã»ãããæ½è±¡åãããããªãã®ãL7ã®ã«ã¼ãã£ã³ã°ãã§ãããã¤ããã®ã«ã¼ã«ã®æ¸ãæ¹ã¯ãhost baseã ã£ãããpathãã¼ã¹ã ã£ããã§æ¸ãããã¾ããSSLçµç«¯ãªã©ã®è¨å®ãæ¸ããã¨ãã§ããã ä¾ï¼
apiVersion: extensions/v1beta1 kind: Ingress metadata: name: test-ingress spec: rules: - http: paths: - path: /testpath backend: serviceName: test servicePort: 80
ãã ãIngressã¯ã«ã¼ã«ãæ½è±¡åããã ãã®objectãªã®ã§ããã¤èªèº«ãã«ã¼ãã£ã³ã°ã¨ãä½ãã®å¦çãåããã¨ãããã¨ã§ã¯ãªããã«ã¼ãã£ã³ã°ãããããå®éã®å¦çãè¡ãIngress Controllerã¨ããå®ä½ã¸å½ä»¤ããã ãã§ããã ãªã®ã§ãIngressã¸ã«ã¼ã«ãæ¸ãã¨ãä½ãèµ·ãããã¨ããã¨ããã®ã«ã¼ã«ãè¦ã¦ãããã¯ã¨ã³ãã«ããIngress Controllerã¸APIãçºè¡ãããªããconfigãçªã£è¾¼ãã ããããªã©ã®å½ä»¤ãåºãã ãã®åå¨ããªã®ã§ãterraformçãªãã®ã«è¿ãã®ãããããªãã
Ingress Controllerã¨ã¯
ã§ãIngress Controllerã£ã¦ãªããªã®ãã£ã¦ããã¨ãçµå±ã¯ãLoadBalancerã®å®è£ ã§ãããæ¨æºã§ç¨æããã¦ããIngress Controllerã¯Nginxã¨GCEã¨ãã2ã¤ããããNginxã¯åã«nginxã§ã§ããLBã®å®è£ ã§ããã ãã¡ãããèªåã§Ingress Controllerãä½ããã¨ãã§ãããä¾ã¨ãã¦ãtraefikã¨ããGolangã§ã§ããReverse Proxyçãªãã¤ãIngress Controllerã¨ããä¾ãDeisã®å ¬å¼ã«ã¯ã®ã£ã¦ããã
GCEã®å ´åã¯ãGoogle LoadbalancingãURL Mapãªã©GCPã®ãªã½ã¼ã¹ã§ãããå®ç¾ããããã«ãªã£ã¦ãã
ãªã®ã§ãIngressã使ã£ãå ´åã¯ãã®ããã«ãªããä¸ã®å³ã®å¤é¨ã¨æ¥ç¶ããServiceããAppã¨æ¥ç¶ããããã®å é¨ç¨Serviceãããã¾ã§ãå¤å管çãã¦ãããã
internet | [ dns ] | ------------------------------------- IP:1.2.3.4 [ Service ] <- Google LoadBalnacing | [ HTTP TargetProxy ã URL map ] <- GCPã®æ¯ãåããã¦ããããã¼ã¤ | ------------------------ | | | [ Service ] [ Service ] [ Service ] <- å é¨IPã ãã®NodePortã¨ããtypeã®ãµã¼ãã¹ | | | [ App ] [ App ] [ App ]
ã¾ã¨ã
ãªã®ã§ãIngressã使ãã°ãDeis/routerã¯ãããªããªãã£ã¦ãã話ãDeis/routerã¯è¨å®ãè²ã é¢åãªã®ã§ãIngressãå©ç¨ããæ¹ãè²ã ã¨ãã£ãããããã ãããããããããä½ãããã£ã¦ãã¨ã¯ä»å¾ã¯Deis/routerããIngressãã¼ã¹ã®ãã®ã«ãªã£ã¦ããã®ã§ã¯ã¨äºæ³ãã¦ããã ã¨ããããDeisåãå®è£ ãã¦ãããã®ã¯ã©ãã©ãKubernetesãå¸åãã¦ããããã¤ãDeisåã¯ããªããªãã®ã§ã¯ã¨ããæªæ¥ãè¦ãã¦ããã
ãã¨ãKubernetesã¯IngressãServiceã®ããã«ç¾å®ä¸çã®ããä½ããä¸ã¤ã®ãã®ã«æ½è±¡åãã¦ãè£å´ã§ãããªã«å®è£ ããã£ãã¨æ¸ãã¦ããã¨ããä»çµã¿ã«ãªã£ã¦ãããã»ãã¨çºæ³ãããã ãªã®ã§ãKubernetesããã¨ãã¯ãããã¾ãTerraformã®åºçªããªãããªããã©ãããã¾ãå°ããªãããªããã£ã¦ããã¨KubernetesãTerraformã¿ãããªãã®ã§ãããããã