CircleCI에 tbot 배포
이 가이드에서는 CircleCI 워크플로 내에서 머신 및 워크로드 아이덴티티의 에이전트 tbot을 실행하도록 설정합니다. A running Teleport cluster. The tctl and tsh clients. Determine the version of your Teleport cluster.
이 가이드에서는 CircleCI 워크플로 내에서 머신 및 워크로드 아이덴티티의 에이전트 tbot을 실행하도록 설정합니다. 봇은 장기 시크릿의 필요성을 제거하기 위해 circleci 위임 조인 방법을 사용하도록 설정됩니다.
사전 조건#
-
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:
-
To check that you can connect to your Teleport cluster, sign in with tsh login, then
verify that you can run tctl commands using your current credentials.
For example, run the following command, assigning to the domain name of the Teleport Proxy Service in your cluster and to your Teleport username:
$ tsh login --proxy= --user=
$ tctl status
# Cluster (=teleport.url=)
# Version (=teleport.version=)
# CA pin (=presets.ca_pin=)
If you can connect to the cluster and run the tctl status command, you can use your
current credentials to run subsequent tctl commands from your workstation.
If you host your own Teleport cluster, you can also run tctl commands on the computer that
hosts the Teleport Auth Service for full permissions.
- 푸시할 수 있는 Git 저장소에 연결된 CircleCI 프로젝트.
1단계/5단계. CircleCI 설정#
Teleport 클러스터에 연결할 수 있는 CircleCI 워크플로에 대한 규칙을 설정하려면 CircleCI 조직의 ID를 확인하고 CircleCI 컨텍스트를 만들어야 합니다.
조직 ID 찾기#
CircleCI를 열고 탐색 모음에서 "Organization settings"로 이동합니다. "Organization ID"라는 섹션이 있는 "Overview" 인터페이스가 표시됩니다. 이 값을 기록해 두고 설정 예시에서 를 이것으로 대체합니다.
컨텍스트 만들기#
CircleCI에는 컨텍스트라는 조직 수준의 개념이 있어 워크플로 작업에 노출되어야 하는 일련의 시크릿을 설정할 수 있습니다. 컨텍스트와 관련된 작업을 트리거할 수 있는 사용자를 제어하도록 CircleCI를 설정할 수 있습니다.
워크플로 작업에 할당된 컨텍스트는 CircleCI가 작업에 대해 생성하는 아이덴티티 토큰에도 인코딩됩니다. 이를 통해 Teleport가 Teleport 클러스터에 접근을 허용해야 하는 CircleCI 작업을 결정하는 이상적인 방법이 됩니다.
이 예시에서는 teleport-access라는 CircleCI 컨텍스트를 만듭니다. 그런 다음 이 컨텍스트에 Teleport 클러스터에 대한 접근을 허용합니다.
CircleCI 컨텍스트를 만들려면 CircleCI에서 "Organization settings"를 열고 "Contexts"로 이동합니다. "Create Context"를 클릭하고 만들려는 컨텍스트 이름으로 를 제공합니다. 이 값을 조직에 더 적합한 문자열로 대체할 수 있지만, 이 가이드의 이후 단계에서 를 해당 값으로 교체해야 합니다.
방금 만든 컨텍스트를 선택합니다. 이제 컨텍스트를 설정할 수 있는 페이지에 있습니다. Teleport를 설정할 때 사용할 컨텍스트의 ID를 확인하려면 다음과 유사한 형식의 URL이 있는 컨텍스트 설정 페이지의 URL을 찾습니다:
https://app.circleci.com/settings/organization/github/gravitational/contexts/00000000-0000-0000-0000-000000000000
이 경우 컨텍스트 ID는 00000000-0000-0000-0000-000000000000입니다.
이 값을 기록해 두고 설정 예시에서 를 이것으로 대체합니다.
2단계/5단계. 봇 만들기#
Next, you need to create a Bot. A Bot is a Teleport identity for a machine or group of machines. Like users, bots have a set of roles and traits which define what they can access.
Create bot.yaml:
kind: bot
version: v1
metadata:
# name is a unique identifier for the Bot in the cluster.
name: example
spec:
# roles is a list of roles to grant to the Bot. Don't worry if you don't know
# what roles you need to specify here, the Access Guides will walk you through
# creating and assigning roles to the already created Bot.
roles: []
Make sure you replace example with a unique, descriptive name for your Bot.
Use tctl to apply this file:
$ tctl create bot.yaml
3단계/5단계. CircleCI용 조인 토큰 만들기#
CircleCI 워크플로가 Teleport 클러스터에 인증할 수 있도록 하려면 먼저 조인 토큰을 만들어야 합니다. 이 토큰은 Auth Service가 봇 또는 노드의 조인을 허용할지 여부를 결정하는 기준을 설정합니다.
bot-token.yaml 파일을 만들고 와 를 1단계의 값으로 교체합니다.
kind: token
version: v2
metadata:
name: example-bot
spec:
roles: [Bot]
join_method: circleci
bot_name: example
circleci:
organization_id: name="organization-id" />
# allow는 Auth Service가 `tbot`의 조인 허용 여부를 결정하는 규칙을 지정합니다.
allow:
- context_id: name="context-id" />
토큰 리소스의 필드를 자세히 살펴봅니다:
metadata.name은 토큰의 이름을 정의합니다. 이 값은 나중에 설정의 다른 부분에서 사용해야 합니다.spec.bot_name은 이 토큰이 접근을 허용할 Machine ID 봇의 이름입니다. 이 값은 나중에 설정의 다른 부분에서 사용해야 합니다.spec.roles는 이 토큰이 접근을 허용할 역할을 정의합니다.[Bot]값은 이 토큰이 머신 및 워크로드 아이덴티티 봇에 대한 접근을 허용함을 나타냅니다.spec.join_method는 토큰이 적용 가능한 조인 방법을 정의합니다. 이 가이드는 CircleCI에만 초점을 맞추므로circleci로 설정합니다.spec.circleci.allow는 토큰을 사용하여 인증할 수 있는 CircleCI 실행에 대한 규칙을 설정하는 데 사용됩니다.
tctl을 사용하여 이 파일을 Teleport 클러스터에 적용합니다:
$ tctl create -f bot-token.yaml
4단계/5단계. CircleCI 워크플로 설정#
봇과 조인 토큰이 만들어지면 Teleport 클러스터에 연결할 수 있는 CircleCI 워크플로를 설정할 수 있습니다.
tbot을 설정하기 위해 YAML 파일이 사용됩니다. 이 예시에서는 저장소 자체 내에 저장하지만 CI 파이프라인 자체에서 생성하거나 만들 수 있습니다.
저장소 내에 tbot.yaml을 만듭니다:
version: v2
proxy_server: name="example.teleport.sh"/>:443
onboarding:
join_method: circleci
token: example-bot
oneshot: true
storage:
type: memory
# services는 접근 가이드를 완료하는 동안 채워집니다.
services: []
교체:
- 를 Teleport Proxy 또는 Auth Service의 주소로. Teleport Proxy의 주소를 사용하는 것이 좋습니다.
example-bot을 세 번째 단계에서 만든 토큰 이름으로.
이제 CircleCI 파이프라인을 정의할 수 있습니다. 파이프라인이 tbot을 사용하기 전에 환경 내에서 사용 가능해야 합니다. 이 예시에서는 CI 단계의 일부로 tbot을 다운로드하는 것을 보여주지만, 프로덕션 구현에서는 Teleport CDN에 의존하지 않도록 이 바이너리를 포함하는 docker 이미지를 구축하는 것이 좋습니다.
Git 저장소를 열고 .circleci라는 디렉터리를 만듭니다. 그런 다음 config.yml 파일을 열고 다음 설정을 삽입합니다:
# See: https://circleci.com/docs/configuration-reference
version: 2.1
jobs:
write-run-log:
docker:
- image: cimg/base:stable
steps:
- checkout
- run:
name: "Install Teleport"
command: |
curl "https://:443/scripts/install.sh" | sudo bash
- run:
name: "Run 머신 및 워크로드 아이덴티티"
command: |
export TELEPORT_ANONYMOUS_TELEMETRY=1
tbot start -c tbot.yaml
workflows:
write-run-log:
jobs:
- write-run-log:
context:
- teleport-access
를 Teleport Proxy Service의 주소로 교체합니다.
TELEPORT_ANONYMOUS_TELEMETRY는 익명 사용 텔레메트리 제출을 활성화합니다. 이는 tbot의 미래 개발을 형성하는 데 도움이 됩니다. 이것을 생략하면 비활성화할 수 있습니다.
이 두 설정 파일을 저장소에 추가, 커밋, 푸시합니다.
CircleCI를 열고 작업 상태를 확인하고 완료될 때까지 기다리며 오류가 발생하지 않는지 확인합니다.
보안 의미 및 위험에 대한 참고 사항#
작업에서 tbot start를 사용하면 해당 작업의 모든 후속 단계가 tbot이 생성한 자격 증명에 접근할 수 있습니다. 이 자격 증명에 접근하는 단계의 수를 줄이기 위해 워크플로를 여러 작업으로 분리합니다.
CircleCI 봇에 할당하는 역할이 CI/CD가 상호 작용해야 하는 Teleport 클러스터의 리소스에만 접근할 수 있는지 확인합니다.
5단계/5단계. 서비스 설정#
You have now prepared the base configuration for tbot. At this point, it
identifies itself to the Teleport cluster and renews its own credentials but
does not output any credentials for other applications to use.
Follow one of the access guides to configure a service that meets your access needs.
추가 단계#
- 접근 가이드를 따라 환경에 맞게
tbot을 마저 설정합니다. - 사용 가능한 모든 설정 옵션을 확인하려면 설정 레퍼런스를 읽으세요.
- CircleCI 자체에 대한 자세한 내용은 CircleCI 문서를 읽으세요.
TELEPORT_ANONYMOUS_TELEMETRY에 대한 자세한 정보.
