1.18.12. 페더레이션 메시로 서비스 가져오기


서비스를 가져오면 서비스 메시 내에서 다른 메시에서 내보낸 서비스를 명시적으로 지정할 수 있습니다.

서비스 메시 페더레이션 가져오기 서비스 예시

ImportedServiceSet 리소스를 사용하여 가져오기 서비스를 선택합니다. 메시 피어에서 내보낸 서비스만 메시에서 명시적으로 가져올 수 있습니다. 명시적으로 가져오지 않는 서비스는 메시 내에서 사용할 수 없습니다.

  • 네임스페이스 또는 이름별로 서비스를 선택할 수 있습니다.
  • 와일드카드를 사용하여 서비스를 선택할 수 있습니다(예: 네임스페이스로 내보낸 모든 서비스를 가져올 수 있습니다.
  • 레이블 선택기를 사용하여 내보내기를 위한 서비스를 선택할 수 있습니다. 이 서비스는 메시에 전역적으로 적용되거나 특정 멤버 네임스페이스로 범위가 지정될 수 있습니다.
  • 별칭을 사용하여 서비스를 가져올 수 있습니다. 예를 들어 custom-ns/bar 서비스를 other-mesh/bar 로 가져올 수 있습니다.
  • 사용자 정의 도메인 접미사를 지정할 수 있습니다. 이 접미사는 정규화된 도메인 이름에 대해 가져온 서비스의 name.namespace 에 추가됩니다(예: bar.other-mesh.imported.local ).

다음 예제는 green-mesh 에서 red-mesh 에서 내보낸 서비스를 가져오는 데 사용됩니다.

ImportedServiceSet의 예

kind: ImportedServiceSet
apiVersion: federation.maistra.io/v1
metadata:
  name: red-mesh #name of mesh that exported the service
  namespace: green-mesh-system #mesh namespace that service is being imported into
spec:
  importRules: # first matching rule is used
  # import ratings.bookinfo as ratings.bookinfo
  - type: NameSelector
    importAsLocal: false
    nameSelector:
      namespace: bookinfo
      name: ratings
      alias:
        # service will be imported as ratings.bookinfo.svc.red-mesh-imports.local
        namespace: bookinfo
        name: ratings

Expand
표 1.11. ImportedServiceSet 매개변수
매개변수설명
metadata: name:

서비스를 페더레이션 메시로 내보낸 ServiceMeshPeer의 이름입니다.

 
metadata: namespace:

ServiceMeshPeer 리소스(메쉬 시스템 네임스페이스)가 포함된 네임스페이스의 이름입니다.

 
spec: importRules: - type:

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

NameSelector

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

NameSelector 규칙을 생성하려면 내보낸 서비스의 namespacename을 지정합니다.

 
spec: importRules: - type: NameSelector importAsLocal:

로컬 서비스와 함께 원격 끝점을 집계하려면 true 로 설정합니다. true 서비스를 < name>.<namespace>.svc.cluster.local 로 가져오는 경우 true 인 경우 별칭이 필요합니다. false 인 경우 별칭이 필요하지 않습니다.

true/false

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

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

 

빨간색-mesh에서 blue-mesh로 "bookinfo/ratings" 서비스를 가져옵니다.

kind: ImportedServiceSet
apiVersion: federation.maistra.io/v1
metadata:
  name: red-mesh
  namespace: blue-mesh-system
spec:
  importRules:
  - type: NameSelector
    importAsLocal: false
    nameSelector:
      namespace: bookinfo
      name: ratings

red-mesh의 west-data-center 네임스페이스에서 green-mesh로 모든 서비스를 가져옵니다. 이러한 서비스는 <name>.west-data-center.svc.red-mesh-imports.local로 액세스할 수 있습니다.

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

1.18.12.1. ImportedServiceSet 생성

ImportedServiceSet 리소스를 생성하여 메시로 가져올 서비스를 명시적으로 선언합니다.

<exported-name>.<exported-namespace>.svc.<ServiceMeshPeer.name>.remote라는 이름으로 서비스를 가져옵니다. 이 서비스는 송신 게이트웨이 네임스페이스 내에서만 표시되고 내보낸 서비스의 호스트 이름과 연결되는 “숨겨진" 서비스입니다. 서비스는 <export-name>.<export-namespace>.<domainSuffix>로 로컬에서 사용할 수 있습니다. 여기서 domainSuffix 는 기본적으로 svc.<ServiceMeshPeer.name>-imports.local입니다. importAsLocaltrue 로 설정되어 있지 않으면 domainSuffixsvc.cluster.local 입니다. importAsLocalfalse 로 설정된 경우 가져오기 규칙의 도메인 접미사가 적용됩니다. 메시의 다른 서비스와 마찬가지로 로컬 가져오기를 처리할 수 있습니다. 내보낸 서비스의 원격 이름으로 리디렉션되는 송신 게이트웨이를 통해 자동으로 라우팅됩니다.

사전 요구 사항

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

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

프로세스

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

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

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

    $ oc project green-mesh-system
  3. green-mesh 가 이전에 red-mesh 에서 내보낸 서비스를 가져오는 다음 예제를 기반으로 ImportedServiceSet 파일을 만듭니다.

    red-mesh에서 green-mesh에 ImportedServiceSet 리소스의 예

    kind: ImportedServiceSet
    apiVersion: federation.maistra.io/v1
    metadata:
      name: red-mesh
      namespace: green-mesh-system
    spec:
      importRules:
      - type: NameSelector
        importAsLocal: false
        nameSelector:
          namespace: bookinfo
          name: red-ratings
          alias:
            namespace: bookinfo
            name: ratings

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

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

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

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

검증

  • 다음 명령을 실행하여 서비스가 green-mesh 로 가져왔는지 확인합니다.

    $ oc get importedserviceset <PeerMeshImportedInto> -o yaml

    예를 들어, 빨간색 메시에서 내보낸 서비스가 'green-mesh- system 네임 스페이스에서 importedserviceset/red-mesh' 오브젝트의 status 섹션을 사용하여 녹색 메시 로 가져왔는지 확인하는 예

    $ oc -n green-mesh-system get importedserviceset/red-mesh -o yaml

    status:
      importedServices:
      - exportedName: red-ratings.bookinfo.svc.green-mesh-exports.local
        localService:
          hostname: ratings.bookinfo.svc.red-mesh-imports.local
          name: ratings
          namespace: bookinfo
      - exportedName: reviews.red-mesh-bookinfo.svc.green-mesh-exports.local
        localService:
          hostname: ""
          name: ""
          namespace: ""

    위 예제에서는 localService 아래에 채워진 필드에 표시된 대로 ratings 서비스만 가져옵니다. reviews 서비스는 가져오기에 사용할 수 있지만 ImportedServiceSet 오브젝트의 importRules 와 일치하지 않기 때문에 현재 가져온 것은 아닙니다.

Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 소개

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

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

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

Red Hat 문서 정보

Legal Notice

Theme

© 2026 Red Hat
맨 위로 이동