Connection Management Guide(KR) - cloud-barista/cb-spider GitHub Wiki

Connection Management Guide

Language: English | ν•œκ΅­μ–΄

1. CB-Spider Register Connection κ°œμš”

  • λ©€ν‹°ν΄λΌμš°λ“œ 인프라λ₯Ό μ œμ–΄ν•˜λ €λ©΄ λ¨Όμ € λŒ€μƒ ν΄λΌμš°λ“œ(CSP)의 μ—°κ²° μ„€μ •(Connection Configuration) 을 등둝해야 ν•©λ‹ˆλ‹€.
  • μ—°κ²° μ„€μ • 등둝 ν›„μ—λŠ” 등둝 μ‹œ λΆ€μ—¬ν•œ μ—°κ²° 이름(Connection Name) 을 μ΄μš©ν•˜μ—¬ λŒ€μƒ ν΄λΌμš°λ“œμ— μ—°κ²° 및 μ œμ–΄ν•  수 μžˆμŠ΅λ‹ˆλ‹€.
  • μ—°κ²° μ„€μ • 등둝은 λ‹€μŒ 4λ‹¨κ³„λ‘œ μ§„ν–‰ν•©λ‹ˆλ‹€:
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              CB-Spider μ—°κ²° μ„€μ • 등둝                          β”‚
β”‚                                                               β”‚
β”‚  (1) Cloud Driver 등둝                                        β”‚
β”‚       └── CSP λ“œλΌμ΄λ²„ ν”ŒλŸ¬κ·ΈμΈ (예: aws-driver-v1.0.so)       β”‚
β”‚                                                               β”‚
β”‚  (2) Cloud Credential 등둝                                    β”‚
β”‚       └── CSP 접속 ν‚€ (예: AccessKey, SecretKey)              β”‚
β”‚                                                               β”‚
β”‚  (3) Cloud Region/Zone 등둝                                   β”‚
β”‚       └── λŒ€μƒ 리전 및 μ‘΄ (예: us-east-2, us-east-2a)          β”‚
β”‚                                                               β”‚
β”‚  (4) Cloud Connection 등둝                                    β”‚
β”‚       └── Driver + Credential + Region μ‘°ν•©                   β”‚
β”‚           β†’ λͺ¨λ“  API ν˜ΈμΆœμ— μ‚¬μš©ν•  ConnectionName 생성         β”‚
β”‚                                                               β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                β”‚
β”‚  β”‚  Driver  β”‚  β”‚ Credential  β”‚  β”‚Region/Zone β”‚                β”‚
β”‚  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜                β”‚
β”‚       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                       β”‚
β”‚                       β–Ό                                       β”‚
β”‚            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                            β”‚
β”‚            β”‚  Connection Config  β”‚                            β”‚
β”‚            β”‚  (ConnectionName)   β”‚                            β”‚
β”‚            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

μ°Έκ³ 

  • (1), (2), (3) λ‹¨κ³„λŠ” μˆœμ„œμ— 관계없이 등둝할 수 μžˆμŠ΅λ‹ˆλ‹€.
  • (4) λ‹¨κ³„λŠ” μ•žμ˜ 3κ°€μ§€ 등둝이 λͺ¨λ‘ μ™„λ£Œλœ 후에 등둝 κ°€λŠ₯ν•©λ‹ˆλ‹€.
  • Credential λ°œκΈ‰ 방법은 How to get CSP Credentialsλ₯Ό μ°Έκ³ ν•˜μ„Έμš”.
  • μžλ™ 일괄 등둝이 ν•„μš”ν•œ 경우 Default Connection Helper 도ꡬλ₯Ό μ°Έκ³ ν•˜μ„Έμš”.

2. 사전 μš”κ΅¬μ‚¬ν•­

  • CB-Spider μ„œλ²„κ°€ μ‹€ν–‰ 쀑이어야 ν•©λ‹ˆλ‹€.
  • API 확인을 μœ„ν•œ curl 및 jq (λ˜λŠ” json_pp) μ„€μΉ˜
  • CSP Credential μ€€λΉ„ (예: AWS Access Key, GCP Service Account Key)

3. CB-Spider μ—°κ²° μ„€μ • API λͺ…μ„Έ

  • CB-Spider REST APIλ₯Ό 톡해 μ—°κ²° 섀정을 등둝 및 관리할 수 μžˆμŠ΅λ‹ˆλ‹€.

3.1 μ—°κ²° μ„€μ • API μ—”λ“œν¬μΈνŠΈ

# Cloud Driver
POST   /spider/driver                - Cloud Driver 등둝
GET    /spider/driver                - Cloud Driver λͺ©λ‘ 쑰회
GET    /spider/driver/{DriverName}   - Cloud Driver 쑰회
DELETE /spider/driver/{DriverName}   - Cloud Driver μ‚­μ œ

# Cloud Credential
POST   /spider/credential                    - Cloud Credential 등둝
GET    /spider/credential                    - Cloud Credential λͺ©λ‘ 쑰회
GET    /spider/credential/{CredentialName}   - Cloud Credential 쑰회
DELETE /spider/credential/{CredentialName}   - Cloud Credential μ‚­μ œ

# Cloud Region/Zone
POST   /spider/region                  - Cloud Region/Zone 등둝
GET    /spider/region                  - Cloud Region λͺ©λ‘ 쑰회
GET    /spider/region/{RegionName}     - Cloud Region 쑰회
DELETE /spider/region/{RegionName}     - Cloud Region μ‚­μ œ

# Cloud Connection Config
POST   /spider/connectionconfig                - Cloud Connection 등둝
GET    /spider/connectionconfig                - Cloud Connection λͺ©λ‘ 쑰회
GET    /spider/connectionconfig/{ConfigName}   - Cloud Connection 쑰회
DELETE /spider/connectionconfig/{ConfigName}   - Cloud Connection μ‚­μ œ

3.2 μš”μ²­ νŒŒλΌλ―Έν„°

Cloud Driver 등둝

νŒŒλΌλ―Έν„° μ„€λͺ… μ˜ˆμ‹œ
DriverName λ“œλΌμ΄λ²„ 이름 aws-driver01
ProviderName ν΄λΌμš°λ“œ 제곡자 이름 AWS, GCP, AZURE, ALIBABA
DriverLibFileName λ“œλΌμ΄λ²„ 라이브러리 파일λͺ… aws-driver-v1.0.so

Cloud Credential 등둝

νŒŒλΌλ―Έν„° μ„€λͺ… μ˜ˆμ‹œ
CredentialName Credential 이름 aws-credential01
ProviderName ν΄λΌμš°λ“œ 제곡자 이름 AWS
KeyValueInfoList Credential ν‚€-κ°’ 쌍 μ•„λž˜ μ˜ˆμ‹œ μ°Έκ³ 

Cloud Region/Zone 등둝

νŒŒλΌλ―Έν„° μ„€λͺ… μ˜ˆμ‹œ
RegionName 리전 이름 aws-ohio
ProviderName ν΄λΌμš°λ“œ 제곡자 이름 AWS
KeyValueInfoList 리전/μ‘΄ ν‚€-κ°’ 쌍 Region: us-east-2, Zone: us-east-2a

Cloud Connection 등둝

νŒŒλΌλ―Έν„° μ„€λͺ… μ˜ˆμ‹œ
ConfigName μ—°κ²° μ„€μ • 이름 aws-ohio-config
ProviderName ν΄λΌμš°λ“œ 제곡자 이름 AWS
DriverName λ“±λ‘ν•œ λ“œλΌμ΄λ²„ 이름 aws-driver01
CredentialName λ“±λ‘ν•œ Credential 이름 aws-credential01
RegionName λ“±λ‘ν•œ 리전 이름 aws-ohio

4. CB-Spider μ—°κ²° μ„€μ • API μ‚¬μš© μ˜ˆμ‹œ

λ‹€μŒμ€ AWS의 Ohio, Oregon 2개 리전에 λŒ€ν•œ μ—°κ²° μ„€μ • 등둝 μ˜ˆμ‹œμž…λ‹ˆλ‹€.

4.1 Cloud Driver 등둝

curl -sX POST http://localhost:1024/spider/driver \
    -H 'Content-Type: application/json' \
    -d '{
        "DriverName": "aws-driver01",
        "ProviderName": "AWS",
        "DriverLibFileName": "aws-driver-v1.0.so"
    }' | json_pp

응닡 μ˜ˆμ‹œ:

{
   "DriverLibFileName" : "aws-driver-v1.0.so",
   "DriverName" : "aws-driver01",
   "ProviderName" : "AWS"
}

4.2 Cloud Credential 등둝

XXXXXXXXXXXXXXXXXXXXXXX 뢀뢄을 μ‹€μ œ CSPμ—μ„œ λ°œκΈ‰λ°›μ€ μ •λ³΄λ‘œ κ΅μ²΄ν•˜μ„Έμš”.

curl -sX POST http://localhost:1024/spider/credential \
    -H 'Content-Type: application/json' \
    -d '{
        "CredentialName": "aws-credential01",
        "ProviderName": "AWS",
        "KeyValueInfoList": [
            {"Key": "aws_access_key_id", "Value": "XXXXXXXXXXXXXXXXXXXXXXX"},
            {"Key": "aws_secret_access_key", "Value": "XXXXXXXXXXXXXXXXXXXXXXX"}
        ]
    }' | json_pp

응닡 μ˜ˆμ‹œ:

{
   "CredentialName" : "aws-credential01",
   "KeyValueInfoList" : [
      {
         "Key" : "ClientId",
         "Value" : "XXXXXXXXXXXXXXXXXXXXXXX"
      },
      {
         "Key" : "ClientSecret",
         "Value" : "XXXXXXXXXXXXXXXXXXXXXXX"
      }
   ],
   "ProviderName" : "AWS"
}

4.3 Cloud Region/Zone 등둝

팁: 등둝할 Region 이름(κ°’)을 ν™•μΈν•˜λ €λ©΄ Region/Zone Info Guide의 μ—°κ²° μ„€μ • μ „ APIλ₯Ό ν™œμš©ν•˜μ„Έμš”. 예: GET /spider/preconfig/regionzone?DriverName=aws-driver01&CredentialName=aws-credential01

μ—¬λŸ¬ 리전/쑴을 ν•œ λ²ˆμ— λ“±λ‘ν•˜λŠ” μ˜ˆμ‹œ (AWS Ohio, Oregon):

regions=("aws-ohio:us-east-2:us-east-2a"
         "aws-oregon:us-west-2:us-west-2a")

for region in "${regions[@]}"; do
    IFS=":" read -r RegionName Region Zone <<< "$region"
    curl -sX POST http://localhost:1024/spider/region \
        -H 'Content-Type: application/json' \
        -d '{
            "RegionName": "'$RegionName'",
            "ProviderName": "AWS",
            "KeyValueInfoList": [
                {"Key": "Region", "Value": "'$Region'"},
                {"Key": "Zone", "Value": "'$Zone'"}
            ]
        }' | json_pp
done

응닡 μ˜ˆμ‹œ:

{
   "AvailableZoneList" : null,
   "KeyValueInfoList" : [
      {
         "Key" : "Region",
         "Value" : "us-east-2"
      },
      {
         "Key" : "Zone",
         "Value" : "us-east-2a"
      }
   ],
   "ProviderName" : "AWS",
   "RegionName" : "aws-ohio"
}

4.4 Cloud Connection 등둝

μ•žμ—μ„œ λ“±λ‘ν•œ λ“œλΌμ΄λ²„, Credential, 리전을 μ‘°ν•©ν•˜μ—¬ μ—°κ²° 섀정을 λ“±λ‘ν•©λ‹ˆλ‹€:

configs=("aws-ohio-config:aws-ohio"
         "aws-oregon-config:aws-oregon")

for config in "${configs[@]}"; do
    IFS=":" read -r ConfigName RegionName <<< "$config"
    curl -sX POST http://localhost:1024/spider/connectionconfig \
        -H 'Content-Type: application/json' \
        -d '{
            "ConfigName": "'$ConfigName'",
            "ProviderName": "AWS",
            "DriverName": "aws-driver01",
            "CredentialName": "aws-credential01",
            "RegionName": "'$RegionName'"
        }' | json_pp
done

응닡 μ˜ˆμ‹œ:

{
   "ConfigName" : "aws-ohio-config",
   "CredentialName" : "aws-credential01",
   "DriverName" : "aws-driver01",
   "ProviderName" : "AWS",
   "RegionName" : "aws-ohio"
}
{
   "ConfigName" : "aws-oregon-config",
   "CredentialName" : "aws-credential01",
   "DriverName" : "aws-driver01",
   "ProviderName" : "AWS",
   "RegionName" : "aws-oregon"
}

5. CSP별 Credential ν‚€ 이름

각 CSP에 ν•„μš”ν•œ Credential ν‚€ 이름을 μ‘°νšŒν•  수 μžˆμŠ΅λ‹ˆλ‹€:

# μ˜ˆμ‹œ: AWS의 Credential ν‚€ 이름 확인
curl -sX GET http://localhost:1024/spider/cloudos/metainfo/AWS \
    -H 'Content-Type: application/json' | json_pp
CSP νƒ€μž… ν‚€ 이름
AWS Spider νƒ€μž… ClientId, ClientSecret
AWS CSP νƒ€μž… aws_access_key_id, aws_secret_access_key
GCP Spider νƒ€μž… ClientEmail, ProjectID, PrivateKey
Azure Spider νƒ€μž… ClientId, ClientSecret, TenantId, SubscriptionId
Alibaba Spider νƒ€μž… ClientId, ClientSecret

μ°Έκ³ 

  • Spider νƒ€μž…κ³Ό CSP νƒ€μž… Credential ν‚€ λͺ¨λ‘ μ§€μ›λ©λ‹ˆλ‹€.
  • 전체 CSP의 ν‚€ 이름은 MetaInfo API둜 확인 κ°€λŠ₯ν•©λ‹ˆλ‹€: GET /spider/cloudos/metainfo/{CSP이름}
  • 각 CSPμ—μ„œ Credential을 λ°œκΈ‰λ°›λŠ” 방법은 How to get CSP Credentialsλ₯Ό μ°Έκ³ ν•˜μ„Έμš”.

6. λ“±λ‘λœ μ—°κ²° μ„€μ • 확인

등둝 ν›„ μ—°κ²° 섀정을 ν™•μΈν•©λ‹ˆλ‹€:

# λ“±λ‘λœ 전체 μ—°κ²° μ„€μ • λͺ©λ‘ 쑰회
curl -sX GET http://localhost:1024/spider/connectionconfig | json_pp

# νŠΉμ • μ—°κ²° μ„€μ • 쑰회
curl -sX GET http://localhost:1024/spider/connectionconfig/aws-ohio-config | json_pp

7. API 응닡 μ½”λ“œ

HTTP μƒνƒœ μ½”λ“œ μ„€λͺ…
200 OK μš”μ²­ 성곡
400 Bad Request 잘λͺ»λœ μš”μ²­ (ν•„μˆ˜ νŒŒλΌλ―Έν„° λˆ„λ½ λ“±)
404 Not Found λŒ€μƒ λ¦¬μ†ŒμŠ€λ₯Ό 찾을 수 μ—†μŒ
500 Internal Server Error μ„œλ²„ λ‚΄λΆ€ 였λ₯˜

8. 참고 자료