Azure Cache for Redis를 통한 데이터베이스 액세스
Teleport v18.9Teleport는 Teleport Database Service를 통해 Azure Cache for Redis에 대한 보안 접근을 제공할 수 있습니다. Teleport Database Service는 Teleport 사용자와 Azure Cache for Redis 간의 트래픽을 프록시합니다.
Teleport는 Teleport Database Service를 통해 Azure Cache for Redis에 대한 보안 접근을 제공할 수 있습니다. 이를 통해 Teleport의 RBAC를 사용한 세분화된 접근 제어가 가능합니다.
이 가이드에서는 다음을 수행합니다:
- Azure Cache for Redis 데이터베이스를 구성합니다 with Microsoft Entra ID-based authentication.
- 데이터베이스를 Teleport 클러스터에 추가합니다.
- Teleport를 통해 데이터베이스에 연결합니다.
작동 방식#
Teleport Database Service는 Teleport 사용자와 Azure Cache for Redis 간의 트래픽을 프록시합니다. 사용자가 Teleport를 통해 데이터베이스에 연결하면 Database Service는 Microsoft Entra ID에서 액세스 토큰을 가져와 데이터베이스를 관리할 권한이 있는 주체로 Azure에 인증합니다.


사전 요구 사항#
-
실행 중인 Teleport 클러스터. Teleport를 시작하려면 무료 체험판에 가입하거나 데모 환경을 구성하세요.
-
tctlandtshclients.Installing `tctl` and `tsh` clients
-
Teleport 클러스터의 버전을 확인합니다.
tctlandtshclients는 Teleport 클러스터 버전보다 최대 한 개의 메이저 버전까지만 뒤처질 수 있습니다. Proxy Service의/v1/webapi/find로 GET 요청을 보내고 JSON 쿼리 도구를 사용하여 클러스터 버전을 확인합니다.teleport.example.com:443를 Teleport Proxy Service의 웹 주소로 바꿉니다:$ TELEPORT_DOMAIN=teleport.example.com:443 $ TELEPORT_VERSION="$(curl -s https://$TELEPORT_DOMAIN/v1/webapi/find | jq -r '.server_version')" -
사용 중인 플랫폼에 대한 지침에 따라
tctlandtshclients를 설치합니다:
-
Mac
`tctl` and `tsh` clients가 포함된, 서명된 Teleport macOS .pkg 설치 프로그램을 다운로드합니다:
```code
$ curl -O https://cdn.teleport.dev/teleport-${TELEPORT_VERSION?}.pkg
```
Finder에서 `pkg` 파일을 더블 클릭하여 설치를 시작합니다.
Homebrew를 사용하여 Teleport를 설치하는 것은 지원되지 않습니다. Homebrew의
Teleport 패키지는 Teleport에서 유지 관리하지 않으므로 신뢰성이나 보안을
보장할 수 없습니다.
Windows - Powershell
```code
$ curl.exe -O https://cdn.teleport.dev/teleport-v${TELEPORT_VERSION?}-windows-amd64-bin.zip
# Unzip the archive and move the `tctl` and `tsh` clients to your %PATH%
# NOTE: Do not place the `tctl` and `tsh` clients in the System32 directory, as this can cause issues when using WinSCP.
# Use %SystemRoot% (C:\Windows) or %USERPROFILE% (C:\Users\<username>) instead.
```
Linux
Linux 설치판의 모든 Teleport 바이너리에는 `tctl` and `tsh` clients가 포함되어 있습니다. RPM/DEB
패키지 및 i386/ARM/ARM64용 다운로드를 포함한 더 많은 옵션은
[설치 페이지](../installation/installation.mdx)를 참조하세요.
```code
$ curl -O https://cdn.teleport.dev/teleport-v${TELEPORT_VERSION?}-linux-amd64-bin.tar.gz
$ tar -xzf teleport-v${TELEPORT_VERSION?}-linux-amd64-bin.tar.gz
$ cd teleport
$ sudo ./install
# Teleport binaries have been copied to /usr/local/bin
```
- 배포된 Azure Redis 서버 또는 Azure Redis Enterprise 클러스터.
- 서비스 주체 및 액세스 제어를 관리하기 위한 Azure 관리자 권한.
- Teleport Database Service를 실행할 호스트(예: Azure VM 인스턴스).
redis-cli버전6.2이상이 설치되어 있고 시스템의PATH환경 변수에 추가되어 있어야 합니다.
Teleport cluster에 연결할 수 있는지 확인하려면 tsh login으로 로그인한 다음,
현재 자격 증명으로 tctl 명령을 실행할 수 있는지 확인합니다.
예를 들어, teleport.example.com에 cluster 내 Teleport Proxy Service의
도메인 이름을, email@example.com에 Teleport 사용자 이름을 지정하여
다음 명령을 실행합니다:
$ tsh login --proxy=teleport.example.com --user=email@example.com
$ tctl status
# Cluster (=teleport.url=)
# Version (=teleport.version=)
# CA pin (=presets.ca_pin=)
cluster에 연결하여 tctl status 명령을 실행할 수 있다면, 현재 자격 증명을 사용하여
워크스테이션에서 이후의 tctl 명령을 실행할 수 있습니다.
자체 Teleport cluster를 호스팅하는 경우, 전체 권한을 얻기 위해 Teleport Auth Service를
호스팅하는 컴퓨터에서 tctl 명령을 실행할 수도 있습니다.
1/5단계. Teleport 토큰 및 사용자 생성#
Database Service가 Teleport 클러스터에 조인하려면 유효한 조인 토큰이 필요합니다.
다음 tctl 명령을 실행하고 Database Service를 실행할 서버에서
토큰 출력을 /tmp/token에 저장합니다:
$ tctl tokens add --type=db --format=text
(=presets.tokens.first=)
기존 사용자를 수정하여 Database Service 접근 권한을 부여하려면 Database Access Controls를 참조하십시오.
Teleport Community Edition
내장 access 역할을 가진 로컬 Teleport 사용자를 생성합니다:
$ tctl users add \
--roles=access \
--db-users="*" \
--db-names="*" \
alice
Teleport Enterprise/Enterprise Cloud
내장 access 및 requester 역할을 가진 로컬 Teleport 사용자를 생성합니다:
$ tctl users add \
--roles=access,requester \
--db-users="*" \
--db-names="*" \
alice
| Flag | 설명 |
|---|---|
--roles |
사용자에게 할당할 역할 목록입니다. 내장 access 역할은 Teleport에 등록된 모든 데이터베이스 서버에 연결할 수 있게 합니다. |
--db-users |
사용자가 데이터베이스에 연결할 때 사용할 수 있는 데이터베이스 사용자명 목록입니다. 와일드카드는 모든 사용자를 허용합니다. |
--db-names |
사용자가 데이터베이스 서버 내에서 연결할 수 있는 논리적 데이터베이스(즉, 스키마) 목록입니다. 와일드카드는 모든 데이터베이스를 허용합니다. |
데이터베이스 이름은 PostgreSQL, MongoDB, Cloud Spanner 데이터베이스에서만 적용됩니다.
데이터베이스 접근 제어 및 접근 제한 방법에 대한 자세한 정보는 RBAC 문서를 참조하십시오.
2/5단계. Database Service 구성 생성#
Teleport Database Service를 실행할 호스트에 Teleport를 설치합니다:
Linux 서버에 Teleport Agent를 설치하려면:
권장 설치 방법은 클러스터 설치 스크립트입니다. 이 스크립트는 클러스터에 맞는 올바른 버전, 에디션, 설치 모드를 선택합니다.
-
teleport.example.com:443에 Teleport 클러스터의 호스트명과 포트를 할당하되, 스킴(https://)은 포함하지 마십시오. -
클러스터의 설치 스크립트를 실행하십시오:
$ curl "https://teleport.example.com:443/scripts/install.sh" | sudo bash
다음과 같이 지역을 지정하여 Database Service 구성을 생성합니다:
$ sudo teleport db configure create \
-o file \
--proxy=tele.example.com:443 \
--token=/tmp/token \
--azure-redis-discovery=eastus
$ sudo teleport db configure create \
-o file \
--proxy=teleport.example.com:443 \
--token=/tmp/token \
--azure-redis-discovery=eastus
이 명령은 eastus 지역에서 Azure Cache for Redis 자동 검색이 활성화된 Database Service 구성을 생성하여 /etc/teleport.yaml 위치에 저장합니다.
--azure-redis-discovery=*를 사용하면 모든 지역의 데이터베이스를 검색할 수 있습니다. 지역 외에도 선택적으로 --azure-resource-group=<resource-group-name>, --azure-subscription=<subscription-id>, 또는 --labels=<key>=<value>를 지정하여 자동 검색 범위를 추가로 사용자 지정할 수 있습니다.
3/5단계. Teleport를 위한 IAM 권한 구성#
Teleport Database Service에는 다음을 위한 Azure IAM 권한이 필요합니다:
- Azure Cache for Redis 데이터베이스 검색 및 등록.
- 데이터베이스 인증을 위한 Redis 액세스 키 검색.
Azure 서비스 주체 구성#
Teleport Database Service가 Azure 리소스에 접근하는 방법은 몇 가지가 있습니다:
- Database Service를 관리 ID(managed identity)가 연결된 Azure VM에서 실행할 수 있습니다. 이 방식은 Azure 자격 증명을 관리할 필요가 없어지므로 프로덕션 환경에서 Database Service를 배포하는 권장 방법입니다.
- Database Service를 Microsoft Entra ID 애플리케이션으로 등록("App registrations"을 통해)하고 해당 자격 증명으로 구성할 수 있습니다. 이 방식은 Database Service의 환경에 Azure 자격 증명이 존재해야 하므로 개발 및 테스트 목적으로만 권장됩니다.
Using managed identity
Azure 포털의 Managed Identities 페이지로 이동하여 Create를 클릭해 새 사용자 할당 관리 ID(user-assigned managed identity)를 생성합니다:

새 ID의 이름과 리소스 그룹을 지정하고 생성합니다:

생성된 ID의 Client ID를 기록해 둡니다:

다음으로, Database Service 인스턴스를 실행할 Azure VM으로 이동하여 방금 생성한 ID를 추가합니다:

Database Service를 실행할 모든 Azure VM에 이 ID를 연결합니다.
Using app registrations
Database Service를 Microsoft Entra ID 애플리케이션으로 등록하는 방식은
테스트 및 개발 시나리오에 적합하거나, Database Service가 Azure VM에서
실행되지 않는 경우에 적합합니다. 프로덕션 시나리오에서는 관리 ID
방식을 사용하는 것이
좋습니다.
Microsoft Entra ID의 App registrations 페이지로 이동하여 New registration을 클릭합니다:

이름(예: DatabaseService)을 지정하고 새 애플리케이션을 등록합니다. 앱이 생성되면 Application (client) ID를 기록해 두고 Add a certificate or secret을 클릭합니다:

Database Service 에이전트가 Azure API로 인증하는 데 사용할 새 클라이언트 시크릿을 생성합니다:

Teleport Database Service는 Azure SDK의 기본 자격 증명 공급자 체인을 사용하여 자격 증명을 찾습니다. 사용 사례에 적합한 방법을 선택하려면 Azure SDK Authorization을 참조하세요. 예를 들어 클라이언트 시크릿을 사용한 환경 기반 인증을 사용하려면 Database Service에 다음 환경 변수가 설정되어 있어야 합니다:
export AZURE_TENANT_ID=
export AZURE_CLIENT_ID=
export AZURE_CLIENT_SECRET=
사용자 지정 역할 생성#
Teleport는 검색을 위해 <resource-type>/read 권한이, Redis 서버 인증을 위해 <resource-type>/listKeys/action 권한이 필요하지만, Teleport는 실제로 보유한 리소스 유형에 대한 권한만 필요로 합니다.
다음은 Teleport가 Azure Redis와 Azure Redis Enterprise 모두에 대해 읽기 및 키 나열을 허용하는 샘플 역할 정의입니다:
{
"properties": {
"roleName": "TeleportDiscovery",
"description": "Allows Teleport to discover Azure Cache For Redis databases and list keys",
"assignableScopes": [
"/subscriptions/11111111-2222-3333-4444-555555555555"
],
"permissions": [
{
"actions": [
"Microsoft.Cache/redis/read",
"Microsoft.Cache/redis/listKeys/action",
"Microsoft.Cache/redisEnterprise/read",
"Microsoft.Cache/redisEnterprise/databases/read",
"Microsoft.Cache/redisEnterprise/databases/listKeys/action"
],
"notActions": [],
"dataActions": [],
"notDataActions": []
}
]
}
}
위의 assignableScopes 필드에는 구독 /subscriptions/<subscription>이 포함되어 있어, 해당 구독 내의 모든 리소스 범위 또는 구독 범위 자체에서 역할을 할당할 수 있습니다. assignableScopes를 더 제한하려면 리소스 그룹 /subscriptions/<subscription>/resourceGroups/<group> 또는 관리 그룹 /providers/Microsoft.Management/managementGroups/<group>을 대신 사용할 수 있습니다.
이제 구독 페이지로 이동하여 구독을 선택합니다.
구독에서 *액세스 제어(IAM)*를 클릭하고 추가 > 사용자 지정 역할 추가를 선택합니다:

사용자 지정 역할 생성 페이지에서 JSON 탭을 클릭하고 편집을 클릭한 다음, JSON 예시를 붙여넣고 assignableScopes의 구독을 본인의 구독 ID로 교체합니다:

Teleport Database Service 주체에 대한 역할 할당 생성#
Teleport에 권한을 부여하려면 생성한 사용자 지정 역할을 Teleport 서비스 주체 - 즉 앞서 생성한 관리 ID 또는 앱 등록 -에 할당해야 합니다.
역할 할당을 수행할 리소스 범위로 이동합니다. *Access control (IAM)*을 클릭하고 Add > Add role assignment을 선택합니다. 생성한 사용자 지정 역할을 역할로 선택하고 Teleport 서비스 주체를 멤버로 선택합니다.

역할 할당은 Teleport Database Service가 일치하는 모든 데이터베이스를 검색할 수 있을 만큼 충분히 높은 범위여야 합니다. Azure 범위와 역할 할당 생성에 대한 자세한 내용은 Identify the needed scope를 참고하십시오.
4/5단계. Database Service 시작#
systemd 서비스를 생성하여 호스트가 부팅될 때 the Teleport Database Service이 자동으로 시작되도록 구성합니다. 지침은 the Teleport Database Service을 어떻게 설치했는지에 따라 다릅니다.
Package Manager
the Teleport Database Service을 실행할 호스트에서 Teleport를 활성화하고 시작합니다:
$ sudo systemctl enable teleport
$ sudo systemctl start teleport
TAR Archive
the Teleport Database Service을 실행할 호스트에서 Teleport용 systemd 서비스 구성을 생성하고, Teleport 서비스를 활성화한 후 Teleport를 시작합니다:
$ sudo teleport install systemd -o /etc/systemd/system/teleport.service
$ sudo systemctl enable teleport
$ sudo systemctl start teleport
systemctl status teleport로 the Teleport Database Service의 상태를 확인하고 journalctl -fu teleport로
로그를 볼 수 있습니다.
5/5단계. 연결#
Teleport 클러스터에 로그인합니다. Azure Cache for Redis 데이터베이스가 사용 가능한 데이터베이스 목록에 나타나야 합니다:
$ tsh login --proxy=teleport.example.com --user=alice
$ tsh db ls
Name Description Allowed Users Labels Connect
------------------------- ---------------------------------------- ------------- ------- -------
my-azure-redis Azure Redis server in East US [*] ...
my-azure-redis-enterprise Azure Redis Enterprise server in East US [*] ...
$ tsh login --proxy=mytenant.teleport.sh --user=alice
$ tsh db ls
Name Description Allowed Users Labels Connect
------------------------- ---------------------------------------- ------------- ------- -------
my-azure-redis Azure Redis server in East US [*] ...
my-azure-redis-enterprise Azure Redis Enterprise server in East US [*] ...
기본적으로 Teleport는 Azure Cache for Redis 리소스의 이름을 데이터베이스 이름으로 사용합니다. TeleportDatabaseName Azure 태그를 리소스에 적용하여 데이터베이스 이름을 재정의할 수 있습니다. 이 태그의 값이 데이터베이스 이름으로 사용됩니다.
데이터베이스의 자격 증명을 검색하고 연결하려면:
$ tsh db connect my-azure-redis
Teleport Database Service가 백엔드에서 자동으로 액세스 키를 검색하고 Redis 서버에 인증한다는 점에 유의하십시오. 따라서 연결된 이후에는 여기서 AUTH <access-key> 명령이 필요하지 않습니다.
이 섹션의 내용은 원문 문서를 참조하세요. (proxy-db-tunnel.mdx)
데이터베이스에서 로그아웃하고 자격 증명을 제거하려면:
$ tsh db logout my-azure-redis
문제 해결#
No credential providers error#
Database Service 로그에서 DefaultAzureCredential: failed to acquire a token. 오류가 보인다면,
Teleport가 Azure SDK에 연결하는 데 필요한 자격 증명을 감지하지 못하는 것입니다.
Teleport Database Service가 실행 중인 머신에 자격 증명이 적용되었는지 확인하고
Teleport Database Service를 재시작하십시오.
자세한 내용은 Azure SDK Authorization을
참조하십시오.
Timeout errors#
Teleport Database Service는 데이터베이스 엔드포인트에 연결할 수 있어야 합니다. 이를 위해
동일한 VPC의 Database Service에서 데이터베이스로 들어오는 인바운드 트래픽을 허용하거나
다른 VPC로부터의 라우팅 규칙이 필요할 수 있습니다. nc 프로그램을 사용하여
데이터베이스 연결을 확인할 수 있습니다:
$ nc -zv server-name.postgres.database.azure.com 5432
# Connection to server-name.postgres.database.azure.com 5432 port [tcp/postgresql] succeeded!
다음 단계#
-
특정 사용자 및 데이터베이스에 대한 접근을 제한하는 방법을 알아보십시오.
-
고가용성 (HA) 가이드를 확인하십시오.
-
YAML 구성 레퍼런스를 살펴보십시오.
-
전체 CLI 레퍼런스를 참조하십시오.