2024-06-02T13:06:12.000Z
์ง๋ ํฌ์คํธ์์๋ ํด๋ฌ์คํฐ๋ฅผ ์์ฑํ๊ณ , ๊ฐ์ฅ ๊ธฐ๋ณธ์ ์ธ ๋ฆฌ์์ค ์ ํ์ธ Deployment์ Service๋ฅผ ์ ์ํ ๋งค๋ํ์คํธ ํ์ผ์ ์์ฑํด๋ณด์๋ค.
์ด๋ฒ์๋ istio์ ๊ด๋ จ๋ ๋ฆฌ์์ค์ธ Gateway, VirtualService๋ฅผ ํฌํจํ ๋๋จธ์ง ์์
์ ์ ๋ถ ๋ง๋ฌด๋ฆฌํ์ฌ, ์ต์ข
์ ์ผ๋ก ๋ฐฐํฌ ์๋ํ๋ฅผ ๋ฌ์ฑํด๋ณด์.
์ค์ devOps ๊ฐ๋ฐ์ ๋ถ๋ค ํน์ ํด๋ผ์ฐ๋ ์๋น์ค์ ์ผ๊ฐ๊ฒฌ์ด ์์ผ์ ๋ถ๋ค์ ์ ๊ธ์ ๋ณด๊ณ ์๋ฌธ์ ํ๋ ๋ถ๋ถ์ด ํ๋ ๊ณณ์ด ์๋์ค ์ ์์ต๋๋ค.
์ฌ๋ฌ๋ถ๋ค์ ์๊ฒฌ์ด ์ ๋ถ ๋ง์ต๋๋ค. ์ ๋ ํ๋ก ํธ์๋ ๊ฐ๋ฐ์์ด๋ฉฐ, ๋จ์ํ ํ์ฌ์ k8s ์ธํ๋ผ๊ฐ ์ด๋ค ๋ฐฉ์์ผ๋ก ๋์ํ๋ ์ง ๋๋ฌด๋๋ ๊ถ๊ธํ์ฌ, ํ์ฌ์์ ๊ตฌ์ถํ ๋ฐฉ์์ ๊ธฐ์ค์ผ๋ก ์ค๋ช ์ ํ๋ ๊ฒ์ ๋๋ค.
์ ์์ค์์ ์ค๋ช ์ ํ ์ ์๋ ๋ถ๋ถ(์ spot ์ธ์คํด์ค๋ฅผ ์ฌ์ฉํ๋๊ฐ?)์ ์ค๋ช ํ๊ฒ ์ง๋ง, ๋๋ฌด deepํด์ง๋ ๋ถ๋ถ๋ค(ex. istio๋ ๋ฌด์์ด๋ฉฐ, ์ ์ฌ์ฉํ๋๊ฐ?)์ ์ ์์ค์ ๋ฒ์ด๋๋ ์ฃผ์ ๊ฐ ๋์ด์ ๋ถ๋์ด ์๋ตํ๋๋ก ํ๊ฒ ์ต๋๋ค. ๐
์ด๋ฏธ์ง ์ถ์ฒ : aws-eks-istio-lab
์ ์ด๋ฏธ์ง๋ EKS ํด๋ฌ์คํฐ ๋ด์์ ํธ๋ํฝ์ด ์ด๋ป๊ฒ ํ๋ฅด๋ ์ง๋ฅผ ๋ณด์ฌ์ค๋ค.
istio-ingressgateway๋ก ์ ๋ฌํ๋ค.istio-ingressgateway๋ ํธ๋ํฝ์ Gateway๋ก ์ ๋ฌํ๋ค.Gateway๋ ํธ๋ํฝ์ VirtualService๋ก ์ ๋ฌํ๋ค.VirtualService๋ ํธ๋ํฝ์ Service๋ก ์ ๋ฌํ๋ค.Service๋ ํด๋น ํธ๋ํฝ์ Pod๋ก ์ ๋ฌํ๋ค.Pod๋ ์ต์ข
์ ์ผ๋ก ์ฌ์ฉ์์๊ฒ ํด๋น ํ์ด์ง๋ฅผ ์๋ตํ๋ค.์์ ๊ฐ์ ํ๋ฆ์ผ๋ก ํธ๋ํฝ์ด ์ฒ๋ฆฌ๋๋๋ก ํ๊ธฐ ์ํด, ๋๋ ๋ค์ ์์๋ก ์์ ์ ์งํํ ๊ฒ์ด๋ค.
ALB๋ AWS์์ ์ ๊ณตํ๋ ๋ก๋๋ฐธ๋ฐ์ ์๋น์ค๋ก, ํด๋ฌ์คํฐ ์ธ๋ถ์์ ํด๋ฌ์คํฐ ๋ด๋ถ๋ก ํธ๋ํฝ์ ์ ๋ฌํ๋ ์ญํ ์ ํ๋ค.
์ค์นํ๋ ๋ฐฉ๋ฒ์ ์ฌ๋ฌ๊ฐ์ง๊ฐ ์๊ฒ ์ง๋ง, AWS์์ ์ด์ฌ์๋ helm์ ์ฌ์ฉํด์ ์ค์นํ๋ ๊ฒ์ ๊ถ์ฅํ๋ฏ๋ก, ์ด๋ฅผ ๋ฐ๋ผํ๊ธฐ๋ก ํ๋ค.
๐ค helm์ด๋?

Node.js์๋ NPM์ด ์๋ฏ์ด, Kubernetes์๋ Helm์ด๋ผ๋ ํจํค์ง ๋งค๋์ ๊ฐ ์๋ค.
๋ฐ๋ผ์ NPM์ npm install ๋ช
๋ น์ด์ ๋น์ทํ๊ฒ helm install ๋ช
๋ น์ด๋ก ํด๋ฌ์คํฐ์ ํ์ํ ์์กด์ฑ์ ์ฝ๊ฒ ์ค์นํ ์ ์๋ค.
macOS์์๋ brew install helm์ผ๋ก ๊ฐ๋จํ ์ค์นํ ์ ์๋ค.
curl -O https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.7.2/docs/install/iam_policy.json์ ๋ช
๋ น์ด๋ฅผ ์คํํด์ IAM ์ ์ฑ
ํ์ผ์ธ iam_policy.json์ ํ์ฌ ์์
๋๋ ํ ๋ฆฌ๋ก ๋ค์ด๋ก๋ํ๋ค.
aws iam create-policy \
--policy-name AWSLoadBalancerControllerIAMPolicy \ # 1๏ธโฃ ์ ์ฑ
์ด๋ฆ
--policy-document file://iam_policy.json # 2๏ธโฃ ์ ์ฑ
ํ์ผ์ดํ ์ aws ๋ช
๋ น์ด๋ฅผ ์คํํ์ฌ IAM ์ ์ฑ
์ ์์ฑํ์.
์ ์์ ์ผ๋ก ์์ฑ๋ IAM ์ ์ฑ
AWSLoadBalancerControllerIAMPolicy
IAM ์ ์ฑ ์ ์์ฑํ๋ค๋ฉด ์ด์ eksctl ๋ช ๋ น์ด๋ฅผ ์ฌ์ฉํด์ IAM ์ญํ ์ ์์ฑํ๋ค.
eksctl create iamserviceaccount \
--cluster=greenhead-cluster \ # ํด๋ฌ์คํฐ ์ด๋ฆ
--namespace=kube-system \
--name=aws-load-balancer-controller \
--role-name AmazonEKSLoadBalancerControllerRole \
--attach-policy-arn=arn:aws:iam::971490215356:policy/AWSLoadBalancerControllerIAMPolicy \
--approve # ๋ช
๋ น์ด ์คํ ํ ๋ณ๋ ์น์ธ๊ณผ์ ์์ด ๋ฐ๋ก ์๋น์ค ๊ณ์ ์ฌ์ฉโattach-policy-arn์์
971490215356์ ๋ด AWS ๊ณ์ ID๋ฅผ ์๋ฏธํ๋ค.
# 1๏ธโฃ eks-charts ๋ ํฌ์งํ ๋ฆฌ๋ฅผ ๋ก์ปฌ์ ์ถ๊ฐ
$ helm repo add eks https://aws.github.io/eks-charts
# npm๊ณผ ๋ฌ๋ฆฌ, helm์์๋ ๋ฆฌ์์ค๋ฅผ ์ค์นํ๋ ค๋ฉด ์ฐ์ ์ค์นํ๋ ค๋ ๋ ํฌ์งํ ๋ฆฌ๋ฅผ ๋ก์ปฌ์ ๋ฑ๋กํด์ค์ผ ํ๋ค.
# 2๏ธโฃ ๋ฑ๋กํ ๋ก์ปฌ ๋ ํฌ์งํ ๋ฆฌ ์ต์ ํ
$ helm repo update eks
# 3๏ธโฃ helm์ผ๋ก ALB ์ค์น
$ helm install aws-load-balancer-controller eks/aws-load-balancer-controller \
-n kube-system \ # ๋ค์์คํ์ด์ค ๋ช
์
--set clusterName=greenhead-cluster \
--set serviceAccount.create=false \ # ์ ๋จ๊ณ์์ ์๋น์ค ๊ณ์ ์ ์ด๋ฏธ ์์ฑํ์์ผ๋ฏ๋ก ์๋ต
--set serviceAccount.name=aws-load-balancer-controller์ ๋ช ๋ น์ด๋ค์ด ์ ๋ถ ์ ์์ ์ผ๋ก ์คํ๋์๋ค๋ฉด, ์๋ ๋ช ๋ น์ด๋ฅผ ํตํด ์ปจํธ๋กค๋ฌ๊ฐ ์ค์น๋์๋ ์ง ํ์ธํ์.
$ kubectl get deployment -n kube-system aws-load-balancer-controller
# ๋ค์๊ณผ ๊ฐ์ด ์ถ๋ ฅ๋๋ฉด ์ ์์ ์ผ๋ก ์ค์น๋ ๊ฒ์ด๋ค.
NAME READY UP-TO-DATE AVAILABLE AGE
aws-load-balancer-controller 2/2 2 2 47dGoogle Cloud์์ ์ค๋ช ํ๋ Istio์ ์ ์๋ ๋ค์๊ณผ ๊ฐ๋ค.
โIstio๋ ์ ํ๋ฆฌ์ผ์ด์ ๋คํธ์ํฌ ๊ธฐ๋ฅ์ ์ ์ฐํ๊ณ ์ฝ๊ฒ ์๋ํํ ์ ์๋ ํฌ๋ช ํ ์ธ์ด ๋ ๋ฆฝ์ ๋ฐฉ๋ฒ์ ์ ๊ณตํ๋ ํ๋ํ๋ ์๋น์ค ๋คํธ์ํน ๋ ์ด์ด์ธ ์๋น์ค ๋ฉ์์ ๋๋ค.โ
ํ๋ก ํธ์๋ ๊ฐ๋ฐ์์ธ ๋๋ก์๋ ๋๋ฌด์ง ํด๋น ๋ฌธ์ฅ์ ์ดํดํ ์ ์์๋คโฆ
Istio๊ฐ ๋ฌด์์ธ์ง ์ ํํ ์ดํดํ๋ ค๋ฉด ์ ์ง ์์ ์๊ฐ์ ์จ์ผ ํ ๊ฒ ๊ฐ๋ค๊ณ ๋๊ผ๊ธฐ์, ๋๋ ์์ ํธ๋ํฝ ํ๋ฆ ์ดํดํ๊ธฐ ์น์
์์ istio๊ฐ ์ด๋ป๊ฒ ์ฌ์ฉ๋์๋ ์ง๋ฅผ ์ฐธ๊ณ ํ์ฌ istio๋ฅผ โํด๋ฌ์คํฐ ์ธ๋ถ์์ ๋ด๋ถ๋ก ๋ค์ด์ค๋ ํธ๋ํฝ์ ๊ด๋ฆฌํ๋ ๋๊ตฌโ๋ก ๊ฐ๋จํ ์๊ฐํ๊ธฐ๋ก ํ์๋ค.
๋ ์ ํํ ๋ด์ฉ์ Istio ๊ณต์ ๋ฌธ์์์ ์ค๋ช ํ๋ ๋ด์ฉ์ ์ฐธ๊ณ ํ์โฆ
ํด๋ฌ์คํฐ์ Istio๋ฅผ ์ค์นํ๊ธฐ ์ํด ๋๋ CLI ๋๊ตฌ์ธ istioctl`์ ์ฌ์ฉํ ๊ฒ์ด๋ค. Homebrew๋ก ๊ฐ๋จํ ์ค์นํ ์ ์๋ค.
๋ค์ istioctl ๋ช
๋ น์ด๋ฅผ ์
๋ ฅํ์ฌ Istio ํด๋ฌ์คํฐ์ ์ค์นํ๋ค.
istioctl install --set profile=default # istio-system ๋ค์์คํ์ด์ค์ ์ค์น๋๋ค.profile ์์ฑ์ด ์๋ฏธํ๋ ๊ฒ์?
profile ์์ฑ์ ๋ช
์ํจ์ผ๋ก์จ ํน์ istio์ ๊ตฌ์ฑ ์์๋ฅผ ํฌํจ์ํค๊ฑฐ๋ ์ ์ธํ์ฌ istio๋ฅผ ์ค์นํ ์ ์๋ค. istio์ ์ฃผ์ ๊ตฌ์ฑ ์์ ์ค ๊ฐ์ฅ ์ค์ํ 3๊ฐ์ง๋ ๋ค์๊ณผ ๊ฐ๋ค.
istio-egressgateway: ํด๋ฌ์คํฐ ์ธ๋ถ -> ๋ด๋ถ๋ก ๋ค์ด์ค๋ ํธ๋ํฝ ๊ด๋ฆฌistio-ingressgateway: ํด๋ฌ์คํฐ ๋ด๋ถ -> ์ธ๋ถ๋ก ๋ค์ด์ค๋ ํธ๋ํฝ ๊ด๋ฆฌistiod: istio ํต์ฌ ๊ตฌ์ฑ์์๋์ ํด๋ฌ์คํฐ๊ฐ ์ ์ ๋์ํ๋ ค๋ฉด istio-ingressgateway, istiod๊ฐ ํ์ํ๋ฏ๋ก profile์ default๋ก ํ์ฌ istio๋ฅผ ์ค์นํ๋ค.
istioctl์ profile ๊ด๋ จํ์ฌ ์ข ๋ ์์ธํ ๋ด์ฉ์ ์ฌ๊ธฐ ํฌ์คํธ์์ ํ๊ตญ์ธ ๊ฐ๋ฐ์๋ถ๊ป์ ์ดํดํ๊ธฐ ์ฝ๊ฒ ์์ฑํด ์ฃผ์
จ๋ค.
์ด๋ ์ค์น๋ istio-ingressgateway์ Type์ Loadbalancer์ธ๋ฐ, ์ด ๊ฒฝ์ฐ ์๋์ผ๋ก ์ธ๋ถ ๋ก๋๋ฐธ๋ฐ์๋ฅผ ์์ฑํ๊ฒ ๋๋ค. ๋์ ๊ฒฝ์ฐ ์์์ ์ค์นํ ALB๊ฐ ๊ด๋ฆฌํ๋ ๋ก๋๋ฐธ๋ฐ์๋ฅผ ์ฌ์ฉํ ๊ฒ์ด๋ฏ๋ก, istio-ingressgateway์ Type์ NodePort๋ก ๋ณ๊ฒฝํ์ฌ ๋ถํ์ํ๊ฒ ๋ก๋๋ฐธ๋ฐ์๊ฐ ์์ฑ๋์ง ์๋๋ก ํ ํ์๊ฐ ์๋ค.
kubectl edit -n istio-system service istio-ingressgateway์ ๋ช
๋ น์ด๋ฅผ ์คํํ๋ฉด istio-ingressgateway์ ๋งค๋ํ์คํธ ํ์ผ์ ์ฐ๊ธฐ ๋ชจ๋๋ก ์ด ์ ์๋ค. ์๋์ ๊ฐ์ด ์์ ํ์.
spec:
...
type: NodePort # Loadbalancer๋ก ๋์ด ์์ ํ
๋ฐ, NodePort๋ก ์์ ํ๊ธฐ
...
ExternalDNS๋ ํด๋ฌ์คํฐ ๋ด์์ DNS ๋ ์ฝ๋๋ฅผ ์๋์ผ๋ก ์์ฑํ๊ณ ์
๋ฐ์ดํธํ๋ ๋๊ตฌ์ด๋ค. ์ด๋ฅผ ํตํด ์ฟ ๋ฒ๋คํฐ์ค ๋ฆฌ์์ค์ธ Ingress ํน์ Service์ IP ์ฃผ์ ๋๋ LoadBalancer ์ฃผ์๋ฅผ Route 53 ๋ฑ์ DNS ์ ๊ณต์์ ์๋์ผ๋ก ๋ฑ๋กํ์ฌ, ๋๋ฉ์ธ ์ด๋ฆ์ ํตํด ํด๋ฌ์คํฐ ๋ด ์๋น์ค์ ์ ๊ทผํ ์ ์๊ฒ ํ๋ค.
์ธ๋ถ์ ์ธ ๋จ๊ณ๋ ๋ค์๊ณผ ๊ฐ์ผ๋ฉฐ, ExternalDNS์ ๊ณต์ ํํ ๋ฆฌ์ผ์ ์ฐธ๊ณ ํ์ฌ ์งํํ์๋ค.

๋์ ๊ฒฝ์ฐ greenhead.blog ๋๋ฉ์ธ์ด ์ด๋ฏธ Route 53์ ๋ฑ๋ก๋์ด ์๊ณ , HTTPS ํต์ ์ ์ํ SSL ์ธ์ฆ์๋ฅผ ACM์ ํตํด ์์ฑ๋ ์ํ์ด๋ค.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"route53:ChangeResourceRecordSets"
],
"Resource": [
"arn:aws:route53:::hostedzone/*"
]
},
{
"Effect": "Allow",
"Action": [
"route53:ListHostedZones",
"route53:ListResourceRecordSets",
"route53:ListTagsForResource"
],
"Resource": [
"*"
]
}
]
}์ JSON ์ฝ๋๋ฅผ policy.json์ด๋ผ๋ ์ด๋ฆ์ผ๋ก ์ ์ฅํ๋ค. (์ด๋ฆ์ ์๊ด์๋ค)
aws iam create-policy --policy-name "AllowExternalDNSUpdates" --policy-document file://policy.json์ดํ ์ aws ๋ช
๋ น์ด๋ฅผ ์คํํ์ฌ AllowExternalDNSUpdates๋ผ๋ ์ด๋ฆ์ IAM ์ ์ฑ
์ ์์ฑํ๋ฉด ๋๋ค.
eksctl ๋ช
๋ น์ด๋ฅผ ํตํด IAM ์ญํ ์ ์์ฑํ๋ค.
eksctl create iamserviceaccount \
--name external-dns-green-blog-co \
--namespace external-dns \
--cluster greenhead-cluster \
--attach-policy-arn arn:aws:iam::971490215356:policy/AllowExternalDNSUpdates \ # ์ ๋จ๊ณ์์ ์์ฑํ IAM ์ ์ฑ
์ ๋ํ ARN ์
๋ ฅ
--approve์ด์ ExternalDNS ๊ณต์ ๋ฌธ์์ โManifest (for cluster with RABC enalbed)โ์ ์์ฑ๋ ๋งค๋ํ์คํธ ํ์ผ์ ๊ธฐ์ค์ผ๋ก ExternalDNS ๊ตฌ์ฑ์ ์์ฑํ์ฌ ํด๋ฌ์คํฐ์ ๋ฐฐํฌํ๋ฉด ๋๋ค.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: external-dns-green-blog-co
rules:
- apiGroups: [""]
resources: ["services","endpoints","pods"]
verbs: ["get","watch","list"]
- apiGroups: ["extensions","networking.k8s.io"]
resources: ["ingresses"]
verbs: ["get","watch","list"]
- apiGroups: [""]
resources: ["nodes"]
verbs: ["list"]
- apiGroups: ["networking.istio.io"]
resources: ["gateways", "virtualservices"]
verbs: ["get","watch","list"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: external-dns-green-blog-co
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: external-dns-green-blog-co
subjects:
- kind: ServiceAccount
name: external-dns-green-blog-co
namespace: external-dns
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: external-dns-green-blog-co
namespace: external-dns
spec:
selector:
matchLabels:
app: external-dns-green-blog-co
strategy:
type: Recreate
template:
metadata:
labels:
app: external-dns-green-blog-co
spec:
serviceAccountName: external-dns-green-blog-co
containers:
- name: external-dns-green-blog-co
image: registry.k8s.io/external-dns/external-dns:v0.14.0
args:
- --source=service
- --source=ingress
- --source=istio-gateway
- --source=istio-virtualservice
- --domain-filter=green-blog.co # ๋๋ฉ์ธ ์ด๋ฆ
- --provider=aws
- --policy=upsert-only
- --aws-zone-type=public
- --registry=txt
- --txt-owner-id=Z06833101WGBT1HIY3N6H # ํธ์คํ
์์ญ ID--txt-owner-id๋ Route 53์ ํธ์คํ
์์ญ ID ๊ฐ์ ์ฌ์ฉํ๋ค.
์์ฑํ yaml ํ์ผ์ external-dns.yaml ์ด๋ผ๋ ์ด๋ฆ์ผ๋ก ์ ์ฅํ๊ณ , kubectl ๋ช
๋ น์ด๋ฅผ ํตํด ํด๋ฌ์คํฐ์ ๋ฐฐํฌํ๋ฉด ๋๋ค.
kubectl apply -f external-dns.yamlIngress๋ ์ด์ ํฌ์คํธ์์ ๋ค๋ฃฌ Deployment, Service์ ๊ฐ์ ์ฟ ๋ฒ๋คํฐ์ค ๋นํธ์ธ ๋ฆฌ์์ค ์ค ํ๋๋ก, ์ฟ ๋ฒ๋คํฐ์ค ์ธ๋ถ์์ ๋ด๋ถ ์๋น์ค๋ก์ HTTP(S) ํธ๋ํฝ์ ๋ผ์ฐํ
ํ๋ ์ญํ ์ ํ๋ค.
๋ค๋ง Ingress๋ ํธ๋ํฝ์ ์ด๋ป๊ฒ ๋ผ์ฐํ
ํ ์ง์ ๋ํ ๊ท์น์ ์ ์ํ๊ธฐ๋ง ํ ๋ฟ, ์ค์ ๋ก ํธ๋ํฝ์ ์ฒ๋ฆฌํ๋ ค๋ฉด Ingress Controller๋ผ๋ ๊ฒ์ด ํ์ํ๋ค. Nginx, Traefik ๋ฑ ๋ค์ํ Ingress Controller๊ฐ ์กด์ฌํ๋ค๊ณ ํ๋ฉฐ, ์ ๋จ๊ณ์์ ์ค์นํ istio-ingressgateway ๋ํ Ingress Controller์ด๋ค.
์ด์ Ingress ๋งค๋ํ์คํธ ํ์ผ์ ์์ฑํด๋ณด์.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: istio-ingress-green-blog-co
namespace: istio-system # istiod, istio-ingressgateway๊ฐ ์ค์น๋ ๋ค์์คํ์ด์ค๋ก ๋ง์ถ๊ธฐ
annotations:
alb.ingress.kubernetes.io/scheme: internet-facing # ALB๋ฅผ ์ธ๋ถ์ ๋
ธ์ถ์์ผ ์ ๊ทผํ ์ ์๋๋ก ์ค์
alb.ingress.kubernetes.io/certificate-arn: "[green-blog.co์ ๋ํ SSL ์ธ์ฆ์์ ARN์ ์ฌ๊ธฐ์ ์
๋ ฅ]"
alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS":443}]'
alb.ingress.kubernetes.io/actions.ssl-redirect: '{"Type": "redirect", "RedirectConfig": { "Protocol": "HTTPS", "Port": "443", "StatusCode": "HTTP_301"}}'
external-dns.alpha.kubernetes.io/hostname: "green-blog.co" # ๋๋ฉ์ธ ์ด๋ฆ
spec:
ingressClassName: alb
rules:
- http: # http๋ https๋ก ๋ฆฌ๋ค์ด๋ ์
๋๋ฏ๋ก, http ํ๋๋ง ์์ฑํ๋ค.
paths:
- path: /
pathType: Prefix
backend:
service:
name: ssl-redirect
port:
name: use-annotation
- path: /
pathType: Prefix
backend:
service:
name: istio-ingressgateway
port:
number: 80
- path: /
pathType: Prefix
backend:
service:
name: istio-ingressgateway
port:
number: 443์ Ingress ๋งค๋ํ์คํธ ํ์ผ์ ๋ค์๊ณผ ๊ฐ์ ๊ท์น์ ์ ์ํ๊ณ ์๋ค.
green-blog.co ๋๋ฉ์ธ์ ๋ํ SSL ์ธ์ฆ์๋ฅผ ์ฌ์ฉํ์ฌ HTTPS๋ฅผ ์ค์ green-blog.co ๋๋ฉ์ธ์ ๋ํ ExternalDNS ์ค์ ์ ์istio-ingressgateway ์๋น์ค๋ก ๋ผ์ฐํ
(์ดํ ๋ค๋ฃฐ Gateway ์ค์ ๊ณผ ๋ฐ์ ํ ๊ด๋ จ)์ด ์ค์ ์ ํตํด ์ธ๋ถ์์ green-blog.co ๋๋ฉ์ธ์ผ๋ก ๋ค์ด์ค๋ ์์ฒญ์ด ALB๋ฅผ ํตํด Istio Ingress Gateway๋ก ์ ๋ฌ๋๋ฉฐ, HTTP ์์ฒญ์ HTTPS๋ก ๋ฆฌ๋ค์ด๋ ํธ๋๋ค.
Gateway์ VirtualService๋ Deployment, Service์ ๊ฐ์ ์ฟ ๋ฒ๋คํฐ์ค ๋นํธ์ธ ๋ฆฌ์์ค๊ฐ ์๋๋ผ Istio์์ ์ ๊ณตํ๋ ์จ๋ํํฐ ๋ฆฌ์์ค์ด๋ค.
๊ฐ๊ฐ์ ๋ค์์ ์ญํ ์ ์ํํ๋ค.
๋งค๋ํ์คํธ ์์ฑ(๋ฐฐํฌ) ์์๋ Gateway โก๏ธ VirtualService ์์ด๋ค.
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: green-blog-co-gateway
namespace: green-blog-co
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "green-blog.co"์์ ๊ฐ์ด ์์ฑ ํ ํด๋ฌ์คํฐ์ Gateway๋ฅผ ๋ฐฐํฌํ๋ฉด ๋ก๋ ๋ฐธ๋ฐ์๊ฐ ์์ฑ๋๋ค.
์์ฑ๋ ๋ก๋ ๋ฐธ๋ฐ์์ DNS ์ด๋ฆ์ ์ดํ VirtualService๋ฅผ ์์ฑํ ๋ ํ์ํ๋ค.
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: green-blog-co-virtual-service
namespace: green-blog-co
annotations: # ์ ๋จ๊ณ์์ ์์ฑ๋ ๋ก๋ ๋ฐธ๋ฐ์์ DNS ์ด๋ฆ์ ์๋ ํ๋์ ์์ฑํ๋ค.
external-dns.alpha.kubernetes.io/target: "k8s-istiosys-istioing-5a5c0fc93a-784634683.ap-northeast-2.elb.amazonaws.com"
spec:
hosts:
- "green-blog.co"
gateways:
- green-blog-co-gateway
http:
- match:
- uri:
prefix: /
route:
- destination:
host: green-blog-co-service
port:
number: 3000 # green-blog-co-service์ ์ด๋ ค์๋ ํฌํธ ๋ฒํธ์ด๋ฅผ ํตํด ์น ์ ํ๋ฆฌ์ผ์ด์ ์ Github Actions + ECR + EKS๋ฅผ ์ฌ์ฉํ์ฌ ๋ฐฐํฌํ ๋์ ๊ฒฝํ์ ์ ๋ถ ์ ๋ฆฌํ์๋ค.
ํ๋ก ํธ์๋ ๊ฐ๋ฐ์๊ฐ ์ค๋ฌด์์ ์ค์ ๋ก ์ธํ๋ผ ์ค์ ์ ๋ค๋ฃจ๊ฒ ๋๋ ๊ฒฝ์ฐ๋ ๋๋ฌผ ํ ์ง๋ง, ์ด ๊ฒฝํ์ ํตํด์ ์ฌ๋ด ์น ์ ํ๋ฆฌ์ผ์ด์ ์ด ์ด๋ป๊ฒ ๋ฐฐํฌ๋๋ ์ง์ ๋ํ ์ ์ฒด์ ์ธ ํ๋ฆ์ ๊น๊ฒ ์ดํดํ ์ ์์๊ธฐ ๋๋ฌธ์ ๋ฐฐ์ฐ๋ฉด์ ์ ๋ง ์ฆ๊ฑฐ์ ๋ค.
์ฌ์ค ์ฌ๊ธฐ์ ๋๋ด๊ธฐ์ ์ฝ๊ฐ ์์ฌ์ด ๋ถ๋ถ์ ์๋ค. ์ด ์ ๋๋ง์ผ๋ก๋ ์์ ํ ๋ฐฐํฌ ์๋ํ๊ฐ ๋์ง ์๊ธฐ ๋๋ฌธ์ด๋ค. ์ง์ ํ Push To Deploy๋ฅผ ๊ตฌํํ๊ธฐ ์ํด์๋ ๋งค๋ํ์คํธ ํ์ผ์ ๋ณ๊ฒฝ์ ๊ฐ์งํ์ฌ ์ด๋ฅผ ํด๋ฌ์คํฐ์ ์ ์ฉํ๋ ArgoCD๋ผ๋ ๋๊ตฌ๋ ๋ค๋ค์ผ ํ๊ธฐ ๋๋ฌธ์ด๋ค.
ArgoCD๋ฅผ ๋ค๋ค๋ณธ ๊ฒฝํ์ ์ธ์ ๊ฐ ์ฌ์ ๊ฐ ๋๋ฉด ์ถ๊ฐ๋ก ์์ฑํด๋ณด๊ธฐ๋ก ํ๊ฒ ๋ค.. ๐ซก