11.6. WasmPlugin 사용자 정의 리소스 생성


서비스 메시는 WasmPlugin 이라는 사이드카 프록시에 Proxy-WASM 확장을 지정하고 적용하는 CRD(사용자 정의 리소스 정의)를 제공합니다. 서비스 메시는 3scale을 사용한 HTTP API 관리가 필요한 워크로드 세트에 CR(사용자 정의 리소스)을 적용합니다.

절차

  1. 이 모듈을 적용할 Service Mesh 배포에서 OCP(OpenShift Container Platform) 네임스페이스(예: info 프로젝트)를 식별합니다.
  2. registry.redhat.io 인증 정보를 사용하여 풀 시크릿을 가져옵니다.

    • WasmPlugin 과 동일한 네임스페이스에 새 풀 시크릿 리소스를 생성합니다.
  3. 모듈이 적용할 애플리케이션 집합을 식별하는 선택기와 함께 3scale-wasm-auth 모듈이 배포된 네임스페이스를 선언해야 합니다. 다음 예제는 threescale-wasm-auth 모듈에 대한 CR의 YAML 형식입니다.

    apiVersion: extensions.istio.io/v1alpha1
    kind: WasmPlugin
    metadata:
      name: <threescale_wasm_plugin_name>
     namespace: <namespace>
    spec:
      url: oci://registry.redhat.io/3scale-amp2/3scale-auth-wasm-rhel8:0.0.3
      imagePullSecret: <pull_secret_resource>
      phase: AUTHZ
      priority: 100
      match:
       - mode: CLIENT
      selector:
        matchLabels:
          app: <selector>
      pluginConfig:
        api: v1
        system:
          name: system
          upstream:
            name: outbound|443||<system_host>
            url: <system_url>
            timeout: 5000
          token: <access_token>
    
        backend:
          name: backend
          upstream:
            name: outbound|<backend_port>||<backend_host>
            url: <backend_url>
            timeout: 5000
          extensions:
          - no_body
        services:
        - id: '<product_id>'
          authorities:
          - "*"
          credentials:
            user_key:
              - query_string:
                  keys:
                    - user_key
              - header:
                  keys:
                    - user_key
    • spec.pluginConfig 필드는 애플리케이션에 따라 다릅니다. 기타 모든 필드는 이 사용자 정의 리소스의 여러 인스턴스에서 유지됩니다.
    • 특히 WasmPlugin spec.pluginConfig 는 쿼리 문자열에 제공된 user_key 인증으로 구성됩니다.
    • 설명:

      • name: 3scale 내에서 WasmPlugin 의 고유 이름 또는 식별자를 지정합니다.
      • namespace: 워크로드의 네임스페이스입니다.
      • imagePullSecret: 2단계에서 생성한 풀 시크릿의 이름입니다.
      • selector: 워크로드 라벨 선택기입니다. info 프로젝트의 productpage를 사용합니다.
      • backend-port: 사용 중인 3scale에 따라 다릅니다. Service Mesh에 3scale URL 추가를 참조하십시오. 예를 들어 내부 3scale 포트 80을 사용하고 외부 3scale은 포트 443을 사용합니다.
      • backend-host,system-host: Service Mesh에 3scale URL 추가에 사용한 것과 동일한 호스트를 사용합니다.
      • system-url,backend-url: 각각의 호스트를 사용하고 프로토콜을 추가합니다. 예를 들면 https://<system-host>입니다.
      • access-token: 시스템 테넌트에 대한 액세스 토큰입니다.
      • product_id: 사용하려는 제품의 ID입니다. 여러 제품을 사용하려면 services 섹션에서 여러 제품을 정의합니다.
    • spec.pluginConfig 및 나머지 사용자 정의 리소스에 모듈 구성이 있으면 oc apply 명령을 사용하여 적용합니다.

      $ oc apply -f threescale-wasm-auth-info.yaml

11.6.1. 3scale WasmPlugin 인증 옵션

다음은 3scale 사용자 키(App id/App 키) 인증에 대한 구성의 예입니다.

사용자 키

apiVersion: extensions.istio.io/v1alpha1
kind: WasmPlugin
metadata:
  name: <threescale_wasm_plugin_name>
spec:
 ...
  pluginConfig:
  ...
    services:
    - id: '<service_id>'
      authorities:
      - "*"
      credentials:
        user_key:
          - query_string:
              keys:
                - user_key
          - header:
              keys:
                - user_key

앱 ID 및 앱 키

apiVersion: extensions.istio.io/v1alpha1
kind: WasmPlugin
metadata:
  name: <threescale_wasm_plugin_name>
spec:
  ...
  pluginConfig:
    ...
    services:
    - id: '<service_id>'
      authorities:
      - "*"
      credentials:
        app_id:
          - query_string:
              keys:
                - app_id
          - header:
              keys:
                - app_id
        app_key:
          - query_string:
              keys:
                - app_key
          - header:
              keys:
                - app_key

OIDC

WasmPlugin 자체 외에도 OpenID Connect(OIDC)가 작동하려면 RequestAuthentication 이라는 추가 사용자 정의 리소스도 필요합니다. RequestAuthentication 을 적용하면 JWT 토큰을 검증하기 위해 기본 플러그인으로 Envoy 를 구성합니다. 프록시는 모듈을 실행하기 전에 모든 것을 검증하므로 실패하는 요청이 3scale WebAssembly 모듈로 만들지 않습니다.

apiVersion: security.istio.io/v1beta1
kind: RequestAuthentication
metadata:
  name: jwt-example
  namespace: <info>
spec:
  selector:
    matchLabels:
      app: <productpage>
  jwtRules:
  - issuer: >-
      "<url>/auth/realms/<realm_name>"
    jwksUri: >-
      "<url>/auth/realms/<realm_name>/protocol/openid-connect/certs"

설명

  • <URL>: keycloak로 구성된 경우 인증 구성을 위한 keycloak OIDC 공급자의 메타데이터 끝점을 지정하는 데 사용되는 URL 및 OIDC 인스턴스의 URL입니다.
  • < realm_name > : OIDC에서 사용되는 영역의 이름입니다.
apiVersion: extensions.istio.io/v1alpha1
kind: WasmPlugin
metadata:
  name: <threescale_wasm_plugin_name>
spec:
  ...
  pluginConfig:
    ...
    services:
    - id: '<service_id>'
      authorities:
      - "*"
      credentials:
  app_id:
    - filter:
        path:
          - envoy.filters.http.jwt_authn
          - "0"
        keys:
          - azp
          - aud
        ops:
          - take:
              head: 1
Red Hat logoGithubRedditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

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

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

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

Red Hat 소개

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

© 2024 Red Hat, Inc.