2024.11.19 - [devops/minikube] - 3. Connect to Minikube Cluster via Teleport(1)
3. Connect to Minikube Cluster via Teleport(1)
Teleport란 무엇인가?텔레포트는 원래 인프라 접근을 위해 인증서 기반으로 사용자를 관리하는 솔루션인데 쿠버네티스에서 사용할 수 있다. 실제로 현업에서도 많이 쓰기도 하고, 재택을 많이 차
ggorockee.tistory.com
에 이어서 teleport를 올리도록 하겠다. 인증서와 domain만 있으면 teleport를 올리는 것은 참 쉽다.(이 부분이 초심자에게는 어려워서 그렇지..)
텔레포트를 올리는 방법은 아래 링크를 참고하면된다.
https://goteleport.com/docs/admin-guides/deploy-a-cluster/linux-demo/
Run a Self-Hosted Demo Cluster | Teleport Docs
This tutorial will guide you through the steps needed to install and run Teleport on a Linux server
goteleport.com
$ curl https://cdn.teleport.dev/install-v16.4.7.sh | bash -s 16.4.7
설치가 되었으면 $HOME 폴더에 있는 key 파일을 옮기도록 하자.
$ sudo mv fullchain.pem /var/lib/teleport/
$ sudo mv privkey.pem /var/lib/teleport/
이제 텔레포트를 구동시킬 준비는 되었다.
$ sudo teleport configure -o file \
--cluster-name=teleport.dev.xxxx.com \
--public-addr=teleport.dev.xxxx.com:443 \
--cert-file=/var/lib/teleport/fullchain.pem \
--key-file=/var/lib/teleport/privkey.pem
서비스도 등록하고 확인해보자.
$ sudo systemctl enable teleport
$ sudo systemctl start teleport
$ sudo systemctl status teleport
● teleport.service - Teleport Service
Loaded: loaded (/lib/systemd/system/teleport.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2024-11-14 06:48:25 UTC; 41s ago
Main PID: 186884 (teleport)
Tasks: 16 (limit: 18715)
Memory: 102.8M
CGroup: /system.slice/teleport.service
└─186884 /usr/local/bin/teleport start --config /etc/teleport.yaml --pid-file=/run/teleport.pid
Nov 14 06:48:28 ip-172-31-15-127 teleport[186884]: 2024-11-14T06:48:28Z INFO [PROC:1] Starting proxy gRPC server. pid:186884.1 listen_address:[::]:443 service/service.go:6448
Nov 14 06:48:28 ip-172-31-15-127 teleport[186884]: 2024-11-14T06:48:28Z INFO [PROXY:AGE] Starting reverse tunnel agent pool. service/service.go:4813
Nov 14 06:48:28 ip-172-31-15-127 teleport[186884]: 2024-11-14T06:48:28Z INFO [DB:SERVIC] Starting Database Postgres proxy server. pid:186884.1 listen_address:[::]:443 service/service.go:5008
Nov 14 06:48:28 ip-172-31-15-127 teleport[186884]: 2024-11-14T06:48:28Z INFO [DB:SERVIC] Starting Database TLS proxy server. pid:186884.1 listen_address:0.0.0.0:443 service/service.go:5026
Nov 14 06:48:28 ip-172-31-15-127 teleport[186884]: 2024-11-14T06:48:28Z INFO [PROC:1] Starting proxy gRPC server. pid:186884.1 listen_address:[::]:443 service/service.go:6525
Nov 14 06:48:28 ip-172-31-15-127 teleport[186884]: 2024-11-14T06:48:28Z INFO [PROC:1] Service is creating new listener. pid:186884.1 type:node address:0.0.0.0:3022 service/signals.go:249
Nov 14 06:48:28 ip-172-31-15-127 teleport[186884]: 2024-11-14T06:48:28Z INFO [NODE:1] SSH Service is starting. pid:186884.1 version:16.4.7 git_ref:v16.4.7-0-g15dfef1 listen_address:0.0.0.0:3022 cache_pol>
Nov 14 06:48:28 ip-172-31-15-127 teleport[186884]: 2024-11-14T06:48:28Z INFO [PROXY:SER] Starting TLS ALPN SNI proxy server on. pid:186884.1 listen_address:[::]:443 service/service.go:5108
Nov 14 06:48:28 ip-172-31-15-127 teleport[186884]: 2024-11-14T06:48:28Z INFO [PROC:1] The new service has started successfully. Starting syncing rotation status. pid:186884.1 max_retry_period:1m30s servi>
Nov 14 06:48:28 ip-172-31-15-127 teleport[186884]: 2024-11-14T06:48:28Z INFO [HOSTUSERS] Attempting to delete all temporary host users srv/usermgmt.go:545
service가 정상적으로 올라갔다. ㅠㅠㅠㅠㅠㅠㅠㅠ
하지만 아직 이주소로는 연결이 되지 않는데 이 문제는 AWS의 LoadBalancer를 연결해서 해결할 수 있다.
1. 인증서 추가
방금 만들었던 인증서 파일을 aws certificate manager에 import한다.
fullchian에는 2개의 인증서가 있는데 첫번째는 certificate body에 2번째는 chain에 key는 private key에 복사하면된다.
이렇게 넣어주면 인증서가 활성화된다. 이제 이 인증서를 이용해서 LoadBalancer를 만들어준다.
AWS LoadBalancer는 target group이 필요하다. https 타겟 그룹으로 만들자. 타겟그룹만들때 acm은 방금 import한 것을 사용한다.
taget group을 만들었으니 이제 LoadBalancer를 올리자. Application Load Balancer로 만들면된다. 추가적으로 http로 요청이 오면 https로 리다이렉트되게 해줬다.
여기에 나와있는 DNS name (A Record)를 복사해서 route53에 teleport.dev.abc.com에 A Record로 추가해주면된다.
접속해보자!!!
오래 걸렸지만 드디어 성공했다. 인증서도 Let's Encrypt로 잘들어간 것을 볼수가 있다.
약관에 동의하고 user를 추가하자.
$ sudo tctl users add ggorokee --roles=editor,access --logins=root,ubuntu,ec2-user
User "ggorokee" has been created but requires a password. Share this URL with the user to complete user setup, link is valid for 1h:
https://teleport.dev.abc.com:443/web/invite/20d0a540008ca435fff2cd9d62303547
NOTE: Make sure teleport.dev.abc.com:443 points at a Teleport proxy which users can access.
나는 user이름을 ggorockee로 했는데 teleport-admin, admin등 다른 것으로 해도 좋다. 그렇게 하면 링크를 던져주는데 그걸 클릭해서 비밀번호를 설정해주자.
아까 들어갔던 https://teleport.dev.abc.com으로 들어가게 되면 방금 만들었던 User로 로그인 하자.
그리고 MFA값을 쓰라고 하는데
https://play.google.com/store/apps/details?id=com.azure.authenticator&hl=en
Microsoft Authenticator - Apps on Google Play
No more passwords, easier sign-in, and greater protection for your accounts.
play.google.com
app을 모바일에 설치해서 등록해서 사용하면된다.
이렇게 화면이 나타나면 성공한거다. !!!!
이제 kubernetes와 연결이 된것이냐 그것은 아니다. 현재 local이든 외부든 teleport-cluster와 연결이 된 것이고, teleport-cluster와 kubernetes를 연결해야 비로소 완전히 연결되는 것이다. 아직 우리는 여기까지 진행은 하지 않았기에 아직 사용할 수 없다. 다음 포스트에서 텔레포트를 마무리 짓고 다음 스텝으로 가자!
'devops > minikube' 카테고리의 다른 글
6. Istio: 서비스 메쉬의 선두주자 (25) | 2024.11.19 |
---|---|
5. Connect to Minikube Cluster via Teleport(3) (25) | 2024.11.19 |
3. Connect to Minikube Cluster via Teleport(1) (24) | 2024.11.19 |
2. Minikube on EC2 (25) | 2024.11.19 |
1. EKS는 너무 비싸다 (2) | 2024.11.19 |