이번 시간에는 istio 버전을 업그레이드 하는 방법에 대해 알아보자. istio 공식 문서를 보면 업그레이드 방식은 in-place와 canary로 총 두 가지가 있으며 권장되는 방식인 canary 업그레이드에 대해 자세히 알아보자.
in-place
in-place는 istiod와 gateway를 업그레이드하고 sidecar를 업그레이드 하는 방식이다.
공식문서에서는 in-place 업그레이드 방식을 사용하면 업그레이드 중에 트래픽 중단이 발생할 수 있다고 한다. 중단을 최소화 하기 위해서 istiod의 레플리카를 최소 두 개 이상으로 설정하는 것이 좋다고 한다. 그리고 --revision
플래그로 설치를 한 것과 호환이 되지 않는다고 한다. in-place 방식보다는 canary 방식이 권장되는 방식이라고 한다.
canary
canary는 기존 버전의 istiod를 남겨둔 채 새 버전의 istiod를 추가한 뒤 gateway 및 sidecar를 업그레이드 하고 마지막으로 기존 istiod를 지운다.
canary 업그레이드를 할 때 가장 중요한 것은 revision인데, revision은 컨트롤 플레인과 데이터 플레인 각각 가지고 있으며, 컨트롤 플레인은 자신의 revision과 같은 revision의 데이터 플레인만 제어한다. 위의 그림에서 1-23-4 revision을 가지고 있는 istiod는 1-24-3 revision을 가지고 있는 Gateway 및 Sidecar의 envoy 구성을 관리하지 않고 오직 1-23-4 revision을 가진 Gateway 및 Sidecar의 envoy 구성만을 관리한다.
이러한 특성 때문에 canary 업그레이드를 할 때는 일단 업그레이드 기간 동안은 기존 revision의 istiod와 신규 revision의 istiod를 같이 띄운 다음에 모든 데이터플레인을 신규 revision의 istiod에게 관리 받도록 revision을 업그레이드 한 뒤 기존 revision의 istiod를 제거한다.
여기서 revision은 istio의 버전으로 명시했다고 하자. (ex. revision = 1-23-4 라면 실제 istio 버전은 1.23.4)
Upgrade with Helm
만약 Helm으로 istio를 관리한다면 Canary 업그레이드를 다음과 같이 진행하면 된다. 공식문서상 업그레이드 시 두 개의 마이너 버전을 건너뛰는 것이 지원된다고 한다. (세 개 이상의 마이너 버전을 건너뛰는 것은 권장하지 않음)
1. helm repo update
최신의 istio helm 버전을 받기 위해 helm repo를 업데이트한다.
$ helm repo update
2. 버전 호환성 체크
버전이 변경되는 경우, istio Custom Resource의 스펙이 변경되거나 deprecated 되거나 deprecated 될 예정이 있는지 확인해봐야 한다. 만약 변경할 버전으로 업그레이드 시 deprecated 되는 스펙이 있는데 변경을 하지 않는다면 정상 동작을 하지 않을 것이기 때문이다.
간단히 istioctl 명령어로 버전 호환성을 체크할 수 있다.
$ istioctl x precheck
그리고 공식문서의 upgrade note를 확인하여 자세한 변경사항을 확인해보는 것이 좋다.
Istio 1.24 Upgrade Notes
Important changes to consider when upgrading to Istio 1.24.0.
istio.io
3. istio-base 업그레이드
그 다음은 먼저 istio-base 차트 버전을 업그레이드 한다.
$ helm upgrade istio-base istio/base -n istio-system -f base.yaml --version 1.24.3
ArgoCD로 관리하고 있다면 Application에서 helm targetRevision 값을 변경하면 된다.
4. 신규 버전의 istiod 설치
그 다음은 신규 버전의 istiod를 설치하면 된다. 새로운 values.yaml 파일을 하나 만들고 (기존 것 복사) revision
값만 변경하면 된다.
istiod-1-24-3.yaml
revision: "1-24-3"
# istiod 리소스 설정
pilot:
autoscaleMin: 1
autoscaleMax: 2
resources:
requests:
cpu: 100m
memory: 256Mi
limits:
memory: 256Mi
meshConfig:
accessLogFile: /dev/stdout
# istio-proxy sidecar 리소스 설정
proxy:
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 1000m
memory: 128Mi
$ helm install istiod-1-24-3 istio/istiod \
-f istiod-1-24-3.yaml \
-n istio-system \
--version 1.24.3
설치가 끝나면 다음과 같이 istiod가 두개 떠있는 것을 확인할 수 있다.
$ kubectl get po
NAME READY STATUS RESTARTS AGE
egressgateway-5f9ff7cd78-76994 1/1 Running 1 (106m ago) 18h
ingressgateway-8db6fffbb-4b5k4 1/1 Running 1 (106m ago) 18h
ingressgateway-8db6fffbb-xhbp6 1/1 Running 1 (106m ago) 18h
istiod-1-23-4-7fc896c7cf-gjfw4 1/1 Running 1 (106m ago) 18h
istiod-1-24-3-667988df57-tf2sp 1/1 Running 0 24s
그리고 다음 명령어를 입력하면 현재 클러스터에 있는 revision 종류를 확인할 수 있다. 두개 revision이 있으면 성공
$ istioctl tag list
TAG REVISION NAMESPACES
1-23-4
1-24-3
5. ingressgateway / egressgateway 카나리 배포
그 다음은 ingressgateway를 카나리 업그레이드를 하여 버전을 변경해보자. 일단 기존 ingressgateway values.yaml 파일을 복사하여 새로운 파일을 생성한 다음 다음과 같이 변경한다.
ingressgateway-canary.yaml
revision: "1-24-3" # 변경
# 서비스는 기존 ingressgateway의 서비스를 사용
service:
type: None
# 기존 ingressgateway의 서비스의 셀렉터에 포함되도록 레이블 설정 (기존 ingressgateway 서비스 레이블 셀렉터 미리 확인)
labels:
app: ingressgateway
istio: ingressgateway
# Canary 배포 갯수는 원하는대로 설정
autoscaling:
minReplicas: 2
maxReplicas: 3
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 1000m
memory: 128Mi
$ helm install istio-ingress-canary istio/gateway \
-f ingressgateway-canary.yaml \
-n istio-ingress \
--version 1.24.3
카나리 버전을 설치하고 나면 다음과 같이 파드가 뜨고, 기존 ingressgateway의 엔드포인트에도 같이 잡혀있는 것을 확인할 수 있다.
$ kubectl get po -L istio -L app -L istio.io/rev
NAME READY STATUS RESTARTS AGE ISTIO APP REV
egressgateway-5f9ff7cd78-76994 1/1 Running 1 (135m ago) 18h egressgateway egressgateway 1-23-4
ingressgateway-8db6fffbb-4b5k4 1/1 Running 1 (134m ago) 18h ingressgateway ingressgateway 1-23-4
ingressgateway-8db6fffbb-xhbp6 1/1 Running 1 (135m ago) 18h ingressgateway ingressgateway 1-23-4
ingressgateway-canary-cd6f8b9c-47mvm 1/1 Running 0 12m ingressgateway ingressgateway 1-24-3
ingressgateway-canary-cd6f8b9c-bl422 1/1 Running 0 12m ingressgateway ingressgateway 1-24-3
istiod-1-23-4-7fc896c7cf-gjfw4 1/1 Running 1 (135m ago) 18h istiod istiod 1-23-4
istiod-1-24-3-667988df57-tf2sp 1/1 Running 0 29m istiod istiod 1-24-3
운영 후 어느정도 검증이 완료되면 기존 ingressgateway 버전을 업그레이드 하고 canary 버전을 없애면 된다.
$ helm upgrade -i istio-ingress istio/gateway \
-f ingressgateway-canary.yaml \
-n istio-ingress \
--version 1.24.3
$ helm uninstall istio-ingress-canary
같은 방식으로 egressgateway도 업그레이드 한다.
데이터 플레인 버전을 업그레이드 하는 경우, 업그레이드가 완료되면 다음 명령어로 데이터 플레인을 관리하고 있는 istiod를 확인할 수 있다.
$ istioctl proxy-status
NAME CLUSTER CDS LDS EDS RDS ECDS ISTIOD VERSION
details-v1-85c67dd97d-kftbf.bookinfo Kubernetes SYNCED (43s) SYNCED (43s) SYNCED (43s) SYNCED (43s) IGNORED istiod-1-23-4-7fc896c7cf-gjfw4 1.23.4
egressgateway-69b554d76c-z4dr2.istio-system Kubernetes SYNCED (43s) SYNCED (43s) SYNCED (43s) IGNORED IGNORED istiod-1-24-3-667988df57-tf2sp 1.24.3
ingressgateway-57888cf49f-n5swh.istio-system Kubernetes SYNCED (43s) SYNCED (43s) SYNCED (43s) SYNCED (43s) IGNORED istiod-1-24-3-667988df57-tf2sp 1.24.3
ingressgateway-57888cf49f-vrf2h.istio-system Kubernetes SYNCED (43s) SYNCED (43s) SYNCED (43s) SYNCED (43s) IGNORED istiod-1-24-3-667988df57-tf2sp 1.24.3
productpage-v1-656664f7d4-jcbdr.bookinfo Kubernetes SYNCED (43s) SYNCED (43s) SYNCED (43s) SYNCED (43s) IGNORED istiod-1-23-4-7fc896c7cf-gjfw4 1.23.4
ratings-v1-56b4856d5d-g5qk5.bookinfo Kubernetes SYNCED (43s) SYNCED (43s) SYNCED (43s) SYNCED (43s) IGNORED istiod-1-23-4-7fc896c7cf-gjfw4 1.23.4
reviews-v1-7f56fcbc94-v8ckq.bookinfo Kubernetes SYNCED (43s) SYNCED (43s) SYNCED (43s) SYNCED (43s) IGNORED istiod-1-23-4-7fc896c7cf-gjfw4 1.23.4
reviews-v2-7bdbbf6fb-kqjmn.bookinfo Kubernetes SYNCED (43s) SYNCED (43s) SYNCED (43s) SYNCED (43s) IGNORED istiod-1-23-4-7fc896c7cf-gjfw4 1.23.4
reviews-v3-6654dcd8d6-6fwdl.bookinfo Kubernetes SYNCED (43s) SYNCED (43s) SYNCED (43s) SYNCED (43s) IGNORED istiod-1-23-4-7fc896c7cf-gjfw4 1.23.4
todo-api-5559bd5b56-bwg26.todo Kubernetes SYNCED (43s) SYNCED (43s) SYNCED (43s) SYNCED (43s) IGNORED istiod-1-23-4-7fc896c7cf-gjfw4 1.23.4
- 지금은 ingressgateway 및 egressgateway만 업그레이드 했기 때문에 gateway는 1.24.3의 istiod가, 사이드카는 1.23.4 버전의 istiod가 관리한다.
6. 사이드카 버전 업그레이드
사이드카 버전을 업그레이드하는 방법은 auto-injection을 사용하는 각 네임스페이스별로 istio-injection
레이블을 제거하고 istio.io/rev
레이블을 업그레이드 할 revision으로 변경한 뒤에 파드를 재배포하면 된다.
$ kubectl label ns bookinfo istio-injection- istio.io/rev=1-24-3 --overwrite
$ kubectl rollout restart deploy -n bookinfo
재배포 후 istioctl proxy-status
명령어로 버전 업그레이드가 되었는지 확인하자.
$ istioctl proxy-status
NAME CLUSTER CDS LDS EDS RDS ECDS ISTIOD VERSION
details-v1-5ddb6c7665-ql6x7.bookinfo Kubernetes SYNCED (3m1s) SYNCED (3m1s) SYNCED (6s) SYNCED (3m1s) IGNORED istiod-1-24-3-667988df57-tf2sp 1.24.3
egressgateway-69b554d76c-z4dr2.istio-system Kubernetes SYNCED (8m28s) SYNCED (8m28s) SYNCED (6s) IGNORED IGNORED istiod-1-24-3-667988df57-tf2sp 1.24.3
ingressgateway-85bdd9669f-9zw6x.istio-system Kubernetes SYNCED (110s) SYNCED (110s) SYNCED (6s) SYNCED (110s) IGNORED istiod-1-24-3-667988df57-tf2sp 1.24.3
ingressgateway-85bdd9669f-k29wz.istio-system Kubernetes SYNCED (114s) SYNCED (114s) SYNCED (6s) SYNCED (114s) IGNORED istiod-1-24-3-667988df57-tf2sp 1.24.3
productpage-v1-654b77ddb5-4qkpq.bookinfo Kubernetes SYNCED (2m59s) SYNCED (2m59s) SYNCED (6s) SYNCED (2m59s) IGNORED istiod-1-24-3-667988df57-tf2sp 1.24.3
ratings-v1-9fdf47c5c-b5vsp.bookinfo Kubernetes SYNCED (3m) SYNCED (3m) SYNCED (6s) SYNCED (3m) IGNORED istiod-1-24-3-667988df57-tf2sp 1.24.3
reviews-v1-9b4f88f5c-fdxkr.bookinfo Kubernetes SYNCED (3m1s) SYNCED (3m1s) SYNCED (6s) SYNCED (3m1s) IGNORED istiod-1-24-3-667988df57-tf2sp 1.24.3
reviews-v2-8585dd8db7-nm2tp.bookinfo Kubernetes SYNCED (3m1s) SYNCED (3m1s) SYNCED (6s) SYNCED (3m1s) IGNORED istiod-1-24-3-667988df57-tf2sp 1.24.3
reviews-v3-846b967df-tj2dv.bookinfo Kubernetes SYNCED (3m1s) SYNCED (3m1s) SYNCED (6s) SYNCED (3m1s) IGNORED istiod-1-24-3-667988df57-tf2sp 1.24.3
todo-api-5b7f4798c6-95hfg.todo Kubernetes SYNCED (2m58s) SYNCED (2m58s) SYNCED (6s) SYNCED (2m58s) IGNORED istiod-1-24-3-667988df57-tf2sp 1.24.3
7. 기존 istiod 제거
모든 데이터플레인 업그레이드가 완료되었으면 기존 istiod는 삭제해도 좋다.
$ helm uninstall istiod-1-23-4
8. istio-base defaultRevision 변경
마지막으로 istio-base의 defaultRevision을 현재 revision으로 변경하면 완료이다.
base.yaml
defaultRevision: "1-24-3"
$ helm upgrade istio-base istio/base -n istio-system -f base.yaml --version 1.24.3
'DevOps > Istio' 카테고리의 다른 글
istio EnvoyFilter에 대해 알아보자. (0) | 2025.03.03 |
---|---|
istio와 envoy proxy 세부적으로 파악해보기 (0) | 2025.02.20 |
istio traffic 관리 (3) [Egress Gateway] (0) | 2025.01.18 |
istio traffic 관리 (2) [Gateway] (0) | 2025.01.13 |
istio traffic 관리 (1) [VirtualService & DestinationRule] (0) | 2025.01.12 |
댓글