본문 바로가기

Kubernetes

[kubernetes] istio 환경 구성

  • 서비스 메시란?
    • 애플리케이션에의 서비스 간 모든 통신을 처리하는 소프트웨어 계층
    • 컨테이너화된 마이크로서비스로 구성
    • 서비스 간 연결을 관리하기 위해 모니터링, 로깅, 추적, 트래픽 제어와 같은 새로운 기능을 제공
  • 서비스 메시의 이점
    • 서비스 검색
      • 자동화된 서비스 검색을 제공하여 서비스 엔드포인트 관리의 운영 부하를 줄임
    • 로드 밸런싱
      • 라운드 로빈, 최소 연결 또는 가중치 로드 밸런싱과 같은 다양한 알고리즘을 사용하여 요청을 여러 서비스 인스턴스에 지능적으로 분산
      • 리소스 활용도를 높이고 고가용성 및 확장성 보장
      • 성능 최적화 및 네트워크 통신 병목 현상 방지
    • 트래픽 관리
      • 요청 라우팅 및 트래픽 동작을 세밀하게 제어할 수 있는 고급 트래픽 관리 기능을 제공
      • 트래픽 분할
        • 들어오는 트래픽을 서로 다른 서비스 버전 또는 구성 간에 분할할 수 있음
        • 일부 트래픽을 업데이트된 버전에 전달하므로 변경 사항을 제어하고 점진적으로 적용 가능
          • 원활한 전환이 가능, 변경으로 인한 영향을 최소화할 수 있음
      • 미러링 요청
        • 기본 요청 흐름에 영향을 주지 않으면서 분석을 위해 테스트 또는 모니터링 서비스에 트래픽을 복제할 수 있음
      • 카나리 배포
        • 대부분의 사용자가 기존의 안정적인 버전을 계속 사용하면서 일부 사용자 또는 트래픽을 새 서비스 버전에 전달할 수 있음
      • 보안
        • 상호 TLS 암호화, 인증 및 권한 부여와 같은 보안 통신 기능을 제공
      • 모니터링
        • 포괄적인 모니터링 및 관찰성 기능을 제공하여 서비스의 상태, 성능 및 행동에 대한 인사이트를 도출할 수 있음

 

istio 환경 구성

  • isito 설치
curl -L https://istio.io/downloadIstio | sh -
cd istio-x.xx.x
export PATH=$PWD/bin:$PATH
istioctl install

kubectl get deployment -n istio-system

  • Istio manifest.yaml 파일 뽑는 명령어
istioctl manifest generate > 1.yaml
istioctl manifest generate -f samples/operator/pilot-k8s.yaml > 2.yaml
istioctl manifest diff 1.yaml 2.yaml
Differences in manifests are:


Object Deployment:istio-system:istiod has diffs:

spec:
  template:
    spec:
      containers:
        '[#0]':
          resources:
            requests:
              cpu: 500m -> 1000m
              memory: 2048Mi -> 4096Mi


Object HorizontalPodAutoscaler:istio-system:istiod has diffs:

spec:
  maxReplicas: 5 -> 10
  minReplicas: 1 -> 2

 

 

istio operator 환경 구성

  • Istio operator 란
    • Istio 설정을 파일로 관리하는 기능을 제공
  • Istio operator 설치
istioctl operator init
  • Istio operator 로그 확인 명령어
kubectl logs -f [Istio-operator name] -n istio-operator
  • Istio demo profile 코드로 설치
vi demo-istio-operator.yaml

apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
metadata:
  namespace: istio-system
  name: example-istiocontrolplane
spec:
  profile: demo
  
kubectl apply -f demo-istio-operator.yaml
  • Istio operator 로그 확인

  • 설치된 pod yaml파일로 확인 명령어
kubectl get pod istio-ingressgateway-9fc98cc99-ptlq6 -n istio-system -o yaml

yaml 파일을 통해 리소스 할당량 확인
      requests:
        cpu: 10m
        memory: 40Mi
  • Istio-ingressgateway 리소스 할당량 변경
vi demo-isto-operator.yaml

components 추가

apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
metadata:
  namespace: istio-system
  name: example-istiocontrolplane
spec:
  profile: demo
  components:
    ingressGateways:
    - name: istio-ingressgateway
      enabled: true
      k8s:
        resources:
	        #limits:
		        #cpu: 3000m
		        #memory: 1Gib
          requests:
            cpu: 50m
            memory: 400Mi
            
kubectl apply -f demo-isto-operator.yaml

cpu: 10m -> 50m
memory: 40Mi -> 400Mi

 

 

사이드카 환경 구성

  • 사이드카란?
    • 프록시 서버 ( 논리적으로 각 서비스 옆에 있기 때문에 사이드카라고 부름 )
  • 매뉴얼하게 deployment가 정의된 서비스에 사이드카 배포
    • Istioctl를 통해 배포
istioctl kube-inject -f deployment.yaml | kubectl apply -f -

  • 자동으로 namespace label에 inject 적용
    • kubectl 통해 배포
kubectl label namespace [namespace] istio-injection=enabled

  • 자동으로 namespace label에 inject 적용된 곳에서 pod 배포시 적용 안되게 하는 방법
pod의 annotation에서 수정

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
  namespace: istio-test
  labels:
    app: nginx
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
        sidecar.istio.io/inject: "false" -> 추가
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80

'Kubernetes' 카테고리의 다른 글

[Kubernetes]istio - bookinfo 실습 및 Kiali 설정  (0) 2024.10.16