내용 작성

This commit is contained in:
정훈 변
2024-04-19 12:16:07 +09:00
parent efc03ec608
commit ed621393ba
3 changed files with 400 additions and 73 deletions

161
README.md
View File

@@ -1,93 +1,108 @@
# teleport # Teleport
## 설명
접근 제어를 위한 오픈소스 솔루션으로 Teleport 도입을 결정<br>
기존에 설치 및 설정 하였던 정보를 정리할 목적으로 작성<br>
권한 설정 같은 경우 별도의 레파지토리로 작성하였음 ([바로가기](https://lab.jhcloud.kr/sa_8001/teleport_role))
## 설치
Teleport의 설치 같은 경우 docker와 helm chart를 통한 설치 방식 두가지를 사용 하였음<br>
devops팀 : helm chart<br>
기술지원팀 : docker<br>
## Getting started ### Docker
```shell
mkdir -p ~/teleport/config ~/teleport/data
# teleport config와 data를 저장할 경로 생성
To make it easy for you to get started with GitLab, here's a list of recommended next steps. docker run --hostname localhost --rm --entrypoint=/usr/local/bin/teleport public.ecr.aws/gravitational/teleport-distroless:15.2.2 configure --roles=proxy,auth > ~/teleport/config/teleport.yaml
# teleport config 생성
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! vi ~/teleport/config/teleport.yaml
# teleport config 수정 (도메인 적용을 위해 아래의 내용 참고)
## Add your files docker run -d --hostname cloud.elppa.xyz --name teleport -v /teleport/config:/etc/teleport -v /teleport/data:/var/lib/teleport -p 3025:3025 -p 3080:3080 public.ecr.aws/gravitational/teleport-distroless:14.3.3
# teleport 실행
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
``` ```
cd existing_repo
git remote add origin https://lab.jhcloud.kr/sa_8001/teleport.git #### teleport.yaml
git branch -M main ```yaml
git push -uf origin main version: v3
teleport:
nodename: cloud.elppa.xyz:443
data_dir: /var/lib/teleport
log:
output: stderr
severity: INFO
format:
output: text
ca_pin: ""
diag_addr: ""
auth_service:
enabled: "yes"
listen_addr: 0.0.0.0:3025
proxy_listener_mode: multiplex
ssh_service:
enabled: "no"
proxy_service:
enabled: "yes"
public_addr: "cloud.elppa.xyz:443"
https_keypairs: []
https_keypairs_reload_interval: 0s
acme: {}
``` ```
## Integrate with your tools ### Helm Chart
```shell
helm repo add teleport https://charts.releases.teleport.dev
# helm repo 추가
- [ ] [Set up project integrations](http://lab.jhcloud.kr/sa_8001/teleport/-/settings/integrations) helm repo update
# helm 업데이트
## Collaborate with your team vi override.yaml
# value 값 설정 (아래의 내용 참고)
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) helm -n teleport install teleport . -f override.yaml
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) # teleport 배포
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) ```
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy #### override.yaml
```yaml
chartMode: standalone
clusterName: teleport.datasaker.io
teleportVersionOverride: "13.3.5"
Use the built-in continuous integration in GitLab. auth:
teleportConfig:
# put any teleport.yaml auth configuration overrides here
teleport:
log:
output: stderr
severity: DEBUG
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html) auth_service:
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) enabled: true
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) web_idle_timeout: 1h
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) authentication:
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) locking_mode: best_effort
*** proxy:
teleportConfig:
# put any teleport.yaml proxy configuration overrides here
teleport:
log:
output: stderr
severity: DEBUG
# Editing this README proxy_service:
https_keypairs_reload_interval: 12h
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template. podSecurityPolicy:
enabled: false
## Suggestions for a good README proxy_service:
web_listen_addr: 0.0.0.0:3080
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. public_addr: teleport.datasaker.io:443
```
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.

250
app연결.md Normal file
View File

@@ -0,0 +1,250 @@
# Application 연결
Application web을 teleport를 통해서 특정 domain으로 연결
![](https://t25540965.p.clickup-attachments.com/t25540965/f61cb8a3-bf08-4135-8d0c-315ae84fb5c1/image.png)
##연결 방법
`3024 로 요청이 오기 때문에 방화벽 오픈 필요`
```yaml
# 방화벽 Inbound 오픈 요청
SourceIP : Any
포트
- TCP 443
- TCP 80
- TCP 3023 ~ 3029
Destination IP : 39.115.183.131, 39.115.183.139
```
`사용자 role 생성`
```yaml
kind: role
metadata:
id: 1694589666259084009
name: app-connect
spec:
allow:
app_labels:
'*': '*'
deny:
logins:
- guest
options:
cert_format: standard
create_db_user: false
create_desktop_user: false
desktop_clipboard: true
desktop_directory_sharing: true
enhanced_recording:
- command
- network
forward_agent: false
idp:
saml:
enabled: true
max_session_ttl: 8h0m0s
pin_source_ip: false
port_forwarding: true
record_session:
default: best_effort
desktop: true
ssh_file_copy: true
version: v5
```
아래의 내용은 devops팀의 구 환경 기준 설정으로 현재는 적용 사항이 아님<br>
현재는 `nginx proxy manager`로 변경을 하여 아래의 과정 불필요<br>
## 외부 도메인을 이용하여 proxy를 통해 내부 도메인으로 연결
`proxy 설정`
```yaml
# teleport application
use_backend bk_ssl_to_nginx if { req_ssl_sni -i grafana.teleport.kr.datasaker.io }
use_backend bk_teleport_kr_3024 if { req_ssl_sni -i grafana.teleport.kr.datasaker.io }
use_backend bk_ssl_to_nginx if { req_ssl_sni -i cmak.teleport.kr.datasaker.io }
use_backend bk_teleport_kr_3024 if { req_ssl_sni -i cmak.teleport.kr.datasaker.io }
use_backend bk_ssl_to_nginx if { req_ssl_sni -i kaui.teleport.kr.datasaker.io }
use_backend bk_teleport_kr_3024 if { req_ssl_sni -i kaui.teleport.kr.datasaker.io }
use_backend bk_ssl_to_nginx if { req_ssl_sni -i killbill.teleport.kr.datasaker.io }
use_backend bk_teleport_kr_3024 if { req_ssl_sni -i killbill.teleport.kr.datasaker.io }
use_backend bk_ssl_to_nginx if { req_ssl_sni -i kafka-ui.teleport.kr.datasaker.io }
use_backend bk_teleport_kr_3024 if { req_ssl_sni -i kafka-ui.teleport.kr.datasaker.io }
use_backend bk_ssl_to_nginx if { req_ssl_sni -i keycloak.teleport.kr.datasaker.io }
use_backend bk_teleport_kr_3024 if { req_ssl_sni -i keycloak.teleport.kr.datasaker.io }
use_backend bk_ssl_to_nginx if { req_ssl_sni -i druid-router.teleport.kr.datasaker.io }
use_backend bk_teleport_kr_3024 if { req_ssl_sni -i druid-router.teleport.kr.datasaker.io }
# ssl > nginx
backend bk_ssl_to_nginx
mode tcp
balance roundrobin
option ssl-hello-chk
server web01 127.0.0.1:8443 check inter 2s
# 3024 > teleport proxy
listen 3024_in
bind *:3024
mode tcp
balance roundrobin
use_backend bk_teleport_kr_3024
backend bk_teleport_kr_3024
mode tcp
balance roundrobin
server teleport_server_kr_3124 10.10.43.240:30813 check
```
2. 인증서 발급
```plain
domains=('grafana' 'cmak' 'killbill' 'kafka-ui' 'keycloak' 'druid-router')
for domain in ${domains[@]}
do
"certbot certonly --standalone -d ${domain}.teleport.kr.datasaker.io --non-interactive --agree-tos --email havelight@ex-em.com --http-01-port=8899 -v"
done
```
3. nginx 설정
```shell
rp-grafana-teleport-kr.conf
rp-kaui-teleport-kr.conf
rp-kafka-ui-teleport-kr.conf
rp-keycloak-teleport-kr.conf
rp-cmak-teleport-kr.conf
rp-druid-router-teleport-kr.conf
rp-killbill-teleport-kr.conf
```
2. agent 설치
\- token 발급
```shell
tsh login --proxy teleport.kr.dataskaer.io --user [계정명]
tctl tokens add --type=app
```
\- helm chart
```shell
helm repo add teleport https://charts.releases.teleport.dev
helm repo update
helm pull teleport/teleport-kube-agent --untar
```
\- prod\_values.yaml
```yaml
authToken: "[발급받은 token]"
proxyAddr: "teleport.kr.datasaker.io:443"
roles: "app" #(any of: kube,db,app)
apps:
- name: cmak
uri: http://cmak.dsk-middle.svc.cluster.local:9000
- name: kaui
uri: http://dsk-kaui.dsk-middle.svc.cluster.local:8080
- name: killbill
uri: http://dsk-killbill.dsk-middle.svc.cluster.local:8080/api.html
- name: kafka-ui
uri: http://kafka-ui.dsk-middle.svc.cluster.local
- name: keycloak
uri: http://keycloak.dsk-middle.svc.cluster.local
- name: druid-router
uri: http://druid-router.dsk-middle.svc.cluster.local:8888/unified-console.html
storage:
enabled: true
storageClassName: ""
requests: 128Mi
```
\- helm install
```shell
helm -n teleport-agent install teleport-agent . -f prod_values.yaml --create-namespace
```
3. 확인
```yaml
# kubectl -n teleport-agent get all
NAME READY STATUS RESTARTS AGE
pod/teleport-agent-0 1/1 Running 0 141m
NAME READY AGE
statefulset.apps/teleport-agent 1/1 22h
# kubectl -n teleport-agent get cm teleport-agent -o yaml
apiVersion: v1
data:
teleport.yaml: |
app_service:
apps:
- name: cmak
uri: http://cmak.dsk-middle.svc.cluster.local:9000
- name: kaui
uri: http://dsk-kaui.dsk-middle.svc.cluster.local:8080
- name: killbill
uri: http://dsk-killbill.dsk-middle.svc.cluster.local:8080/api.html
- name: kafka-ui
uri: http://kafka-ui.dsk-middle.svc.cluster.local
- name: keycloak
uri: http://keycloak.dsk-middle.svc.cluster.local
- name: druid-router
uri: http://druid-router.dsk-middle.svc.cluster.local:8888/unified-console.html
enabled: true
auth_service:
enabled: false
db_service:
enabled: false
kubernetes_service:
enabled: false
proxy_service:
enabled: false
ssh_service:
enabled: false
teleport:
join_params:
method: token
token_name: /etc/teleport-secrets/auth-token
log:
format:
extra_fields:
- timestamp
- level
- component
- caller
output: text
output: stderr
severity: INFO
proxy_server: teleport.kr.datasaker.io:443
version: v3
kind: ConfigMap
metadata:
annotations:
meta.helm.sh/release-name: teleport-agent
meta.helm.sh/release-namespace: teleport-agent
creationTimestamp: "2023-09-13T07:15:32Z"
labels:
app.kubernetes.io/managed-by: Helm
name: teleport-agent
namespace: teleport-agent
resourceVersion: "144094053"
uid: 57c4e43e-88e5-42fd-abba-bccecbdab0e1
```
## 검증
### Applications
![](https://t25540965.p.clickup-attachments.com/t25540965/b9098cbd-9765-4dc5-9bf9-eb12f1d2b44d/image.png)
### Kafka UI 접속
![](https://t25540965.p.clickup-attachments.com/t25540965/c56081a5-2759-4689-aee5-446f79be2bfd/image.png)

62
github연결.md Normal file
View File

@@ -0,0 +1,62 @@
# github 연결
기본적으로 SSO를 지원하지만, community version에서는 github 만 지원
Enterprise : AD, OIDC, google workspace, GitLab, Okta, OneLogin
## 순서
### github OAuth Apps 등록
![](https://t25540965.p.clickup-attachments.com/t25540965/208fc7af-ad62-4c8c-8013-b41eb4be31c7/image.png)
![](https://t25540965.p.clickup-attachments.com/t25540965/a48f30fc-090f-4a18-b1e2-e5a5687c0e9b/image.png)
![](https://t25540965.p.clickup-attachments.com/t25540965/2494519b-d229-4ed3-8830-64909514002e/image.png)
### GITHUB\_CONNECTOR 생성
```yaml
kind: github
metadata:
name: new_github_connector
spec:
api_endpoint_url: ""
client_id: <Client ID>
client_secret: <Client Secrets>
display: GitHub
endpoint_url: ""
redirect_url: https://teleport.datasaker.io/v1/webapi/github/callback
teams_to_logins: null
teams_to_roles:
- organization: CloudMOA
roles:
- bastion
- dsk_dev_master
team: dev2-datasaker
- organization: CloudMOA
roles:
- bastion
- agent_test
- agent_node
- agent_master
- dsk_dev_master
- management
team: dev2_teleport
version: v3
```
client_id: `Client ID`<br>
client_secert: `Client Secrets`<br>
teams_to_roles.organization: `github repo명`<br>
roles: `teleport roles` (github login 시 적용)<br>
team: `github teams`<br>
## agent 배포를 위한 ansible
[바로가기](https://lab.jhcloud.kr/sa_8001/dsk-iac/-/tree/main/ansible/teleport_setting?ref_type=heads) 참조