GCP 태그 및 레이블을 Teleport 에이전트 레이블로 사용
Google Compute Engine 인스턴스에서 실행할 때 Teleport는 GCP 태그(자체 리소스인 키-값 쌍)와 레이블(각 인스턴스에 특정한 키-값 쌍)을 자동으로 감지하고 SSH 노드, 애플리케이션, 데이터베이스, Kubernetes 클러스터의 Tele...
Google Compute Engine 인스턴스에서 실행할 때 Teleport는 GCP 태그(자체 리소스인 키-값 쌍)와 레이블(각 인스턴스에 특정한 키-값 쌍)을 자동으로 감지하고 SSH 노드, 애플리케이션, 데이터베이스, Kubernetes 클러스터의 Teleport 레이블로 가져옵니다. 이 방식으로 가져온 태그와 레이블 모두 gcp/ 접두사를 갖습니다. 추가로 태그에는 tag/ 중간 접사가, 레이블에는 label/ 중간 접사가 붙습니다. 예를 들어 레이블 foo=bar와 태그 baz=quux가 있는 인스턴스는 Teleport 레이블 gcp/label/foo=bar와 gcp/tag/baz=quux를 갖습니다.
Teleport 프로세스가 시작할 때 GCP API에서 모든 태그와 레이블을 가져와 레이블로 추가합니다. 프로세스는 매 시간 태그를 업데이트하므로 새로 생성되거나 삭제된 태그가 레이블에 반영됩니다.
GCP 레이블 TeleportHostname이 있는 경우 해당 값(소문자여야 함)이 노드의 호스트명을 재정의합니다. 이는 GCP 태그에는 적용되지 않습니다.
$ tsh ls
Node Name Address Labels
-------------------- -------------- -------------------------------------------------------------------------------------------
fakehost.example.com 127.0.0.1:3022 gcp/label/testing=yes,gcp/tag/environment=staging,gcp/TeleportHostname=fakehost.example.com
여러 리소스를 관리하는 서비스(예: Database Service)의 경우 각 리소스는 GCP에서 동일한 태그와 레이블을 받습니다.
사전 요구 사항#
-
A running Teleport cluster. If you want to get started with Teleport, sign up for a free trial or set up a demo environment.
-
The
tctlandtshclients.Installing `tctl` and `tsh` clients
-
Determine the version of your Teleport cluster. The
tctlandtshclients must be at most one major version behind your Teleport cluster version. Send a GET request to the Proxy Service at/v1/webapi/findand use a JSON query tool to obtain your cluster version. Replace with the web address of your Teleport Proxy Service:$ TELEPORT_DOMAIN= $ TELEPORT_VERSION="$(curl -s https://$TELEPORT_DOMAIN/v1/webapi/find | jq -r '.server_version')" -
Follow the instructions for your platform to install
tctlandtshclients:
-
- GCP Compute 인스턴스에서 실행 중인 Teleport 에이전트 하나. Teleport 에이전트 설정 방법은 가이드를 참조하십시오.
Teleport 노드가 있는 인스턴스에서 서비스 계정 구성#
태그와 레이블을 가져오는 데 필요한 IAM 권한을 Teleport에 부여할 서비스 계정을 생성하십시오. 다음을 복사하여 teleport-labels-role.yaml 파일에 붙여넣으십시오:
# teleport-labels-role.yaml
title: "teleport-labels"
description: "A role to enable Teleport to import tags and labels"
stage: "ALPHA"
includedPermissions:
- compute.instances.get
- compute.instances.listEffectiveTags
그런 다음 다음 명령어를 실행하여 역할을 생성하십시오:
$ gcloud iam roles create teleport_labels \
--project= \
--file=teleport-labels-role.yaml
다음 명령어를 실행하여 서비스 계정을 생성하십시오:
$ gcloud iam service-accounts create teleport-labels \
--description="A service account to enable Teleport to import tags and labels" \
--display-name="teleport-labels"
다음 명령어를 실행하여 새 서비스 계정에 새 역할을 추가하십시오:
$ gcloud projects add-iam-policy-binding \
--member="serviceAccount:teleport-labels@.iam.gserviceaccount.com" \
--role="projects//roles/teleport_labels"
레이블만 가져오거나 태그만 가져오려면 생성한 서비스 계정의 권한에서 각각 compute.instances.listEffectiveTags 또는 compute.instances.get을 제외할 수 있습니다.
