구성 가능한 API 프록시 만들기

이 페이지는 ApigeeApigee Hybrid에 적용됩니다.

Apigee Edge 문서 보기

구성 가능한미리보기 API 프록시를 사용하면 Apigee 사용자가 Kubernetes 리소스 모델과 비슷한 선언적 구성을 사용하여 간단한 프록시를 만들고 배포할 수 있습니다. 이 페이지에서는 구성 가능한 프록시를 만들고 새로운 보관 기반 배포 메커니즘을 사용하여 배포하는 데 필요한 단계를 설명합니다.

구성 가능한미리보기 API 프록시에 대한 자세한 내용은 구성 가능한 API 프록시를 참조하세요.

구성 가능한 미리보기 API 프록시 개발은 Apigee 유료 정기 결제 조직의 고객에게만 제공됩니다. 종량제 조직이 있는 Apigee 고객은 프로그래밍 가능한 API 프록시를 만들 수 있습니다.

시작하기 전에

이 튜토리얼에서는 이미 Apigee 조직을 프로비저닝하고 Apigee를 설치했다고 가정합니다. 그렇지 않으면 계속하기 전에 Apigee를 설치하고 구성하는 데 필요한 단계에 대한 프로비저닝 소개를 참조하세요.

이 튜토리얼을 시작하기 전에 다음 추가 단계를 완료하세요.

  1. Cloud SDK가 머신에 다운로드되고 설치되었는지 확인합니다.

    Cloud SDK 다운로드

  2. gcloud 구성요소를 업데이트합니다.
    gcloud components update
  3. 구성 가능한 API 프록시에 대한 환경을 프로비저닝하는 데 필요한 Apigee 사용자 인증 정보와 조직 세부정보를 확인합니다.

Apigee 환경 프로비저닝

프록시 구성을 만들기 전에 구성 가능한 프록시를 지원하는 Apigee 환경을 프로비저닝해야 합니다. 환경은 조직의 API 프록시 및 공유 흐름에 대한 런타임 실행 컨텍스트입니다. 환경에 액세스하려면 API 프록시를 환경에 배포해야 합니다. API 프록시를 단일 환경 또는 여러 환경에 배포할 수 있습니다.

자세한 내용은 환경 및 환경 그룹 정보를 참조하세요.

To create a new environment in the UI:

  1. Open the Apigee UI in a browser.
  2. Select Admin > Environments > Overview in the left navigation menu.

    The UI displays a set of cards, each one representing an existing environment:

    Environment cards

    If this is your first time accessing the Environment view, there will be no environments.

  3. Click +ENVIRONMENT.

    The New environment dialog box displays:

    New Environment dialog

  4. Enter the following information in the New Environment dialog box:
    1. Display name: A friendly name for the environment that is used in the UI. For example, My Test Environment.
    2. Environment name: The programmatic name for the environment. This value will be part of the request URL for your API proxies and should not contain any spaces or other special characters. It can only letters, numbers, and hyphens. For example, my-environment-1.

      The new environment's name cannot be changed after it has been created.

    3. Description (optional): Additional information about the environment that you want to add as a reminder.
    4. Deployment type (Preview): Select Archive as the deployment type.

    All fields except Description are required.

  5. Click OK.

    The card displays Pending Provisioning status while Apigee creates the new environment, as the following example shows:

    Pending provisioning label

    There can be a several minute delay before the new environment is provisioned.

    When it's done, the Apigee UI displays the new environment as a card with other environments that you have created:

    Environment cards

Apigee 인스턴스에 환경 연결

새 환경을 만든 후에는 액세스할 수 있도록 Apigee 인스턴스에 새 환경을 연결해야 합니다. 이 작업은 새 인스턴스를 만들 때 UI를 통해 수행할 수 있습니다(환경이 이미 있는 경우). 이 경우 이전에 인스턴스를 만든 경우 인스턴스 연결 만들기 API를 사용하여 새 환경을 연결할 수 있습니다.

프로세스의 예시는 명령줄 프로비저닝 문서의 환경 만들기를 참조하세요.

이 튜토리얼에서는 다음 명령어를 사용할 수 있습니다.

operation_name=$(curl -s -H "Authorization:Bearer $(gcloud auth print-access-token)" \
  "https://apigee.googleapis.com/v1/organizations/PROJECT_ID/instances/INSTANCE_NAME/attachments" \
  -X POST -H "content-type:application/json"\
  -d '{"environment":"ENV_NAME"}' | jq -r '.name' )

각 항목의 의미는 다음과 같습니다.

  • PROJECT_ID는 Apigee 환경이 생성된 Cloud 프로젝트의 ID입니다. Apigee 조직 이름과 동일해야 합니다.
  • INSTANCE_NAME은 Apigee 인스턴스의 이름입니다.
  • ENV_NAME은 구성 가능한 API 프록시가 배포될 환경의 이름입니다.

이렇게 하면 장기 실행 작업이 반환됩니다. 작업이 done: true로 표시될 때까지 다음 명령어를 사용하여 작업을 폴링할 수 있습니다.

curl -s -H "Authorization:Bearer $(gcloud auth print-access-token)" \
  "https://apigee.googleapis.com/v1/$operation_name"

환경 그룹 구성

환경 그룹(Apigee API에서는 envgroup이라고도 함)은 요청이 개별 환경으로 라우팅되는 방법을 정의하는 기본 메커니즘입니다. 호스트 이름은 개별 환경이 아닌 환경 그룹에서 정의하고 Apigee는 해당 호스트 이름 정의를 사용하여 그룹 내의 환경으로 요청을 라우팅합니다.

그룹에 할당되지 않은 환경에는 자신을 가리키는 호스트 이름이 없으므로 액세스할 수 없습니다. 자세한 내용은 환경 그룹 만들기를 참조하세요.

새 환경의 환경 그룹을 구성하려면 다음 안내를 따르세요.

  1. In the Apigee UI, select Admin > Environments > Groups.
  2. Click +Environment Group:

    Add environment button

    The Add an Environment Group dialog displays.

  3. Enter a name for your new environment group:

    Add environment group

    The name can contain only lower case letters, numbers, and hyphens. In addition, it must start with a letter, be at least two characters long, and cannot end with a hyphen. Valid names include my-env-group and prod2.

  4. Click Add.

    Apigee creates a new environment group. This is usually a very quick operation.

    On a successful operation, Apigee confirms that the group has been created with a banner that looks like the following:

    Group confirmation banner

    Apigee also assigns a default host name to the new group.

  5. (Optional) Assign additional host names to the new group by clicking for that group.

    Apigee displays the Environment group details pane:

    Environment group details

  6. Add host names to the Hostnames field. Each host name must be on a separate line.
  7. Click Save when you're done.

    You can add and remove host names to this list at any time using the same procedure.

프록시 보관 파일 만들기

구성 가능한미리보기 API 프록시 보관 파일을 만들려면 다음을 수행하세요.

  1. 로컬 환경에서 로컬 파일 시스템의 Apigee 작업공간을 저장할 디렉터리를 만듭니다. 이 디렉터리는 아래와 같이 구성 가능한 미리보기 API 프록시 파일 구조의 기반이 됩니다.
    .
    └── src
        └── main
            └── apigee
                ├── apiproxies
                │   ├── <proxy-name>
                │   │   └── config.yaml
                │   ├── <proxy-name>
                │   │   └── config.yaml
                └── environments
                    ├── <env-name>
                    │   ├── deployments.json
                    │   └── targetservers.json
    mkdir -p SOURCE_DIR/src/main/apigee/apiproxies/PROXY_NAME

    각 항목의 의미는 다음과 같습니다.

    • SOURCE_DIR은 보관 파일 디렉터리의 이름입니다.
    • PROXY_NAME은 구성 가능한 프록시의 이름입니다.

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

    mkdir -p my-dir/src/main/apigee/apiproxies/my-proxy
  2. 다음 명령어를 사용하여 프록시 구성의 새 파일을 만듭니다.
    vi SOURCE_DIR/src/main/apigee/apiproxies/PROXY_NAME/config.yaml

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

    vi my-dir/src/main/apigee/apiproxies/my-proxy/config.yaml

    프록시 구성 파일은 반드시 다음 파일 이름 중 하나를 사용해야 합니다.

    • config.yaml
    • config.json
    • config.yml
  3. 다음 프록시 구성을 새 config.yaml 파일에 복사합니다.
    # config.yaml
    
    basepath: "/helloworld"
    operations:
    - id: get-user
      http_match:
      - path_template: "/user"
        method: GET
    target:
      uri: "https://mocktarget.apigee.net"
    
  4. 다음 명령어를 사용하여 deployments.json 파일을 만듭니다.
    vi SOURCE_DIR/src/main/apigee/environments/ENV_NAME/deployments.json
    

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

    vi my-dir/src/main/apigee/environments/prod/deployments.json
  5. 다음을 새 deployments.json 파일에 복사합니다.
  6. {
      "proxies" : ["PROXY_NAME"]
    }
      

자세한 예시는 구성 가능한 프록시 구성 예시를 참조하세요.

보관 파일 배포

Apigee 환경에 보관 파일을 배포하려면 다음 gcloud 명령어를 사용합니다.

gcloud alpha apigee archives deploy \
--organization=PROJECT_ID \
--environment=ENV_NAME \
--source=SOURCE_DIR

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

gcloud alpha apigee archives deploy \
--organization=my-project \
--environment=prod \
--source=my-dir

--environment 플래그를 사용하여 보관 파일을 배포하려는 Apigee 환경을 지정해야 합니다. Apigee 환경에 보관 파일 배포를 사용 설정해야 합니다.

보관 파일 배포 관리에 대한 자세한 내용은 Apigee 환경에서 보관 파일 배포 및 관리를 참조하세요.

보관 파일 배포 상태 확인

보관 파일 배포 상태를 확인하려면 gcloud alpha apigee operations 명령어를 사용합니다.

다음 예시는 버전 ID가 439fa3f7-6aa4-42ad-8b12-3ca912c75d5c인 작업의 보관 파일 배포가 IN_PROGRESS 상태임을 보여줍니다.

gcloud alpha apigee operations describe b64c2665-b5ac-43cc-9e2d-232e8895c2ed

다음은 응답의 예시입니다.

Using Apigee organization 'myorg'
Waiting for operation [b64c2665-b5ac-43cc-9e2d-232e8895c2ed] to complete...done.

보관 파일 배포 나열, 배포 세부정보 보기 또는 보관 파일 배포가 있는 환경 삭제에 대한 자세한 내용은 Apigee 환경에서 보관 파일 배포 및 관리를 참조하세요.