Google Kubernetes Engine (GKE)용 서비스 디렉터리는 모든 GKE 배포 및 그 이상에서 모든 서비스의 단일 뷰를 제공합니다. 다양한 유형의 GKE 서비스를 추가하고, 주석을 달고, 서비스 디렉터리에서 해당 서비스를 확인할 수 있습니다.
GKE용 서비스 디렉터리는 다음과 같은 기능을 제공합니다.
- gRPC 및 HTTP를 통해 서비스를 검색하고 서비스 디렉터리 DNS 영역을 사용하여 DNS를 통해 서비스를 확인할 수 있습니다. 서비스 디렉터리 및 Cloud DNS 통합을 사용하면 서비스 디렉터리 DNS 영역을 구성할 수 있습니다.
- 서비스 디렉터리는 GKE 외부의 서비스를 등록하여 GKE 및 비GKE 서비스가 서로 쉽게 검색할 수 있도록 지원합니다.
- Service Directory는 IAM 권한과 VPC 서비스 제어 검사를 적용하여 고객 데이터의 적절한 보안과 개인 정보 보호를 보장합니다.
- Autopilot GKE 클러스터 또는 Standard GKE 클러스터로 GKE용 서비스 디렉터리를 구성할 수 있습니다. 두 모드에 대한 자세한 내용은 GKE 작업 모드 선택을 참고하세요.
서비스 디렉터리를 구성하여 GKE 서비스를 서비스 디렉터리에 자동으로 등록하는 방법을 알아보려면 GKE용 서비스 디렉터리 구성을 참고하세요.
서비스 매핑
서비스를 서비스 디렉터리에 등록하면 Kubernetes 네임스페이스 이름과 GKE 클러스터 리전을 사용하여 Google Cloud fleet 프로젝트에 서비스가 생성됩니다. 다음 표에서는 모든 GKE 서비스 유형에 대해 GKE 서비스의 속성이 Service Directory에서 생성된 서비스의 속성에 매핑되는 방식을 설명합니다.
최상위 속성
| 서비스 디렉터리 속성 | GKE 속성 |
| 프로젝트 | Fleet 프로젝트 |
| 리전 | 클러스터의 리전 |
| 네임스페이스 | Kubernetes 네임스페이스 |
LoadBalancer 서비스 유형
다음 예에서는 GKE LoadBalancer 서비스가 서비스 디렉터리에 매핑되는 방법을 보여줍니다. 서비스 디렉터리 서비스는 GKE 클러스터의 플릿 프로젝트 및 리전에서 Kubernetes 네임스페이스와 이름이 동일한 네임스페이스에 있습니다.
| 서비스 디렉터리 속성 | GKE 속성 |
| 서비스 이름 | 서비스 이름 |
| 엔드포인트 이름 | 서비스 디렉터리 컨트롤러에 의해 자동 생성됨 |
| 엔드포인트 IP 주소 | LoadBalancer 인그레스 |
| 엔드포인트 포트 | LoadBalancer 서비스 포트 |
| 엔드포인트 네트워크 | 클러스터의 VPC 네트워크 |
다음은 GKE LoadBalancer 서비스의 예시입니다.
apiVersion: v1 kind: Service metadata: name: hello-app annotations: cloud.google.com/load-balancer-type: "Internal" labels: app: hello-app sd-import: "true" spec: ports: - port: 80 targetPort: 8080 protocol: TCP selector: app: hello-app type: LoadBalancer status: loadBalancer: ingress: - ip: 10.140.0.5
다음은 서비스 디렉터리 서비스의 예입니다.
service: endpoints: - address: 10.140.0.5 metadata: cloud.google.com/load-balancer-type: "Internal" name: projects/my-project/locations/us-central1/namespaces/default/services/hello-app/endpoints/gke-hello-cluster-12345 port: 80 network: projects/my-project/locations/global/networks/default name: projects/my-project/locations/us-central1/namespaces/default/services/hello-app
NodePort 서비스 유형
다음 예시에서는 GKE NodePort 서비스가 서비스 디렉터리에 매핑되는 방법을 보여줍니다. 서비스 디렉터리 서비스는 GKE 클러스터의 허브 및 리전 프로젝트에 있는 Kubernetes 네임스페이스와 이름이 동일한 네임스페이스에 있습니다.
| 서비스 디렉터리 속성 | GKE 속성 |
| 서비스 이름 | 서비스 이름 |
| 엔드포인트 이름 | 서비스 디렉터리 컨트롤러에 의해 자동 생성됨 |
| 엔드포인트 IP 주소 | 서비스의 포드를 실행하는 각 노드의 노드 내부 IP 주소 |
| 엔드포인트 포트 | 정적 노드 포트 |
| 엔드포인트 네트워크 | 클러스터의 VPC 네트워크 |
다음은 GKE NodePort 서비스의 예시입니다.
apiVersion: v1 kind: Service metadata: name: hello-app annotations: key1: "value1" spec: ports: - nodePort: 30007 port: 80 targetPort: 8080 protocol: TCP selector: app: hello-app type: NodePort
다음은 GKE 노드의 예입니다.
apiVersion: v1 items: - apiVersion: v1 kind: Node metadata: name: gke-hello-cluster-default-pool-a40cbab6-d2rr status: addresses: - address: 10.142.0.27 type: InternalIP - address: 34.73.248.170 - apiVersion: v1 kind: Node metadata: name: gke-hello-cluster-default-pool-a40cbab6-kb38 status: addresses: - address: 10.142.0.29 type: InternalIP - address: 35.196.219.215 type: ExternalIP - apiVersion: v1 kind: Node metadata: name: gke-hello-cluster-default-pool-a40cbab6-x34q status: addresses: - address: 10.142.0.28 type: InternalIP - address: 34.75.202.26 type: ExternalIP
다음은 서비스 디렉터리 서비스의 예입니다.
service: endpoints: - address: 10.142.0.27 metadata: key1: value1 name: projects/my-project/locations/us-central1/namespaces/default/services/hello-app/endpoints/gke-hello-cluster-12345 port: 30007 network: projects/my-project/locations/global/networks/default - address: 10.142.0.28 metadata: key1: value1 name: projects/my-project/locations/us-central1/namespaces/default/services/hello-app/endpoints/gke-hello-cluster-23456 port: 30007 network: projects/my-project/locations/global/networks/default - address: 10.142.0.29 metadata: key1: value1 name: projects/my-project/locations/us-central1/namespaces/default/services/hello-app/endpoints/gke-hello-cluster-34567 port: 30007 network: projects/my-project/locations/global/networks/default name: projects/my-project/locations/us-central1/namespaces/default/services/hello-app
ClusterIP 서비스
다음 예에서는 GKE ClusterIP 서비스가 서비스 디렉터리에 매핑되는 방법을 보여줍니다. 서비스 디렉터리 서비스는 GKE 클러스터의 Fleet 프로젝트 및 리전에서 Kubernetes 네임스페이스와 이름이 같은 네임스페이스에 있습니다.
| 서비스 디렉터리 속성 | GKE 속성 |
| 서비스 이름 | 서비스 이름 |
| 엔드포인트 이름 | 서비스 디렉터리 컨트롤러에 의해 자동 생성됨 |
| 엔드포인트 IP 주소 | ClusterIP |
| 엔드포인트 포트 | 서비스 포트 |
| 엔드포인트 네트워크 | 클러스터의 VPC 네트워크 |
다음은 GKE ClusterIP 서비스의 예입니다.
apiVersion: v1 kind: Service metadata: name: hello-app annotations: key1: "value1" labels: app: hello-app sd-import: "true" spec: clusterIP: 10.15.254.17 ports: - port: 80 targetPort: 8080 protocol: TCP selector: app: hello-app type: ClusterIP
다음은 서비스 디렉터리 서비스의 예입니다.
service: endpoints: - address: 10.15.254.17 metadata: key1: value1 name: projects/my-project/locations/us-central1/namespaces/default/services/hello-app/endpoints/gke-hello-cluster-12345 port: 80 network: projects/my-project/locations/global/networks/default name: projects/my-project/locations/us-central1/namespaces/default/services/hello-app
다음 단계
- 서비스 디렉터리 개요는 서비스 디렉터리 개요를 참고하세요.
- Service Directory를 사용할 때 발생할 수 있는 일반적인 문제에 대한 해결책을 찾으려면 문제 해결을 참고하세요.