InfoGrab Docs

ClickHouse 데이터베이스 접근

요약

Teleport ClickHouse 통합을 통해 ClickHouse 데이터베이스를 Teleport에 등록할 수 있습니다. 이 가이드를 통해 다음을 수행할 수 있습니다: Teleport 데이터베이스 서비스는 x509 인증서를 사용하여 ClickHouse에 인증하며, 이 인증서는 ClickHouse HTTP 및 Native(TCP) 인터페이스에서 사용 가능합니다.

Teleport ClickHouse 통합을 통해 ClickHouse 데이터베이스를 Teleport에 등록할 수 있습니다.

이 가이드를 통해 다음을 수행할 수 있습니다:

  • Teleport 데이터베이스 에이전트를 설치하고 구성합니다.
  • 셀프 호스팅 ClickHouse 데이터베이스에 접근하기 위해 Teleport를 설정합니다.
  • Teleport를 통해 데이터베이스에 연결합니다.

작동 방식#

Teleport 데이터베이스 서비스는 x509 인증서를 사용하여 ClickHouse에 인증하며, 이 인증서는 ClickHouse HTTP 및 Native(TCP) 인터페이스에서 사용 가능합니다. Teleport 데이터베이스 서비스는 ClickHouse Native(TCP) 및 HTTP 프로토콜 모두로 통신할 수 있으며, Teleport 데이터베이스 서비스를 구성할 때 사용할 프로토콜을 선택할 수 있습니다.

쿼리 활동에 대한 Teleport 감사 로그는 ClickHouse HTTP 인터페이스에서만 지원됩니다. ClickHouse의 네이티브 인터페이스에 대한 Teleport 지원에는 데이터베이스 쿼리 활동에 대한 감사 로그가 포함되지 않습니다.

셀프 호스팅 Teleport 클러스터로 ClickHouse 등록

클라우드 호스팅 Teleport 클러스터로 ClickHouse 등록

사전 조건#

  • 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 tctl and tsh clients.

    Installing `tctl` and `tsh` clients
    1. Determine the version of your Teleport cluster. The tctl and tsh clients must be at most one major version behind your Teleport cluster version. Send a GET request to the Proxy Service at /v1/webapi/find and 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')"
      
    2. Follow the instructions for your platform to install tctl and tsh clients:

  • Teleport 데이터베이스 서비스를 실행할 Linux 호스트 또는 Kubernetes 클러스터.

선택한 ClickHouse 프로토콜에 따라 다음도 필요합니다:

  • ClickHouse Server v22.3 이상의 셀프 호스팅 배포.
  • ClickHouse Server v23.3 이상의 셀프 호스팅 배포.
  • clickhouse-client가 설치되어 사용자의 PATH 환경 변수에 추가되어 있어야 합니다.
  • 선택 사항: 셀프 호스팅 데이터베이스에 대한 인증서를 발급하는 인증 기관.

1/5단계. Teleport 토큰 및 사용자 생성#

The Database Service requires a valid join token to join your Teleport cluster. Run the following tctl command and save the token output in /tmp/token on the server that will run the Database Service:

$ tctl tokens add --type=db --format=text
(=presets.tokens.first=)
Flag Description
--roles List of roles to assign to the user. The builtin access role allows them to connect to any database server registered with Teleport.
--db-users List of database usernames the user will be allowed to use when connecting to the databases. A wildcard allows any user.
--db-names List of logical databases (aka schemas) the user will be allowed to connect to within a database server. A wildcard allows any database.

For more detailed information about database access controls and how to restrict access see RBAC documentation.

2/5단계. 인증서/키 쌍 생성#

Teleport uses mutual TLS authentication with self-hosted databases. These databases must be able to verify certificates presented by the Teleport Database Service. Self-hosted databases also need a certificate/key pair that Teleport can verify.

By default, the Teleport Database Service trusts certificates issued by a certificate authority managed by the Teleport Auth Service. You can either:

  • Configure your self-hosted database to trust this CA, and instruct Teleport to issue a certificate for the database to present to the Teleport Database Service.
  • Configure the Database Service to trust a custom CA.

3/5단계. ClickHouse 구성#

생성된 시크릿을 사용하여 clickhouse-server/config.xml 구성 파일에서 상호 TLS를 활성화합니다:

<openSSL>
    <server>
       <privateKeyFile>/path/to/server.key</privateKeyFile>
       <caConfig>/path/to/server.cas</caConfig>
       <certificateFile>/path/to/server.crt</certificateFile>
       <verificationMode>strict</verificationMode>
    </server>
</openSSL>

이 구성을 활성화하려면 ClickHouse Server를 재시작하세요. 또한 ClickHouse 데이터베이스 사용자 계정은 유효한 클라이언트 인증서를 요구하도록 구성되어야 합니다:

CREATE USER alice IDENTIFIED WITH ssl_certificate CN 'alice';

기본적으로 생성된 사용자는 아무것에도 접근할 수 없어 연결할 수 없으므로 일부 권한을 부여합니다:

GRANT ALL ON *.* TO alice;

4/5단계. 데이터베이스 서비스 구성 및 시작#

Teleport 데이터베이스 서비스를 실행할 호스트 또는 Kubernetes 클러스터에 Teleport를 설치하고 구성합니다. HTTP 프로토콜에는 을 clickhouse-http로 지정하고, 네이티브 ClickHouse 프로토콜에는 clickhouse로 지정합니다:

To install a Teleport Agent on your Linux server:

The recommended installation method is the cluster install script. It will select the correct version, edition, and installation mode for your cluster.

  1. Assign to your Teleport cluster hostname and port, but not the scheme (https://).

  2. Run your cluster's install script:

    $ curl "https:///scripts/install.sh" | sudo bash
    
Note

아래 단계는 기존 구성 파일을 덮어쓰므로, 여러 서비스를 실행 중인 경우 --output=stdout을 추가하여 터미널에 구성을 출력하고 /etc/teleport.yaml을 수동으로 조정하세요.

Teleport 데이터베이스 서비스를 실행할 호스트에서 적절한 구성으로 Teleport를 시작합니다.

단일 Teleport 프로세스가 여러 다른 서비스를 실행할 수 있습니다. 예를 들어 여러 데이터베이스 서비스 에이전트뿐만 아니라 SSH 서비스 또는 애플리케이션 서비스도 함께 실행할 수 있습니다. 아래 단계는 기존 구성 파일을 덮어쓰므로, 여러 서비스를 실행 중인 경우 --output=stdout을 추가하여 터미널에 구성을 출력하고 /etc/teleport.yaml을 수동으로 조정하세요.

데이터베이스 서비스용 구성 파일을 /etc/teleport.yaml에 생성하려면 다음 명령을 실행하세요. Teleport Proxy 서비스의 호스트와 포트를 사용하도록 을 업데이트하세요:

$ sudo teleport db configure create \
   -o file \
   --token=/tmp/token \
   --proxy= \
   --name=example-clickhouse \
   --protocol= \
   --uri=clickhouse.example.com:8443 \
   --labels=env=dev

Teleport 데이터베이스 서비스가 커스텀 CA를 신뢰하도록 구성하려면:

  1. 커스텀 CA의 CA 인증서를 내보내고 Teleport 데이터베이스 서비스 호스트의 /var/lib/teleport/db.ca에서 사용할 수 있도록 만듭니다.

  2. --ca-cert-file 플래그를 사용하는 위 명령의 변형을 실행합니다. 이렇게 하면 Teleport 데이터베이스 서비스가 db.ca의 CA 인증서를 사용하여 데이터베이스에서 오는 트래픽을 확인하도록 구성됩니다:

    $ sudo teleport db configure create \
       -o file \
       --token=/tmp/token \
       --proxy= \
       --name=example-clickhouse \
       --protocol= \
       --uri=clickhouse.example.com:8443 \
       --ca-cert-file="/var/lib/teleport/db.ca" \
       --labels=env=dev
    

Configure the Teleport Database Service to start automatically when the host boots up by creating a systemd service for it. The instructions depend on how you installed the Teleport Database Service.

You can check the status of the Teleport Database Service with systemctl status teleport and view its logs with journalctl -fu teleport.

Teleport는 Kubernetes 클러스터에 Teleport 데이터베이스 서비스를 설치하기 위한 Helm 차트를 제공합니다.

Configure Helm to fetch Teleport charts from the Teleport Helm repository:

$ helm repo add teleport (=teleport.helm_repo_url=)

Refresh the local Helm cache by fetching the latest charts:

$ helm repo update

Teleport 데이터베이스 서비스 구성으로 Teleport 에이전트를 Kubernetes 클러스터에 설치합니다.

다음 내용으로 values.yaml 파일을 만듭니다. Teleport Proxy 서비스의 호스트와 포트를 사용하도록 을 업데이트하고, 은 이전에 생성한 조인 토큰으로 설정합니다:

roles: db
proxyAddr:  name="teleport.example.com:443" />
# Teleport Community Edition을 사용하는 경우 false로 설정
enterprise: true
authToken:  name="JOIN_TOKEN" />
databases:
  - name: example-clickhouse
    uri: clickhouse.example.com:8443
    protocol:  name="protocol" />
tags:
  env: dev

Teleport 데이터베이스 서비스가 커스텀 CA를 신뢰하도록 구성하려면:

  1. 커스텀 CA의 CA 인증서를 내보내고 워크스테이션의 db.ca에서 사용할 수 있도록 만듭니다.

  2. 다음 명령을 사용하여 Teleport와 동일한 네임스페이스에 데이터베이스 CA 인증서를 포함하는 시크릿을 생성합니다:

    $ kubectl create secret generic db-ca --from-file=ca.pem=/path/to/db.ca
    
  3. values.yaml에 다음을 추가합니다:

  roles: db
  proxyAddr: teleport.example.com:443
  # Teleport Community Edition을 사용하는 경우 false로 설정
  enterprise: true
  authToken: JOIN_TOKEN
  databases:
    - name: example-clickhouse
      uri: clickhouse.example.com:8443
      protocol: <protocol>
+     tls:
+       ca_cert_file: "/etc/teleport-tls-db/db-ca/ca.pem"
      static_labels:
        env: dev
+ extraVolumes:
+   - name: db-ca
+     secret:
+       secretName: db-ca
+ extraVolumeMounts:
+   - name: db-ca
+     mountPath: /etc/teleport-tls-db/db-ca
+     readOnly: true

차트를 설치합니다:

$ helm install teleport-kube-agent teleport/teleport-kube-agent \
  --create-namespace \
  --namespace teleport-agent \
  --version (=teleport.version=) \
  -f values.yaml

Teleport 에이전트 파드가 실행 중인지 확인합니다. 단일 준비 완료 컨테이너가 있는 teleport-kube-agent 파드 하나가 표시되어야 합니다:

$ kubectl -n teleport-agent get pods
NAME                    READY   STATUS    RESTARTS   AGE
teleport-kube-agent-0   1/1     Running   0          32s

(!docs/pages/includes/database-access/multiple-instances-tip.mdx !)

5/5단계. 연결#

데이터베이스 서비스가 클러스터에 합류하면 로그인하여 사용 가능한 데이터베이스를 확인합니다:

Teleport에 로그인하고 연결할 수 있는 데이터베이스를 나열합니다. 이전에 등록한 ClickHouse 데이터베이스가 표시되어야 합니다:

$ tsh login --proxy= --user=alice
$ tsh db ls
# Name                      Description Allowed Users Labels  Connect
# ------------------------- ----------- ------------- ------- -------
# example-clickhouse-http               [*]           env=dev

GUI 데이터베이스 클라이언트를 통해 ClickHouse에 연결하거나 curl을 통해 요청을 보낼 수 있도록 인증된 프록시 터널을 생성합니다:

$ tsh proxy db --db-user=alice --tunnel example-clickhouse-http
# Started authenticated tunnel for the Clickhouse (HTTP) database "clickhouse-http" in cluster "teleport.example.com" on 127.0.0.1:59215.
# To avoid port randomization, you can choose the listening port using the --port flag.
#
# Use the following command to connect to the database or to the address above using other database GUI/CLI clients:
#   $ curl http://localhost:59215/

연결을 테스트하려면 다음 명령을 실행합니다:

$ echo 'select currentUser();' | curl http://localhost:59215/  --data-binary @-
# alice

데이터베이스에서 로그아웃하고 자격 증명을 제거하려면:

# 특정 데이터베이스 인스턴스의 자격 증명 제거.
$ tsh db logout example-clickhouse-http
# 모든 데이터베이스 인스턴스의 자격 증명 제거.
$ tsh db logout

Teleport에 로그인하고 연결할 수 있는 데이터베이스를 나열합니다. 이전에 등록한 ClickHouse 데이터베이스가 표시되어야 합니다:

$ tsh login --proxy= --user=alice
$ tsh db ls
# Name                    Description Allowed Users Labels  Connect
# ----------------------- ----------- ------------- ------- -------
# example-clickhouse                  [*]           env=dev

데이터베이스에 연결합니다:

$ tsh db connect --db-user=alice example-clickhouse
# ClickHouse client version 22.7.2.1.
# Connecting to localhost:59502 as user default.
# Connected to ClickHouse server version 23.4.2 revision 54462.
#
# 350ddafd1941 :) select 1;
#
# SELECT 1
#
# Query id: 327cfd34-2fec-4e04-a185-79fc840aa5cf
#
# ┌─1─┐
# │ 1 │
# └───┘
# ↓ Progress: 1.00 rows, 1.00 B (208.59 rows/s., 208.59 B/s.)                                                                                                                                                            (0.0 CPU, 9.19 KB RAM)
# 1 row in set. Elapsed: 0.005 sec.
#
# 350ddafd1941 :)

데이터베이스에서 로그아웃하고 자격 증명을 제거하려면:

# 특정 데이터베이스 인스턴스의 자격 증명 제거.
$ tsh db logout example-clickhouse
# 모든 데이터베이스 인스턴스의 자격 증명 제거.
$ tsh db logout

다음 단계#

ClickHouse 데이터베이스 접근

원문 보기
요약

Teleport ClickHouse 통합을 통해 ClickHouse 데이터베이스를 Teleport에 등록할 수 있습니다. 이 가이드를 통해 다음을 수행할 수 있습니다: Teleport 데이터베이스 서비스는 x509 인증서를 사용하여 ClickHouse에 인증하며, 이 인증서는 ClickHouse HTTP 및 Native(TCP) 인터페이스에서 사용 가능합니다.

Teleport ClickHouse 통합을 통해 ClickHouse 데이터베이스를 Teleport에 등록할 수 있습니다.

이 가이드를 통해 다음을 수행할 수 있습니다:

  • Teleport 데이터베이스 에이전트를 설치하고 구성합니다.
  • 셀프 호스팅 ClickHouse 데이터베이스에 접근하기 위해 Teleport를 설정합니다.
  • Teleport를 통해 데이터베이스에 연결합니다.

작동 방식#

Teleport 데이터베이스 서비스는 x509 인증서를 사용하여 ClickHouse에 인증하며, 이 인증서는 ClickHouse HTTP 및 Native(TCP) 인터페이스에서 사용 가능합니다. Teleport 데이터베이스 서비스는 ClickHouse Native(TCP) 및 HTTP 프로토콜 모두로 통신할 수 있으며, Teleport 데이터베이스 서비스를 구성할 때 사용할 프로토콜을 선택할 수 있습니다.

쿼리 활동에 대한 Teleport 감사 로그는 ClickHouse HTTP 인터페이스에서만 지원됩니다. ClickHouse의 네이티브 인터페이스에 대한 Teleport 지원에는 데이터베이스 쿼리 활동에 대한 감사 로그가 포함되지 않습니다.

셀프 호스팅 Teleport 클러스터로 ClickHouse 등록

클라우드 호스팅 Teleport 클러스터로 ClickHouse 등록

사전 조건#

  • 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 tctl and tsh clients.

    Installing `tctl` and `tsh` clients
    1. Determine the version of your Teleport cluster. The tctl and tsh clients must be at most one major version behind your Teleport cluster version. Send a GET request to the Proxy Service at /v1/webapi/find and 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')"
      
    2. Follow the instructions for your platform to install tctl and tsh clients:

  • Teleport 데이터베이스 서비스를 실행할 Linux 호스트 또는 Kubernetes 클러스터.

선택한 ClickHouse 프로토콜에 따라 다음도 필요합니다:

  • ClickHouse Server v22.3 이상의 셀프 호스팅 배포.
  • ClickHouse Server v23.3 이상의 셀프 호스팅 배포.
  • clickhouse-client가 설치되어 사용자의 PATH 환경 변수에 추가되어 있어야 합니다.
  • 선택 사항: 셀프 호스팅 데이터베이스에 대한 인증서를 발급하는 인증 기관.

1/5단계. Teleport 토큰 및 사용자 생성#

The Database Service requires a valid join token to join your Teleport cluster. Run the following tctl command and save the token output in /tmp/token on the server that will run the Database Service:

$ tctl tokens add --type=db --format=text
(=presets.tokens.first=)
Flag Description
--roles List of roles to assign to the user. The builtin access role allows them to connect to any database server registered with Teleport.
--db-users List of database usernames the user will be allowed to use when connecting to the databases. A wildcard allows any user.
--db-names List of logical databases (aka schemas) the user will be allowed to connect to within a database server. A wildcard allows any database.

For more detailed information about database access controls and how to restrict access see RBAC documentation.

2/5단계. 인증서/키 쌍 생성#

Teleport uses mutual TLS authentication with self-hosted databases. These databases must be able to verify certificates presented by the Teleport Database Service. Self-hosted databases also need a certificate/key pair that Teleport can verify.

By default, the Teleport Database Service trusts certificates issued by a certificate authority managed by the Teleport Auth Service. You can either:

  • Configure your self-hosted database to trust this CA, and instruct Teleport to issue a certificate for the database to present to the Teleport Database Service.
  • Configure the Database Service to trust a custom CA.

3/5단계. ClickHouse 구성#

생성된 시크릿을 사용하여 clickhouse-server/config.xml 구성 파일에서 상호 TLS를 활성화합니다:

<openSSL>
    <server>
       <privateKeyFile>/path/to/server.key</privateKeyFile>
       <caConfig>/path/to/server.cas</caConfig>
       <certificateFile>/path/to/server.crt</certificateFile>
       <verificationMode>strict</verificationMode>
    </server>
</openSSL>

이 구성을 활성화하려면 ClickHouse Server를 재시작하세요. 또한 ClickHouse 데이터베이스 사용자 계정은 유효한 클라이언트 인증서를 요구하도록 구성되어야 합니다:

CREATE USER alice IDENTIFIED WITH ssl_certificate CN 'alice';

기본적으로 생성된 사용자는 아무것에도 접근할 수 없어 연결할 수 없으므로 일부 권한을 부여합니다:

GRANT ALL ON *.* TO alice;

4/5단계. 데이터베이스 서비스 구성 및 시작#

Teleport 데이터베이스 서비스를 실행할 호스트 또는 Kubernetes 클러스터에 Teleport를 설치하고 구성합니다. HTTP 프로토콜에는 을 clickhouse-http로 지정하고, 네이티브 ClickHouse 프로토콜에는 clickhouse로 지정합니다:

To install a Teleport Agent on your Linux server:

The recommended installation method is the cluster install script. It will select the correct version, edition, and installation mode for your cluster.

  1. Assign to your Teleport cluster hostname and port, but not the scheme (https://).

  2. Run your cluster's install script:

    $ curl "https:///scripts/install.sh" | sudo bash
    
Note

아래 단계는 기존 구성 파일을 덮어쓰므로, 여러 서비스를 실행 중인 경우 --output=stdout을 추가하여 터미널에 구성을 출력하고 /etc/teleport.yaml을 수동으로 조정하세요.

Teleport 데이터베이스 서비스를 실행할 호스트에서 적절한 구성으로 Teleport를 시작합니다.

단일 Teleport 프로세스가 여러 다른 서비스를 실행할 수 있습니다. 예를 들어 여러 데이터베이스 서비스 에이전트뿐만 아니라 SSH 서비스 또는 애플리케이션 서비스도 함께 실행할 수 있습니다. 아래 단계는 기존 구성 파일을 덮어쓰므로, 여러 서비스를 실행 중인 경우 --output=stdout을 추가하여 터미널에 구성을 출력하고 /etc/teleport.yaml을 수동으로 조정하세요.

데이터베이스 서비스용 구성 파일을 /etc/teleport.yaml에 생성하려면 다음 명령을 실행하세요. Teleport Proxy 서비스의 호스트와 포트를 사용하도록 을 업데이트하세요:

$ sudo teleport db configure create \
   -o file \
   --token=/tmp/token \
   --proxy= \
   --name=example-clickhouse \
   --protocol= \
   --uri=clickhouse.example.com:8443 \
   --labels=env=dev

Teleport 데이터베이스 서비스가 커스텀 CA를 신뢰하도록 구성하려면:

  1. 커스텀 CA의 CA 인증서를 내보내고 Teleport 데이터베이스 서비스 호스트의 /var/lib/teleport/db.ca에서 사용할 수 있도록 만듭니다.

  2. --ca-cert-file 플래그를 사용하는 위 명령의 변형을 실행합니다. 이렇게 하면 Teleport 데이터베이스 서비스가 db.ca의 CA 인증서를 사용하여 데이터베이스에서 오는 트래픽을 확인하도록 구성됩니다:

    $ sudo teleport db configure create \
       -o file \
       --token=/tmp/token \
       --proxy= \
       --name=example-clickhouse \
       --protocol= \
       --uri=clickhouse.example.com:8443 \
       --ca-cert-file="/var/lib/teleport/db.ca" \
       --labels=env=dev
    

Configure the Teleport Database Service to start automatically when the host boots up by creating a systemd service for it. The instructions depend on how you installed the Teleport Database Service.

You can check the status of the Teleport Database Service with systemctl status teleport and view its logs with journalctl -fu teleport.

Teleport는 Kubernetes 클러스터에 Teleport 데이터베이스 서비스를 설치하기 위한 Helm 차트를 제공합니다.

Configure Helm to fetch Teleport charts from the Teleport Helm repository:

$ helm repo add teleport (=teleport.helm_repo_url=)

Refresh the local Helm cache by fetching the latest charts:

$ helm repo update

Teleport 데이터베이스 서비스 구성으로 Teleport 에이전트를 Kubernetes 클러스터에 설치합니다.

다음 내용으로 values.yaml 파일을 만듭니다. Teleport Proxy 서비스의 호스트와 포트를 사용하도록 을 업데이트하고, 은 이전에 생성한 조인 토큰으로 설정합니다:

roles: db
proxyAddr:  name="teleport.example.com:443" />
# Teleport Community Edition을 사용하는 경우 false로 설정
enterprise: true
authToken:  name="JOIN_TOKEN" />
databases:
  - name: example-clickhouse
    uri: clickhouse.example.com:8443
    protocol:  name="protocol" />
tags:
  env: dev

Teleport 데이터베이스 서비스가 커스텀 CA를 신뢰하도록 구성하려면:

  1. 커스텀 CA의 CA 인증서를 내보내고 워크스테이션의 db.ca에서 사용할 수 있도록 만듭니다.

  2. 다음 명령을 사용하여 Teleport와 동일한 네임스페이스에 데이터베이스 CA 인증서를 포함하는 시크릿을 생성합니다:

    $ kubectl create secret generic db-ca --from-file=ca.pem=/path/to/db.ca
    
  3. values.yaml에 다음을 추가합니다:

  roles: db
  proxyAddr: teleport.example.com:443
  # Teleport Community Edition을 사용하는 경우 false로 설정
  enterprise: true
  authToken: JOIN_TOKEN
  databases:
    - name: example-clickhouse
      uri: clickhouse.example.com:8443
      protocol: <protocol>
+     tls:
+       ca_cert_file: "/etc/teleport-tls-db/db-ca/ca.pem"
      static_labels:
        env: dev
+ extraVolumes:
+   - name: db-ca
+     secret:
+       secretName: db-ca
+ extraVolumeMounts:
+   - name: db-ca
+     mountPath: /etc/teleport-tls-db/db-ca
+     readOnly: true

차트를 설치합니다:

$ helm install teleport-kube-agent teleport/teleport-kube-agent \
  --create-namespace \
  --namespace teleport-agent \
  --version (=teleport.version=) \
  -f values.yaml

Teleport 에이전트 파드가 실행 중인지 확인합니다. 단일 준비 완료 컨테이너가 있는 teleport-kube-agent 파드 하나가 표시되어야 합니다:

$ kubectl -n teleport-agent get pods
NAME                    READY   STATUS    RESTARTS   AGE
teleport-kube-agent-0   1/1     Running   0          32s

(!docs/pages/includes/database-access/multiple-instances-tip.mdx !)

5/5단계. 연결#

데이터베이스 서비스가 클러스터에 합류하면 로그인하여 사용 가능한 데이터베이스를 확인합니다:

Teleport에 로그인하고 연결할 수 있는 데이터베이스를 나열합니다. 이전에 등록한 ClickHouse 데이터베이스가 표시되어야 합니다:

$ tsh login --proxy= --user=alice
$ tsh db ls
# Name                      Description Allowed Users Labels  Connect
# ------------------------- ----------- ------------- ------- -------
# example-clickhouse-http               [*]           env=dev

GUI 데이터베이스 클라이언트를 통해 ClickHouse에 연결하거나 curl을 통해 요청을 보낼 수 있도록 인증된 프록시 터널을 생성합니다:

$ tsh proxy db --db-user=alice --tunnel example-clickhouse-http
# Started authenticated tunnel for the Clickhouse (HTTP) database "clickhouse-http" in cluster "teleport.example.com" on 127.0.0.1:59215.
# To avoid port randomization, you can choose the listening port using the --port flag.
#
# Use the following command to connect to the database or to the address above using other database GUI/CLI clients:
#   $ curl http://localhost:59215/

연결을 테스트하려면 다음 명령을 실행합니다:

$ echo 'select currentUser();' | curl http://localhost:59215/  --data-binary @-
# alice

데이터베이스에서 로그아웃하고 자격 증명을 제거하려면:

# 특정 데이터베이스 인스턴스의 자격 증명 제거.
$ tsh db logout example-clickhouse-http
# 모든 데이터베이스 인스턴스의 자격 증명 제거.
$ tsh db logout

Teleport에 로그인하고 연결할 수 있는 데이터베이스를 나열합니다. 이전에 등록한 ClickHouse 데이터베이스가 표시되어야 합니다:

$ tsh login --proxy= --user=alice
$ tsh db ls
# Name                    Description Allowed Users Labels  Connect
# ----------------------- ----------- ------------- ------- -------
# example-clickhouse                  [*]           env=dev

데이터베이스에 연결합니다:

$ tsh db connect --db-user=alice example-clickhouse
# ClickHouse client version 22.7.2.1.
# Connecting to localhost:59502 as user default.
# Connected to ClickHouse server version 23.4.2 revision 54462.
#
# 350ddafd1941 :) select 1;
#
# SELECT 1
#
# Query id: 327cfd34-2fec-4e04-a185-79fc840aa5cf
#
# ┌─1─┐
# │ 1 │
# └───┘
# ↓ Progress: 1.00 rows, 1.00 B (208.59 rows/s., 208.59 B/s.)                                                                                                                                                            (0.0 CPU, 9.19 KB RAM)
# 1 row in set. Elapsed: 0.005 sec.
#
# 350ddafd1941 :)

데이터베이스에서 로그아웃하고 자격 증명을 제거하려면:

# 특정 데이터베이스 인스턴스의 자격 증명 제거.
$ tsh db logout example-clickhouse
# 모든 데이터베이스 인스턴스의 자격 증명 제거.
$ tsh db logout

다음 단계#