https://istio.io/latest/docs/setup/install/operator/
해당 istio 공식문서 가이드에 따라 istio를 설치 할 경우 istio는 잘 설치 되나 특정 요구사항을 충족시키기엔 좀 어렵다.
필자의 경우 특정 노드에 배포 하고 싶거나 ingress-gateway pod를 2개 이상 배포하고 싶었는데 어떻게 설정을 했는지 공유하고자 한다.
아래 설정코드는 istioctl 명령어로 istio operator를 사용하여 istio를 설치하는 코드인데 기본값으로 설정 할 경우 ingress-gateway pod나 istiod 배포 시 HAP resource도 같이 배포가 되어 deployment resource에서 replicas 사이즈를 조정을 해도 다시 롤백이 되는 현상이 발생한다.
해당 이슈는 autoscaleEnabled
값을 비활성화 하여 해결할 수 있다.
추가로 nodeSelector를 통해 특정 노드에 pod를 생성하도록 지정할 수 있다.
apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
metadata:
namespace: istio-system
spec:
tag: 1.16.1
components:
# Istio Gateway feature
ingressGateways:
- name: istio-ingressgateway
enabled: true
k8s:
replicaCount: 3
nodeSelector:
node-role.kubernetes.io/ingress: "true"
pilot:
k8s:
replicaCount: 1
nodeSelector:
node-role.kubernetes.io/ingress: "true"
hpaSpec:
minReplicas: 1
maxReplicas: 1
values:
global:
defaultNodeSelector:
node-role.kubernetes.io/ingress: "true"
base:
enableCRDTemplates: false
validationURL: ''
defaultRevision: ''
gateways:
istio-ingressgateway:
autoscaleEnabled: false # when it sets "true", crate HPA resource
env: {}
name: istio-ingressgateway
replicaCount: 3
secretVolumes:
- mountPath: /etc/istio/ingressgateway-certs
name: ingressgateway-certs
secretName: istio-ingressgateway-certs
- mountPath: /etc/istio/ingressgateway-ca-certs
name: ingressgateway-ca-certs
secretName: istio-ingressgateway-ca-certs
type: NodePort
# 설치
istioctl_v1.16.1 install --set profile=default -f ./istio_v1.16.1.yaml
# 삭제(istio 관련 리소스들이 다 삭제되니 주의 필요)
istioctl_v1.16.1 uninstall --purge
istio operator로 설치하면 기본적으로 autoscaleEnabled
이 활성화되어 있는데, 위에서 언급한 것 처럼 deployment에서 replicas를 조정하면 다시 원복되는 현상이 발생한다.
kube-controller-manager
pod에서 관련 로그를 확인할 수 있다.
# kube-controller-manager 로그
> I0426 00:02:34.426771 1 event.go:294] "Event occurred" object="istio-system/istio-ingressgateway"
fieldPath="" kind="HorizontalPodAutoscaler" apiVersion="autoscaling/v2" type="Normal"
reason="SuccessfulRescale" message="New size: 1; reason: All metrics below target"