5.16. 제품 내보내기

소스 3scale 인스턴스와의 연결이 없는 3scale 인스턴스로 해당 제품을 가져올 수 있도록 3scale 제품 정의를 .yaml 형식으로 내보낼 수 있습니다. 3scale 제품을 설정해야 해당 제품을 내보낼 수 있습니다. API 호출을 테스트하기 위해 새 제품 생성 을 참조하십시오.

두 개의 3scale 인스턴스에 네트워크 연결이 있는 경우 3scale 인스턴스에서 동일한 3scale 제품을 사용하려는 경우 toolbox 3scale copy 명령을 사용하십시오.

설명

3scale 제품을 내보내면 toolbox는 제품 및 백엔드 CRD(사용자 정의 리소스 정의)를 준수하는 .yaml 형식으로 제품 정의를 직렬화합니다. output. yaml에는 제품의 기본 정보와 함께 다음이 포함됩니다.

  • 제품에 연결된 백엔드입니다.
  • 연결된 백엔드에 대한 지표, 메서드 및 매핑 규칙.
  • 애플리케이션 계획에 정의된 제한 및 가격 결정 규칙.
  • 제한 및 가격 규칙에 따라 참조되는 지표 및 방법.

제품 내보내기는 읽기 전용 작업입니다. 즉, 제품을 반복적으로 내보내는 것이 안전합니다. toolbox는 내보낼 제품을 변경하지 않습니다. 원하는 경우 .yaml 출력을 다른 3scale 인스턴스로 가져오기 전에 수정할 수 있습니다.

3scale 제품 내보내기는 다음과 같은 상황에 적합합니다.

  • 소스와 대상 3scale 인스턴스 간에는 연결이 없습니다. 예를 들어 2개 이상의 3scale 인스턴스에서 동일한 제품을 사용하려는 경우 toolbox 3scale copy 명령을 실행하지 않는 심각한 네트워크 제한이 있을 수 있습니다.
  • Git 또는 일부 기타 소스 제어 시스템을 사용하여 3scale 제품 정의를 .yaml 형식으로 유지 관리하려고 합니다.

3scale toolbox 내보내기가져오기 명령은 제품 정의를 백업하고 복원하는 데에도 유용할 수 있습니다.

형식

export 명령을 실행하려면 이 형식을 사용하십시오.

3scale product export [-f output-file] <remote> <product>

export 명령은 출력을 stdout 또는 파일에 전송할 수 있습니다. 기본값은 stdout 입니다. 출력을 파일로 보내려면. yaml 파일 이름으로 -f 또는 --file 옵션을 지정합니다.

<remote> 를 제품을 내보낼 3scale 인스턴스와 연결된 3scale 공급자 계정 별칭 또는 URL로 바꿉니다. 이 값을 지정하는 방법에 대한 자세한 내용은 원격 액세스 자격 증명 관리를 참조하십시오.

<product> 를 시스템 이름 또는 내보낼 제품의 3scale ID로 바꿉니다. 이 제품은 지정한 3scale 공급자 계정과 연결되어야 합니다. 제품의 시스템 이름은 제품 개요 페이지의 3scale GUI에서 확인할 수 있습니다. 제품의 3scale ID를 가져오려면 toolbox 3scale services show 명령을 실행합니다.

예제

다음 명령은 my-3scale-1 공급자 계정과 연결된 3scale 인스턴스에서 petstore 제품을 내보내고 petstore-product.yaml 파일에 출력합니다.

3scale product export -f petstore-product.yaml my-3scale-1 petstore

다음은 Default API 제품에 대한 직렬화 예입니다.

apiVersion: v1
kind: List
items:
- apiVersion: capabilities.3scale.net/v1beta1
  kind: Product
  metadata:
    annotations:
      3scale_toolbox_created_at: '2021-02-17T10:59:23Z'
      3scale_toolbox_version: 0.17.1
    name: api.xysnalcj
  spec:
    name: Default API
    systemName: api
    description: ''
    mappingRules:
    - httpMethod: GET
      pattern: "/v2"
      metricMethodRef: hits
      increment: 1
      last: false
    metrics:
      hits:
        friendlyName: Hits
        unit: hit
        description: Number of API hits
    methods:
      servicemethod01:
        friendlyName: servicemethod01
        description: ''
    policies:
    - name: apicast
      version: builtin
      configuration: {}
      enabled: true
    applicationPlans:
      basic:
        name: Basic
        appsRequireApproval: false
        trialPeriod: 0
        setupFee: 0.0
        custom: false
        state: published
        costMonth: 0.0
        pricingRules:
        - from: 1
          to: 1000
          pricePerUnit: 1.0
          metricMethodRef:
            systemName: hits
        limits:
        - period: hour
          value: 1222222
          metricMethodRef:
            systemName: hits
            backend: backend_01
    backendUsages:
      backend_01:
        path: "/v1/pets"
      backend_02:
        path: "/v1/cats"
    deployment:
      apicastSelfManaged:
        authentication:
          oidc:
            issuerType: rest
            issuerEndpoint: https://hello:test@example.com/auth/realms/3scale-api-consumers
            jwtClaimWithClientID: azp
            jwtClaimWithClientIDType: plain
            authenticationFlow:
              standardFlowEnabled: false
              implicitFlowEnabled: true
              serviceAccountsEnabled: false
              directAccessGrantsEnabled: true
            credentials: query
            security:
              hostHeader: ''
              secretToken: some_secret
            gatewayResponse:
              errorStatusAuthFailed: 403
              errorHeadersAuthFailed: text/plain; charset=us-ascii
              errorAuthFailed: Authentication failed
              errorStatusAuthMissing: 403
              errorHeadersAuthMissing: text/plain; charset=us-ascii
              errorAuthMissing: Authentication parameters missing
              errorStatusNoMatch: 404
              errorHeadersNoMatch: text/plain; charset=us-ascii
              errorNoMatch: No Mapping Rule matched
              errorStatusLimitsExceeded: 429
              errorHeadersLimitsExceeded: text/plain; charset=us-ascii
              errorLimitsExceeded: Usage limit exceeded
        stagingPublicBaseURL: http://staging.example.com:80
        productionPublicBaseURL: http://example.com:80
- apiVersion: capabilities.3scale.net/v1beta1
  kind: Backend
  metadata:
    annotations:
      3scale_toolbox_created_at: '2021-02-17T10:59:34Z'
      3scale_toolbox_version: 0.17.1
    name: backend.01.pcjwxbdu
  spec:
    name: Backend 01
    systemName: backend_01
    privateBaseURL: https://b1.example.com:443
    description: new desc
    mappingRules:
    - httpMethod: GET
      pattern: "/v1/pets"
      metricMethodRef: hits
      increment: 1
      last: false
    metrics:
      hits:
        friendlyName: Hits
        unit: hit
        description: Number of API hits
    methods:
      mybackendmethod01:
        friendlyName: mybackendmethod01
        description: ''
- apiVersion: capabilities.3scale.net/v1beta1
  kind: Backend
  metadata:
    annotations:
      3scale_toolbox_created_at: '2021-02-17T10:59:34Z'
      3scale_toolbox_version: 0.17.1
    name: backend.02.tiedgjsk
  spec:
    name: Backend 02
    systemName: backend_02
    privateBaseURL: https://b2.example.com:443
    description: ''
    mappingRules:
    - httpMethod: GET
      pattern: "/v1/cats"
      metricMethodRef: hits
      increment: 1
      last: false
    metrics:
      hits:
        friendlyName: Hits
        unit: hit
        description: Number of API hits
    methods:
      backend02_method01:
        friendlyName: backend02_method01
        description: ''

제품 CR 내보내기 및 파이핑

내보내기 명령을 실행하면 출력을 파이프하여 제품 사용자 정의 리소스(CR) 를 생성할 수 있습니다. 이 CR이 포함된 3scale 인스턴스는 다음에 따라 다릅니다.

  • 3scale-provider-account 시크릿이 정의된 경우 3scale 운영자는 해당 시크릿으로 식별된 3scale 인스턴스에 product CR을 생성합니다.
  • 3scale-provider-account 시크릿이 정의되지 않은 경우 새 제품 CR이 있는 네임스페이스에 3scale 인스턴스가 설치되면 3scale 운영자가 해당 네임스페이스에 제품 CR을 생성합니다.
  • 3scale-provider-account 시크릿이 정의되지 않고 새 제품 CR이 있는 네임스페이스에 3scale 인스턴스가 포함되지 않은 경우 3scale 운영자는 제품 CR을 실패 상태로 표시합니다.

3scale-provider-account 시크릿을 포함하는 네임스페이스에서 다음 명령을 실행하도록 가정합니다. toolbox는 petstore CR을 threescale -provider-account 보안에서 식별된 3scale 인스턴스에 파이프합니다.

3scale product export my-3scale-1 petstore | oc apply -f -

자세한 내용은 3scale Operator가 사용자 정의 리소스 링크가 있는 테넌트를 식별하는 방법을 참조하십시오.