InfoGrab Docs

쿠버네티스 클러스터 등록 시작하기

요약

이 가이드는 보호하려는 쿠버네티스 클러스터에 Teleport 쿠버네티스 서비스를 배포하여 쿠버네티스 클러스터를 Teleport 리소스로 등록하는 방법을 설명합니다. 이 시나리오에서 Teleport 쿠버네티스 서비스 파드는 쿠버네티스에서 실행 중임을 감지하고 자동으로 쿠버네티스 클러스터를 등록합니다.

이 가이드는 보호하려는 쿠버네티스 클러스터에 Teleport 쿠버네티스 서비스를 배포하여 쿠버네티스 클러스터를 Teleport 리소스로 등록하는 방법을 설명합니다.

작동 방식#

이 시나리오에서 Teleport 쿠버네티스 서비스 파드는 쿠버네티스에서 실행 중임을 감지하고 자동으로 쿠버네티스 클러스터를 등록합니다. 다음 다이어그램은 쿠버네티스 클러스터에서 Teleport 쿠버네티스 서비스가 실행되는 이 배포 시나리오의 간략한 개요를 제공합니다:

쿠버네티스 클러스터 등록

쿠버네티스 클러스터를 등록하고 탐색하는 다른 방법에 대한 자세한 내용은 Teleport로 쿠버네티스 클러스터 등록을 참조하세요.

사전 조건#

  • 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:

  • Kubernetes >= v(=kubernetes.major_version=).(=kubernetes.minor_version=).0

  • Helm >= (=helm.version=)

    Verify that Helm and Kubernetes are installed and up to date.

    $ helm version
    # version.BuildInfo{Version:"v(=helm.version=)"}
    
    $ kubectl version
    # Client Version: version.Info{Major:"(=kubernetes.major_version=)", Minor:"(=kubernetes.minor_version=)+"}
    # Server Version: version.Info{Major:"(=kubernetes.major_version=)", Minor:"(=kubernetes.minor_version=)+"}
    

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.

1/3단계. RBAC 리소스 생성#

Teleport를 사용하여 쿠버네티스 클러스터에 인증하려면, 상호작용할 쿠버네티스 클러스터에 대한 접근 권한을 부여하는 Teleport 역할이 있어야 합니다.

이 단계에서는 viewers 그룹의 구성원으로서 Teleport로 보호된 모든 쿠버네티스 클러스터에 요청을 보낼 수 있는 kube-access라는 Teleport 역할을 생성하는 방법을 안내합니다. Teleport 쿠버네티스 서비스는 사용자의 요청을 프록시할 때 viewers 그룹을 가장합니다.

  1. 다음 내용으로 kube-access.yaml 파일을 생성합니다:

    kind: role
    metadata:
      name: kube-access
    version: v7
    spec:
      allow:
        kubernetes_labels:
          '*': '*'
        kubernetes_resources:
          - kind: '*'
            namespace: '*'
            name: '*'
            verbs: ['*']
        kubernetes_groups:
        - viewers
      deny: {}
    
  2. 변경 사항을 적용합니다:

    $ tctl create -f kube-access.yaml
    

Assign the kube-access role to your Teleport user by running the appropriate commands for your authentication provider:

kube-access 역할에 viewers 그룹의 구성원으로 쿠버네티스 클러스터에 접근할 수 있는 권한을 부여했지만, 이 그룹은 아직 해당 쿠버네티스 클러스터 내에서 권한이 없습니다. 이 권한을 할당하려면 viewers 그룹에 권한을 부여하는 쿠버네티스 RoleBinding 또는 ClusterRoleBindings를 생성합니다.

  1. 다음 내용으로 viewers-bind.yaml 파일을 생성합니다:

    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRoleBinding
    metadata:
      name: viewers-crb
    subjects:
    - kind: Group
      # Bind the group "viewers" to the kubernetes_groups assigned in the "kube-access" role
      name: viewers
      apiGroup: rbac.authorization.k8s.io
    roleRef:
      kind: ClusterRole
      # "view" is a default ClusterRole that grants read-only access to resources
      # See: https://kubernetes.io/docs/reference/access-authn-authz/rbac/#user-facing-roles
      name: view
      apiGroup: rbac.authorization.k8s.io
    
  2. kubectlClusterRoleBinding을 적용합니다:

    $ kubectl apply -f viewers-bind.yaml
    

이제 Teleport 사용자는 쿠버네티스 클러스터에 접근할 때 viewers 그룹의 구성원 자격을 가정할 수 있는 권한이 있으며, viewers 그룹은 클러스터의 리소스를 조회할 수 있는 권한을 가집니다. 다음 단계는 사용자 요청을 프록시하기 위해 클러스터에 Teleport 쿠버네티스 서비스를 배포하는 것입니다.

2/3단계. 안내형 등록 지침 따르기#

이 단계에서는 Teleport Web UI에서 스크립트를 복사하고 터미널에서 실행하여 쿠버네티스 클러스터에 Teleport 쿠버네티스 서비스를 배포합니다.

  1. Teleport Web UI를 열고 관리자 계정으로 로그인합니다.

  2. **새 리소스 등록(Enroll New Resource)**을 클릭합니다.

  3. 검색 필드에 Kubernetes의 전체 또는 일부를 입력하여 표시되는 리소스 유형을 필터링한 다음 Kubernetes를 클릭합니다.

  4. teleport-agent 차트 리포지터리를 추가하는 명령을 복사하여 워크스테이션의 터미널에 붙여넣습니다.

  5. Teleport 쿠버네티스 서비스를 배포할 네임스페이스와 이 클러스터에 연결할 때 사용할 표시 이름으로 teleport-agent를 입력한 다음 **다음(Next)**을 클릭합니다.

    다음을 클릭하면 Teleport가 쿠버네티스 클러스터를 Teleport 클러스터의 리소스로 구성하고 등록하는 스크립트를 생성합니다.

  6. Teleport Web UI에 표시된 명령을 복사하여 터미널에서 실행합니다.

    Teleport Web UI에 "새 쿠버네티스 클러스터가 성공적으로 감지되었습니다(Successfully detected your new Kubernetes cluster)"라는 메시지가 클러스터 등록 확인으로 표시됩니다. 이 메시지가 표시되면 **다음(Next)**을 클릭하여 계속합니다.

3/3단계. 쿠버네티스 접근 테스트#

쿠버네티스 클러스터에 Teleport 쿠버네티스 서비스를 배포하고 클러스터를 Teleport 리소스로 등록했으므로, viewers 그룹의 구성원으로 쿠버네티스 클러스터에 접근할 수 있는지 확인합니다.

이 가이드의 이전 단계를 따랐다면, 접근 설정(Set Up Access) 보기에서 쿠버네티스 그룹(Kubernetes Groups) 필드가 viewers로 채워집니다.

접근을 설정하고 테스트하려면:

  1. **다음(Next)**을 클릭합니다.

  2. teleport-agent 네임스페이스, 이전 단계의 쿠버네티스 viewers 그룹, 그리고 Teleport 사용자 이름을 지정합니다.

  3. Teleport Web UI에 표시된 명령을 복사하여 실행하면 쿠버네티스 클러스터와 상호작용하고 Teleport를 통한 접근을 검증할 수 있습니다. 또는 아래에 표시된 명령을 실행합니다:

    Teleport 클러스터에 인증합니다. 에는 클러스터 도메인을, 에는 Teleport 사용자 이름을 할당합니다:

    $ tsh login --proxy=:443 --auth=local --user=
    

    접근 가능한 쿠버네티스 클러스터를 나열합니다:

    $ tsh kube ls
    

    쿠버네티스 클러스터에 접근하기 위한 자격 증명을 가져옵니다. 을 쿠버네티스 클러스터 이름으로 교체합니다:

    $ tsh kube login 
    

    Teleport 쿠버네티스 서비스가 kubectl 명령을 프록시합니다:

    $ kubectl get pods -n teleport-agent
    

    이전에 배포한 Teleport 쿠버네티스 서비스 파드가 표시됩니다:

    NAME               READY   STATUS    RESTARTS   AGE
    teleport-agent-0   1/1     Running   0          8m6s
    
  4. **완료(Finish)**를 클릭합니다.

다음 단계#

이 가이드는 쿠버네티스 클러스터 내에서 Teleport 쿠버네티스 서비스를 실행하여 쿠버네티스 클러스터를 등록하는 방법을 설명했습니다.

쿠버네티스 클러스터 등록 시작하기

원문 보기
요약

이 가이드는 보호하려는 쿠버네티스 클러스터에 Teleport 쿠버네티스 서비스를 배포하여 쿠버네티스 클러스터를 Teleport 리소스로 등록하는 방법을 설명합니다. 이 시나리오에서 Teleport 쿠버네티스 서비스 파드는 쿠버네티스에서 실행 중임을 감지하고 자동으로 쿠버네티스 클러스터를 등록합니다.

이 가이드는 보호하려는 쿠버네티스 클러스터에 Teleport 쿠버네티스 서비스를 배포하여 쿠버네티스 클러스터를 Teleport 리소스로 등록하는 방법을 설명합니다.

작동 방식#

이 시나리오에서 Teleport 쿠버네티스 서비스 파드는 쿠버네티스에서 실행 중임을 감지하고 자동으로 쿠버네티스 클러스터를 등록합니다. 다음 다이어그램은 쿠버네티스 클러스터에서 Teleport 쿠버네티스 서비스가 실행되는 이 배포 시나리오의 간략한 개요를 제공합니다:

쿠버네티스 클러스터 등록

쿠버네티스 클러스터를 등록하고 탐색하는 다른 방법에 대한 자세한 내용은 Teleport로 쿠버네티스 클러스터 등록을 참조하세요.

사전 조건#

  • 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:

  • Kubernetes >= v(=kubernetes.major_version=).(=kubernetes.minor_version=).0

  • Helm >= (=helm.version=)

    Verify that Helm and Kubernetes are installed and up to date.

    $ helm version
    # version.BuildInfo{Version:"v(=helm.version=)"}
    
    $ kubectl version
    # Client Version: version.Info{Major:"(=kubernetes.major_version=)", Minor:"(=kubernetes.minor_version=)+"}
    # Server Version: version.Info{Major:"(=kubernetes.major_version=)", Minor:"(=kubernetes.minor_version=)+"}
    

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.

1/3단계. RBAC 리소스 생성#

Teleport를 사용하여 쿠버네티스 클러스터에 인증하려면, 상호작용할 쿠버네티스 클러스터에 대한 접근 권한을 부여하는 Teleport 역할이 있어야 합니다.

이 단계에서는 viewers 그룹의 구성원으로서 Teleport로 보호된 모든 쿠버네티스 클러스터에 요청을 보낼 수 있는 kube-access라는 Teleport 역할을 생성하는 방법을 안내합니다. Teleport 쿠버네티스 서비스는 사용자의 요청을 프록시할 때 viewers 그룹을 가장합니다.

  1. 다음 내용으로 kube-access.yaml 파일을 생성합니다:

    kind: role
    metadata:
      name: kube-access
    version: v7
    spec:
      allow:
        kubernetes_labels:
          '*': '*'
        kubernetes_resources:
          - kind: '*'
            namespace: '*'
            name: '*'
            verbs: ['*']
        kubernetes_groups:
        - viewers
      deny: {}
    
  2. 변경 사항을 적용합니다:

    $ tctl create -f kube-access.yaml
    

Assign the kube-access role to your Teleport user by running the appropriate commands for your authentication provider:

kube-access 역할에 viewers 그룹의 구성원으로 쿠버네티스 클러스터에 접근할 수 있는 권한을 부여했지만, 이 그룹은 아직 해당 쿠버네티스 클러스터 내에서 권한이 없습니다. 이 권한을 할당하려면 viewers 그룹에 권한을 부여하는 쿠버네티스 RoleBinding 또는 ClusterRoleBindings를 생성합니다.

  1. 다음 내용으로 viewers-bind.yaml 파일을 생성합니다:

    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRoleBinding
    metadata:
      name: viewers-crb
    subjects:
    - kind: Group
      # Bind the group "viewers" to the kubernetes_groups assigned in the "kube-access" role
      name: viewers
      apiGroup: rbac.authorization.k8s.io
    roleRef:
      kind: ClusterRole
      # "view" is a default ClusterRole that grants read-only access to resources
      # See: https://kubernetes.io/docs/reference/access-authn-authz/rbac/#user-facing-roles
      name: view
      apiGroup: rbac.authorization.k8s.io
    
  2. kubectlClusterRoleBinding을 적용합니다:

    $ kubectl apply -f viewers-bind.yaml
    

이제 Teleport 사용자는 쿠버네티스 클러스터에 접근할 때 viewers 그룹의 구성원 자격을 가정할 수 있는 권한이 있으며, viewers 그룹은 클러스터의 리소스를 조회할 수 있는 권한을 가집니다. 다음 단계는 사용자 요청을 프록시하기 위해 클러스터에 Teleport 쿠버네티스 서비스를 배포하는 것입니다.

2/3단계. 안내형 등록 지침 따르기#

이 단계에서는 Teleport Web UI에서 스크립트를 복사하고 터미널에서 실행하여 쿠버네티스 클러스터에 Teleport 쿠버네티스 서비스를 배포합니다.

  1. Teleport Web UI를 열고 관리자 계정으로 로그인합니다.

  2. **새 리소스 등록(Enroll New Resource)**을 클릭합니다.

  3. 검색 필드에 Kubernetes의 전체 또는 일부를 입력하여 표시되는 리소스 유형을 필터링한 다음 Kubernetes를 클릭합니다.

  4. teleport-agent 차트 리포지터리를 추가하는 명령을 복사하여 워크스테이션의 터미널에 붙여넣습니다.

  5. Teleport 쿠버네티스 서비스를 배포할 네임스페이스와 이 클러스터에 연결할 때 사용할 표시 이름으로 teleport-agent를 입력한 다음 **다음(Next)**을 클릭합니다.

    다음을 클릭하면 Teleport가 쿠버네티스 클러스터를 Teleport 클러스터의 리소스로 구성하고 등록하는 스크립트를 생성합니다.

  6. Teleport Web UI에 표시된 명령을 복사하여 터미널에서 실행합니다.

    Teleport Web UI에 "새 쿠버네티스 클러스터가 성공적으로 감지되었습니다(Successfully detected your new Kubernetes cluster)"라는 메시지가 클러스터 등록 확인으로 표시됩니다. 이 메시지가 표시되면 **다음(Next)**을 클릭하여 계속합니다.

3/3단계. 쿠버네티스 접근 테스트#

쿠버네티스 클러스터에 Teleport 쿠버네티스 서비스를 배포하고 클러스터를 Teleport 리소스로 등록했으므로, viewers 그룹의 구성원으로 쿠버네티스 클러스터에 접근할 수 있는지 확인합니다.

이 가이드의 이전 단계를 따랐다면, 접근 설정(Set Up Access) 보기에서 쿠버네티스 그룹(Kubernetes Groups) 필드가 viewers로 채워집니다.

접근을 설정하고 테스트하려면:

  1. **다음(Next)**을 클릭합니다.

  2. teleport-agent 네임스페이스, 이전 단계의 쿠버네티스 viewers 그룹, 그리고 Teleport 사용자 이름을 지정합니다.

  3. Teleport Web UI에 표시된 명령을 복사하여 실행하면 쿠버네티스 클러스터와 상호작용하고 Teleport를 통한 접근을 검증할 수 있습니다. 또는 아래에 표시된 명령을 실행합니다:

    Teleport 클러스터에 인증합니다. 에는 클러스터 도메인을, 에는 Teleport 사용자 이름을 할당합니다:

    $ tsh login --proxy=:443 --auth=local --user=
    

    접근 가능한 쿠버네티스 클러스터를 나열합니다:

    $ tsh kube ls
    

    쿠버네티스 클러스터에 접근하기 위한 자격 증명을 가져옵니다. 을 쿠버네티스 클러스터 이름으로 교체합니다:

    $ tsh kube login 
    

    Teleport 쿠버네티스 서비스가 kubectl 명령을 프록시합니다:

    $ kubectl get pods -n teleport-agent
    

    이전에 배포한 Teleport 쿠버네티스 서비스 파드가 표시됩니다:

    NAME               READY   STATUS    RESTARTS   AGE
    teleport-agent-0   1/1     Running   0          8m6s
    
  4. **완료(Finish)**를 클릭합니다.

다음 단계#

이 가이드는 쿠버네티스 클러스터 내에서 Teleport 쿠버네티스 서비스를 실행하여 쿠버네티스 클러스터를 등록하는 방법을 설명했습니다.