본문 바로가기

Cloud/Oracle Cloud Infrastructure (OCI)

OCI상에서 ISTIO를 활용하여 구현한 Service Mesh - #5. 이스티오 데모 - 이스티오 설치, 엔보이 프록시 주입

Oracle Cloud Infrastructure (OCI) 에서 이스티오(ISTIO)를 활용한 서비스 메쉬(Service Mesh)에 대한 기술 정리 및 이를 데모로 구현한 내용을 정리합니다.

글 순서

1. Overview

2. 이스티오 작동 방식

3. 이스티오 데모 - 사전 준비

4. 이스티오 데모 - 쿠버네티스 대쉬보드 설치/설정

5. 이스티오 데모 - 이스티오 설치, 엔보이 프록시 주입

6. 이스티오 데모 - 샘플 어플리케이션 (Bookinfo) 배포

7. 이스티오 데모 - 카나리 배포

8. 이스티오 데모 - 결함 주입(Fault Injection)

9. 이스티오 데모 - 서비스 시각화 (프로메테우스)

10. 이스티오 데모 - 서비스 시각화 (그라파나)

11. 이스티오 데모 - 서비스 시각화 (키알리)

12. 이스티오 데모 - 서비스 시각화 (예거)

 

REFERENCES

아래 도서 및 사이트를 참조하여 작성한 문서입니다.

  • 도메인 주도 설계로 시작하는 마이크로 서비스 개발 (위키북스)
  • 쿠버네티스 완벽 가이드 (길벗)
  • Istio로 시작하는 서비스 메시 (에이콘)
  • Isitio Documentation

 

이스티오 설치

다음 명령으로 이스티오를 다운로드 받습니다. 아래에서는 최신 이스티오 버전을 받았으나, “curl -L https://istio.io/downloadIstio | ISTIO_VERSION=1.6.0 TARGET_ARCH=x86_64 sh -” 와 같이 특정 버전을 지정해서 받을 수도 있습니다.

[opc@demo ~]$ curl -L <https://istio.io/downloadIstio> | sh -
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   101  100   101    0     0    171      0 --:--:-- --:--:-- --:--:--   171
100  4926  100  4926    0     0   5930      0 --:--:-- --:--:-- --:--:--  5930

Downloading istio-1.14.1 from <https://github.com/istio/istio/releases/download/1.14.1/istio-1.14.1-linux-amd64.tar.gz> ...

Istio 1.14.1 Download Complete!

Istio has been successfully downloaded into the istio-1.14.1 folder on your system.

Next Steps:
See <https://istio.io/latest/docs/setup/install/> to add Istio to your Kubernetes cluster.

To configure the istioctl client tool for your workstation,
add the /home/opc/istio-1.14.1/bin directory to your environment path variable with:
         export PATH="$PATH:/home/opc/istio-1.14.1/bin"

Begin the Istio pre-installation check by running:
         istioctl x precheck

Need more information? Visit <https://istio.io/latest/docs/setup/install/>
[opc@demo ~]$ ls
bin      Documents  istio-1.14.1  lib    nginx-lb.yaml                   Pictures  Templates
Desktop  Downloads  kubectl       Music  oke-admin-service-account.yaml  Public    Videos

 

이스티오 관리에 사용되는 istioctl 바이너리 경로를 환경변수에 아래와 같이 추가했습니다.

[opc@demo ~]$ cat .bash_profile
...

PATH=$PATH:$HOME/.local/bin:$HOME/bin:$HOME/istio-1.14.1/bin/

export PATH

...
[opc@demo ~]$ source .bash_profile

 

istioctl 명령이 수행되는 것을 알 수 있습니다.

[opc@demo ~]$ istioctl version
no running Istio pods in "istio-system"
1.14.1

 

이제 istioctl install 명령으로 이스티오를 설치합니다. demo 프로파일로 설치를 진행했습니다.

이스티오에서는 컨트롤 플레인과 데이터플레인 구성에 대한 내장된 아래 6개 설정 프로파일을 제공합니다. 여기에서는 이후 Bookinfo 어플리케이션을 사용 샘플로 사용할 것이므로 demo 프로파일을 적용했습니다.

  • default: 운영환경이나 멀티 클러스터 메시 환경에서 프라이머리 클러스터에 적합한 프로파일
  • demo: 적은 자원으로 이스티오 기능을 데모로 보여주도록 설계된 프로파일. Bookinfo 어플리케이션을 수행하는데 적합
  • minimal: default 프로파일과 동일하지만 컨트롤 플레인 컴포넌트만 설치된 프로파일
  • external: 외부 컨트롤 플레인 또는 멀티 클러스터 메시의 프라이머리 클러스터에 있는 컨트롤 플레인에 의해 관리되는 원격 클러스터 설정에 사용
  • empty: 아무것도 배포하지 않음. 사용자 정의 설정을 위한 기본 프로파일로 활용
  • preview: 이스티오에 도입될 신기능 적용를 위한 프로파일

 

[opc@demo ~]$ istioctl install --set profile=demo
This will install the Istio 1.14.1 demo profile with ["Istio core" "Istiod" "Ingress gateways" "Egress gateways"] components into the cluster. Proceed? (y/N) y
✔ Istio core installed
✔ Istiod installed
✔ Egress gateways installed
✔ Ingress gateways installed
✔ Installation complete                                                                                                                                Making this installation the default for injection and validation.

Thank you for installing Istio 1.14.  Please take a few minutes to tell us about your install/upgrade experience!  <https://forms.gle/yEtCbt45FZ3VoDT5A>

 

kubectl 명령을 통해 이스티오 관련 배포된 사항들을 확인합니다.

[opc@demo ~]$ kubectl -n istio-system get deploy
NAME                   READY   UP-TO-DATE   AVAILABLE   AGE
istio-egressgateway    1/1     1            1           17m
istio-ingressgateway   1/1     1            1           17m
istiod                 1/1     1            1           17m

 

이스티오 엔보이 프록시 주입(Injection)

엔보이 프록시를 파드에 주입하기 위한 방법은 자동과 수동 두가지 방법이 있습니다.

먼저 수동으로 하는 방식은 아래와 같이 istioctl kube-inject 명령을 수행하는 방식입니다. 이 경우 기존 매니페스트 파일에 엔보이 프록시를 추가하는 매니페스트를 자동으로 생성하게됩니다.

istioctl kube-inject -f [samples/sleep/sleep.yaml](<https://raw.githubusercontent.com/istio/istio/release-1.14/samples/sleep/sleep.yaml>) | kubectl apply -f -

 

또 다른 방식은 “istio-injection=enabled” 라벨을 네임스페이스에 설정하여 해당 네임스페이스에 파드가 생성되면 자동으로 엔보이 프록시가 함께 만들어지도록 하는 방법입니다. 여기에서는 자동으로 엔보이 프록시를 추가하도록 했습니다. 아래 명령을 수행합니다.

[opc@demo ~]$ kubectl label namespace default istio-injection=enabled --overwrite
namespace/default labeled

 

설정한 내용을 확인합니다. 디폴트 네임스페이스에 istio-injection이 활성화되어 있는 것을 알 수 있습니다.

[opc@demo ~]$ kubectl get namespaces -L istio-injection
NAME                   STATUS   AGE    ISTIO-INJECTION
default                Active   2d7h   enabled
kube-node-lease        Active   2d7h
kube-public            Active   2d7h
kube-system            Active   2d7h
kubernetes-dashboard   Active   25h

 

테스트를 위해 NGINX 컨테이너를 3개의 레플리카를 설정으로하여 생성해 보겠습니다. 매니페스트 파일의 내용은 아래와 같습니다.

[opc@demo ~]$ cat nginx-deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 3
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80

 

NGIX 컨테이너를 쿠버네티스에 배포합니다.

[opc@demo ~]$ kubectl apply -f nginx-deployment.yaml
deployment.apps/nginx-deployment created

 

컨테이너가 배포되었습니다. 아래는 쿠버네티스 대쉬보드에서 확인한 화면입니다.

 

배포 후 파드 정보를 보면, “현재 실행 중인 파드 수 / 디플로이먼트를 만들 때 설정한 파드 수” 정보를 나타내는 READY 칼럼이 2/2 로 나타나는 것을 알 수 있습니다. 엔보이 프록시가 자동으로 배치된 것을 알 수 있습니다. 어플리케이션이나 매니페스트를 변경하지 않아도 이스티오 엔보이 프록시가 배치되어 있습니다.

[opc@demo ~]$ kubectl get pods -o wide
NAME                               READY   STATUS    RESTARTS   AGE   IP             NODE          NOMINATED NODE   READINESS GATES
nginx-deployment-9456bbbf9-9rdwj   2/2     Running   0          28s   10.244.0.133   10.0.10.35    <none>           <none>
nginx-deployment-9456bbbf9-j7bvv   2/2     Running   0          28s   10.244.1.5     10.0.10.42    <none>           <none>
nginx-deployment-9456bbbf9-qksv8   2/2     Running   0          28s   10.244.0.8     10.0.10.234   <none>           <none>

 

파드에 대한 상세 정보를 kubectl describe 명령으로 보면, 파드에 주입된 istio-proxy 생성 이벤트를 확인할 수 있습니다.

[opc@demo ~]$ kubectl describe pod -l app=nginx
...
Events:
  Type    Reason     Age   From               Message
  ----    ------     ----  ----               -------
  Normal  Scheduled  27m   default-scheduler  Successfully assigned default/nginx-deployment-9456bbbf9-qksv8 to 10.0.10.234
  Normal  Pulled     27m   kubelet            Container image "docker.io/istio/proxyv2:1.14.1" already present on machine
  Normal  Created    27m   kubelet            Created container istio-init
  Normal  Started    27m   kubelet            Started container istio-init
  Normal  Pulled     27m   kubelet            Container image "nginx:1.14.2" already present on machine
  Normal  Created    27m   kubelet            Created container nginx
  Normal  Started    27m   kubelet            Started container nginx
  Normal  Pulled     27m   kubelet            Container image "docker.io/istio/proxyv2:1.14.1" already present on machine
  Normal  Created    27m   kubelet            Created container istio-proxy
  Normal  Started    27m   kubelet            Started container istio-proxy

 

<END>