3.2. Istio API를 사용하여 게이트웨이를 통해 송신 트래픽 전달


Istio API를 사용하여 게이트웨이 삽입을 사용하여 설치된 게이트웨이를 통해 아웃바운드 HTTP 트래픽을 전달합니다.

사전 요구 사항

  • 게이트웨이 삽입을 사용하여 게이트웨이를 설치했습니다.

프로세스

  1. 다음 명령을 실행하여 curl 이라는 네임스페이스를 생성합니다.

    $ oc create namespace curl
  2. 사용 중인 업데이트 전략에 따라 적절한 명령을 실행하여 네임스페이스에서 사이드카 삽입을 활성화합니다.

    1. InPlace 업데이트 전략을 사용하는 경우 다음 명령을 실행합니다.

      $ oc label namespace curl istio-injection=enabled
    2. RevisionBased 업데이트 전략을 사용하는 경우 다음 명령을 실행합니다.

      1. 다음 명령을 실행하여 버전 이름을 표시합니다.

        $ oc get istiorevisions.sailoperator.io

        출력 예

        NAME     TYPE    READY   STATUS    IN USE   VERSION   AGE
        default  Local   True    Healthy   True     v1.24.3   3m33s

      2. 다음 명령을 실행하여 버전 이름으로 네임스페이스에 라벨을 지정하여 사이드카 삽입을 활성화합니다.

        $ oc label namespace curl istio.io/rev=default
  3. 다음 명령을 실행하여 curl 애플리케이션을 배포합니다.

    $ oc apply -n curl -f https://raw.githubusercontent.com/openshift-service-mesh/istio/refs/heads/master/samples/curl/curl.yaml
  4. curl 포드 이름으로 초기화된 CURL_POD 환경 변수를 내보냅니다.

    $ export CURL_POD=$(oc get pod -n curl -l app=curl -o jsonpath='{.items[0].metadata.name}')
  5. 메시의 트래픽을 외부 서비스로 보내는 http-se.yaml 이라는 YAML 파일을 생성합니다. 다음 예제에서는 URL에 대한 ServiceEntry 를 정의합니다.

    설정 예

    apiVersion: networking.istio.io/v1
    kind: ServiceEntry
    metadata:
      name: egress-se
      namespace: curl
    spec:
      hosts:
        - docs.redhat.com
      ports:
        - number: 80
          name: http-port
          protocol: HTTP
      location: MESH_EXTERNAL
      resolution: DNS

  6. 다음 명령을 실행하여 YAML 파일을 적용합니다.

    $ oc apply -f http-se.yaml
  7. ServiceEntry 구성이 올바르게 적용되었는지 확인합니다. 다음 명령을 실행하여 이전 단계에서 지정한 호스트에 HTTP 요청을 보냅니다.

    $ oc exec "$CURL_POD" -n curl -c curl -- curl -sSL -o /dev/null -D - http://docs.redhat.com

    이 명령은 연결이 작동함을 나타내는 301 (redirect) 또는 200 (성공)과 같은 HTTP 상태 코드를 반환해야 합니다.

  8. 송신 게이트웨이 를 생성하고 메시에서 외부 서비스에 지정된 호스트로 트래픽을 라우팅하는 http-gtw.yaml 이라는 YAML 파일을 생성합니다.

    설정 예

    apiVersion: networking.istio.io/v1alpha3
    kind: Gateway
    metadata:
      name: egress-gw
      namespace: <gateway_namespace> # Namespace where the egress gateway is deployed
    spec:
      selector:
        istio: <gateway_name> # Selects the egress-gateway instance to handle this traffic
      servers:
        - port:
            number: 80
            name: http
            protocol: HTTP
          hosts:
            - docs.redhat.com # External service host, not a full URL.
    ---
    apiVersion: networking.istio.io/v1alpha3
    kind: DestinationRule
    metadata:
      name: egress-dr
      namespace: <gateway_namespace> # Namespace where the egress gateway is deployed
    spec:
      host: <gateway_name>.<gateway_namespace>.svc.cluster.local
      subsets:
        - name: rh-docs

  9. 다음 명령을 실행하여 YAML 파일을 적용합니다.

    $ oc apply -f http-gtw.yaml
  10. 송신 게이트웨이를 통해 외부 호스트로 애플리케이션 사이드카의 트래픽 흐름을 관리하기 위해 VirtualService 를 설정하는 http-vs.yaml 이라는 YAML 파일을 생성합니다.

    설정 예

    apiVersion: networking.istio.io/v1alpha3
    kind: VirtualService
    metadata:
      name: egress-vs
      namespace: curl # Namespace where the curl pod is running
    spec:
      hosts:
        - docs.redhat.com # External service host, not a full URL.
      gateways:
        - mesh
        - <gateway_namespace>/egress-gw # Egress gateway name defined in the file that you used in the previous step.
      http:
        - match:
            - gateways:
                - mesh
              port: 80
          route:
            - destination:
                host: <gateway_name>.<gateway_namespace>.svc.cluster.local
                subset: rh-docs
                port:
                  number: 80
              weight: 100
        - match:
            - gateways:
                - <gateway_namespace>/egress-gw # Egress gateway name defined in the file that you used in the previous step.
              port: 80
          route:
            - destination:
                host: docs.redhat.com
                port:
                  number: 80
              weight: 100

  11. 다음 명령을 실행하여 YAML 파일을 적용합니다.

    $ oc apply -f http-vs.yaml
  12. HTTP 요청을 URL에 다시 보냅니다.

    $ oc exec "$CURL_POD" -n curl -c curl -- curl -sSL -o /dev/null -D - http://docs.redhat.com

    터미널에 다음 출력과 유사한 정보가 표시되어야 합니다.

    출력 예

    ...
    HTTP/1.1 301 Moved Permanently
    ...
    location: <example_url>
    ...
    
    HTTP/2 200
    Content-Type: text/html; charset=utf-8

  13. 다음 명령을 실행하여 요청을 게이트웨이를 통해 라우팅되었는지 확인합니다.

    $ oc logs deployment/<gateway_name> -n <gateway_namespace> | tail -1
    참고

    이 확인 단계가 작동하려면 액세스 로깅을 활성화해야 합니다. spec.values.meshConfig.accessLogFile 필드를 Istio 리소스의 /dev/stdout 으로 설정하여 표준 출력에 대한 액세스 로깅을 활성화할 수 있습니다.

    터미널에 다음 출력과 유사한 정보가 표시되어야 합니다.

    출력 예

    [2024-11-07T14:35:52.428Z] "GET / HTTP/2" 301 - via_upstream - "-" 0 0 24 24 "10.128.2.30" "curl/8.11.0" "79551af2-341b-456d-b414-9220b487a03b" "docs.redhat.com" "23.55.176.201:80" outbound|80||docs.redhat.com 10.128.2.29:49766 10.128.2.29:80 10.128.2.30:38296 -

Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2026 Red Hat
맨 위로 이동