1.18.11. 페더레이션 메시에서 서비스 내보내기


서비스 내보내기를 통해 메시는 하나 이상의 서비스를 페더레이션 메시의 다른 멤버와 공유할 수 있습니다.

서비스 메시 페더레이션에서 서비스 예시

ExportedServiceSet 리소스를 사용하여 페더레이션 메시의 다른 피어에 사용할 수 있는 하나의 메시에서 서비스를 선언합니다. 피어와 공유하려면 각 서비스를 명시적으로 선언해야 합니다.

  • 네임스페이스 또는 이름별로 서비스를 선택할 수 있습니다.
  • 와일드카드를 사용하여 서비스를 선택할 수 있습니다(예: 네임스페이스의 모든 서비스를 내보내려면).
  • 별칭을 사용하여 서비스를 내보낼 수 있습니다. 예를 들어 foo/bar 서비스를 custom-ns/bar 로 내보낼 수 있습니다.
  • 메시의 시스템 네임스페이스에 표시되는 서비스만 내보낼 수 있습니다. 예를 들어 networking.istio.io/exportTo 레이블이 '.'로 설정된 다른 네임스페이스의 서비스는 내보내기 후보가 아닙니다.
  • 내보낸 서비스의 경우 대상 서비스는 원래 요청자가 아닌 수신 게이트웨이의 트래픽만 볼 수 있습니다(즉, 다른 메시의 송신 게이트웨이 또는 워크로드 또는 요청의 클라이언트 ID를 볼 수 없음).

다음 예제는 red-meshgreen-mesh 로 내보내는 서비스에 대한 것입니다.

ExportedServiceSet 리소스의 예

kind: ExportedServiceSet
apiVersion: federation.maistra.io/v1
metadata:
  name: green-mesh
  namespace: red-mesh-system
spec:
  exportRules:
  # export ratings.mesh-x-bookinfo as ratings.bookinfo
  - type: NameSelector
    nameSelector:
      namespace: red-mesh-bookinfo
      name: red-ratings
      alias:
        namespace: bookinfo
        name: ratings
  # export any service in red-mesh-bookinfo namespace with label export-service=true
  - type: LabelSelector
    labelSelector:
      namespace: red-mesh-bookinfo
      selector:
        matchLabels:
          export-service: "true"
      aliases: # export all matching services as if they were in the bookinfo namespace
      - namespace: "*"
        name: "*"
        alias:
          namespace: bookinfo

Expand
표 1.10. ExportedServiceSet 매개변수
매개변수설명
metadata: name:

이 서비스를 노출하는 ServiceMeshPeer의 이름입니다.

ServiceMeshPeer 리소스에서 메시의 name 값과 일치해야 합니다.

metadata: namespace:

이 리소스가 포함된 프로젝트/네임스페이스의 이름(메쉬의 시스템 네임스페이스여야 함)

 
spec: exportRules: - type:

이 서비스의 내보내기를 제어하는 규칙 유형입니다. 서비스에 대해 발견된 첫 번째 일치 규칙이 내보내기에 사용됩니다.

NameSelector, LabelSelector

spec: exportRules: - type: NameSelector nameSelector: namespace: name:

NameSelector 규칙을 생성하려면 Service 리소스에 정의된 대로 서비스의 namespace 와 서비스 name을 지정합니다.

 
spec: exportRules: - type: NameSelector nameSelector: alias: namespace: name:

서비스에 대한 별칭을 사용하는 NameSelector 규칙을 생성하려면 서비스에 대한 namespacename을 지정한 후 namespace 의 별칭과 서비스 name에 사용할 별칭을 지정합니다.

 
spec: exportRules: - type: LabelSelector labelSelector: namespace: <exportingMesh> selector: matchLabels: <labelKey>: <labelValue>

LabelSelector 규칙을 생성하려면 서비스의 namespace를 지정하고 Service 리소스에 정의된 label 을 지정합니다. 위의 예에서 레이블은 export-service 입니다.

 
spec: exportRules: - type: LabelSelector labelSelector: namespace: <exportingMesh> selector: matchLabels: <labelKey>: <labelValue> aliases: - namespace: name: alias: namespace: name:

서비스에 대한 별칭을 사용하는 LabelSelector 규칙을 생성하려면 selector를 지정한 후 서비스의 name 또는 namespace에 사용할 별칭을 지정합니다. 위의 예에서 네임스페이스 별칭은 일치하는 모든 서비스에 대해 bookinfo 입니다.

 

이름이 "ratings"인 서비스를 빨간색-mesh에 있는 모든 네임스페이스에서 blue-mesh로 내보냅니다.

kind: ExportedServiceSet
apiVersion: federation.maistra.io/v1
metadata:
  name: blue-mesh
  namespace: red-mesh-system
spec:
  exportRules:
  - type: NameSelector
    nameSelector:
      namespace: "*"
      name: ratings

west-data-center 네임스페이스의 모든 서비스를 green-mesh로 내보냅니다.

kind: ExportedServiceSet
apiVersion: federation.maistra.io/v1
metadata:
  name: green-mesh
  namespace: red-mesh-system
spec:
  exportRules:
  - type: NameSelector
    nameSelector:
      namespace: west-data-center
      name: "*"

1.18.11.1. ExportedServiceSet 생성

ExportedServiceSet 리소스를 생성하여 메시 피어에서 사용할 수 있는 서비스를 명시적으로 선언합니다.

서비스는 <export-name>.<export-namespace>.svc.<ServiceMeshPeer.name>-exports.local로 내보내지며 대상 서비스로 자동으로 라우팅됩니다. 내보낸 서비스는 내보낸 메시에서 알려진 이름입니다. 수신 게이트웨이가 이 이름에 대한 요청을 수신하면 내보낼 실제 서비스로 라우팅됩니다. 예를 들어 ratings.red-mesh-bookinfo 라는 서비스가 ratings.bookinfogreen-mesh 로 내보내지면 서비스는 ratings.bookinfo.svc.green-mesh-exports.local 에서 내보내지고 해당 호스트 이름에 대해 수신 게이트웨이에서 수신한 트래픽이 ratings.red-mesh-bookinfo 서비스로 라우팅됩니다.

참고

로컬 서비스와 함께 원격 끝점을 집계하려면 importAsLocal 매개변수를 true 로 설정하면 서비스에 대한 별칭을 사용해야 합니다. 매개변수를 false 로 설정하면 별칭이 필요하지 않습니다.

사전 요구 사항

  • 메시 페더레이션을 위해 클러스터 및 ServiceMeshControlPlane 이 구성되어 있습니다.
  • cluster-admin 역할이 있는 계정.
참고

아직 존재하지 않는 경우에도 내보내기를 위해 서비스를 구성할 수 있습니다. ExportedServiceSet에 지정된 값과 일치하는 서비스가 배포되면 자동으로 내보내집니다.

CLI의 프로세스

명령줄에서 ExportedServiceSet 을 생성하려면 다음 절차를 따르십시오.

  1. cluster-admin 역할의 사용자로 AWS CLI에서 Red Hat OpenShift Service에 로그인합니다. 다음 명령을 입력합니다. 메시지가 표시되면 사용자 이름과 암호를 입력합니다.

    $ oc login --username=<NAMEOFUSER> <API token> https://<HOSTNAME>:6443
  2. Service Mesh Control Plane을 설치한 프로젝트(예: red-mesh-system )로 변경합니다.

    $ oc project red-mesh-system
  3. red-meshgreen-mesh 로 서비스를 내보내는 다음 예제를 기반으로 ExportedServiceSet 파일을 만듭니다.

    red-mesh에서 green-mesh로 ExportedServiceSet 리소스의 예

    apiVersion: federation.maistra.io/v1
    kind: ExportedServiceSet
    metadata:
      name: green-mesh
      namespace: red-mesh-system
    spec:
      exportRules:
      - type: NameSelector
        nameSelector:
          namespace: red-mesh-bookinfo
          name: ratings
          alias:
            namespace: bookinfo
            name: red-ratings
      - type: NameSelector
        nameSelector:
          namespace: red-mesh-bookinfo
          name: reviews

  4. 다음 명령을 실행하여 red-mesh-system 네임스페이스에 ExportedServiceSet 리소스를 업로드하고 생성합니다.

    $ oc create -n <ControlPlaneNamespace> -f <ExportedServiceSet.yaml>

    예를 들면 다음과 같습니다.

    $ oc create -n red-mesh-system -f export-to-green-mesh.yaml
  5. 페더레이션 메시의 각 메시 피어에 대해 필요에 따라 추가 ExportedServiceSets 를 생성합니다.

검증

  • 다음 명령을 실행하여 green-mesh와 공유할 red-mesh 내보내기를 서비스에 검증합니다.

    $ oc get exportedserviceset <PeerMeshExportedTo> -o yaml

    예를 들면 다음과 같습니다.

    $ oc -n red-mesh-system get exportedserviceset green-mesh -o yaml

    녹색 메시와 공유되는 빨간색 메시에서 내보낸 서비스 검증의 예.

      status:
        exportedServices:
        - exportedName: red-ratings.bookinfo.svc.green-mesh-exports.local
          localService:
            hostname: ratings.red-mesh-bookinfo.svc.cluster.local
            name: ratings
            namespace: red-mesh-bookinfo
        - exportedName: reviews.red-mesh-bookinfo.svc.green-mesh-exports.local
          localService:
            hostname: reviews.red-mesh-bookinfo.svc.cluster.local
            name: reviews
            namespace: red-mesh-bookinfo

    status.exportedServices 배열은 현재 내보낸 서비스( ExportedServiceSet 오브젝트의 내보내기 규칙과 일치)를 나열합니다. 배열의 각 항목은 내보낸 서비스의 이름과 내보낸 로컬 서비스에 대한 세부 정보를 나타냅니다.

    내보낸 서비스가 누락된 경우 Service 오브젝트가 있는지, 해당 이름 또는 레이블이 ExportedServiceSet 오브젝트에 정의된 exportRules 와 일치하며 Service 오브젝트의 네임스페이스가 ServiceMeshMemberRoll 또는 ServiceMeshMember 오브젝트를 사용하여 서비스 메시의 멤버로 구성되어 있는지 확인합니다.

Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 소개

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

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

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

Red Hat 문서 정보

Legal Notice

Theme

© 2026 Red Hat
맨 위로 이동