Apigee에 권한 위임
Apigee에 권한 위임 (Delegate Authorization to Apigee)
이 주제는 외부 인가(외부 authorization) Envoy 확장을 사용해 데이터 플레인 인가 요청을 Apigee에 위임하는 방법을 설명해요.
출처: 문서
본문
이 주제는 외부 인가 Envoy 확장을 사용해 데이터 플레인 인가 요청을 Apigee에 위임하는 방법을 설명해요.
더 자세한 지침은 GitHub의 learn-consul-apigee-external-authz 저장소를 참고해요.
워크플로 (Workflow)
Apigee와 함께 외부 인가 확장을 사용하려면 다음 단계를 완료해요:
- Apigee Adapter for Envoy를 배포하고 Consul에 서비스를 등록해요.
- service defaults 또는 proxy defaults 구성 항목에
EnvoyExtensions블록을 구성해요. - 구성 항목을 적용해요.
Apigee Adapter for Envoy 배포 (Deploy the Apigee Adapter for Envoy)
Apigee Adapter for Envoy는 Envoy를 사용해 API 트래픽을 프록시하는 Apigee 관리형 API 게이트웨이예요.
Apigee Adapter for Envoy를 다운로드하고 설치하려면 시작하기 문서를 참고하거나 learn-consul-apigee-external-authz GitHub 저장소를 따라해요.
원하는 런타임에 서비스를 배포한 후 서비스의 gRPC 프로토콜에 대한 service defaults 구성 항목을 생성해요.
apigee-remote-service-envoy.hcl:
Kind = "service-defaults"
Name = "apigee-remote-service-envoy"
Protocol = "grpc"
apigee-remote-service-envoy.json:
{
"kind": "service-defaults",
"name": "apigee-remote-service-envoy",
"protocol": "grpc"
}
apigee-remote-service-envoy.yaml:
apiVersion: consul.hashicorp.com/v1alpha1
kind: ServiceDefaults
metadata:
name: apigee-remote-service-envoy
namespace: apigee
spec:
protocol: grpc
EnvoyExtensions 구성 (Configure the EnvoyExtensions)
proxy defaults 또는 service defaults 구성 항목에 Envoy 확장 구성을 추가해요. 구성 항목의 EnvoyExtensions 블록에 확장 구성을 배치해요.
- proxy defaults에 Envoy 확장을 구성하면 모든 서비스에 적용돼요.
- service defaults에 Envoy 확장을 구성하면 해당 이름의 서비스의 모든 인스턴스에 적용돼요.
경고 (Warning)
기본 프록시 구성에 Envoy 확장을 추가하면 의도하지 않은 결과가 발생할 수 있어요. 대부분의 경우 service defaults 구성 항목에
EnvoyExtensions를 구성할 것을 권장해요.
Consul은 proxy defaults에 구성된 Envoy 확장을 service defaults의 확장보다 먼저 적용해요. 따라서 service defaults의 Envoy 확장 구성이 proxy defaults의 구성보다 우선할 수 있어요.
다음 예시는 api라는 모든 서비스의 기본 동작을 구성해 해당 서비스 인스턴스의 사이드카로 실행되는 Envoy 프록시가 gRPC 인가 요청을 위해 apigee-remote-service-envoy 서비스를 대상으로 하도록 해요:
api-auth-service-defaults.hcl:
Kind = "service-defaults"
Name = "api"
EnvoyExtensions = [
{
Name = "builtin/ext-authz"
Arguments = {
ProxyType = "connect-proxy"
Config = {
GrpcService = {
Target = {
Service = {
Name = "apigee-remote-service-envoy"
}
}
}
}
}
}
]
api-auth-service-defaults.json:
{
"Kind": "service-defaults",
"Name": "api",
"EnvoyExtensions": [{
"Name": "builtin/ext-authz",
"Arguments": {
"ProxyType": "connect-proxy",
"Config": {
"GrpcService": {
"Target": {
"Service": {
"Name": "apigee-remote-service-envoy"
}
}
}
}
}
}
]
}
api-auth-service-defaults.yaml:
apiVersion: consul.hashicorp.com/v1alpha1
kind: ServiceDefaults
metadata:
name: api
namespace: default
spec:
envoyExtensions:
- name: builtin/ext-authz
arguments:
proxyType: connect-proxy
config:
grpcService:
target:
service:
name: apigee-remote-service-envoy
namespace: apigee
확장을 구성하는 방법에 대한 세부 사항은 외부 인가 확장 구성 참조를 참고해요.
구성 항목을 정의하는 방법에 대한 세부 사항은 proxy defaults 구성 항목 참조와 service defaults 구성 항목 참조를 참고해요.
경고 (Warning)
기본 프록시 구성에 Envoy 확장을 추가하면 의도하지 않은 결과가 발생할 수 있어요. 대부분의 경우 service defaults 구성 항목에
EnvoyExtensions를 구성할 것을 권장해요.
구성 항목 적용 (Apply the configuration entry)
CLI에서 consul config write 명령을 사용하고 구성 항목의 이름을 지정해 Consul에 적용할 수 있어요. Kubernetes 오케스트레이션 네트워크에서는 kubectl apply 명령을 사용해 관련 CRD를 업데이트해요.
consul config write (HCL/JSON):
$ consul config write apigee-remote-service-envoy.hcl
$ consul config write api-auth-service-defaults.hcl
$ consul config write apigee-remote-service-envoy.json
$ consul config write api-auth-service-defaults.json
$ kubectl apply -f apigee-remote-service-envoy.yaml
$ kubectl apply -f api-auth-service-defaults.yaml