spctl user guide - cloud-barista/cb-spider GitHub Wiki
spctl
User Guide
CB-Spider CLI * ๋ณธ ๊ฐ์ด๋๋ CB-Spider์ CLI ๋๊ตฌ spctl๋ฅผ ์ด์ฉํ ๋ฉํฐํด๋ผ์ฐ๋ ์ ์ด์ ๋ํ ์์๋ฅผ ์ ๊ณตํ๊ณ ์์ต๋๋ค.
* ๋ณธ ๊ฐ์ด๋๋ AWS VM ์์ฑ ๋ฐ ์ ์ด ์ค์ฌ์ผ๋ก ๊ฐ์ด๋ํ๊ณ ์์ต๋๋ค.
* ๊ทธ ์ธ CSP ๋ฐ ์์์ ๋ํ ํ์ฉ์ ๋ค์ User Guide ๋ฐ CLI ๊ท๊ฒฉ ๋ฌธ์ ๋ฑ์ ์ฐธ๊ณ ํ์ฌ ์ ์ฌํ ๋ฐฉ๋ฒ์ผ๋ก ์ ์ฉ ๊ฐ๋ฅํฉ๋๋ค.
-
โป CB-Spider CLI spctl Documentations
-
CB-Spider CLI Install Guide
-
CB-Spider CLI Specifications
-
CB-Spider CLI User Guide ยทยทยทยทยทยทยทยทยทยทยทยทยท (ํ์ฌ ๋ฌธ์)
-
[๋ชฉ ์ฐจ]
- ์ฌ์ ์ค๋น
- ๋ฉํฐํด๋ผ์ฐ๋ ์ฐ๊ฒฐ ์ค์ ๊ด๋ฆฌ
- ๋ฉํฐํด๋ผ์ฐ๋ ์ธํ๋ผ ์์ ์ ์ด
- ๋ฉํฐํด๋ผ์ฐ๋ ๊ฐ์๋จธ์ ๋ผ์ดํ์ฌ์ดํด ์ ์ด
0. ์ฌ์ ์ค๋น
-
์ฐ๋ ๋์ CSP ๊ณ์ ์์ฑ ๋ฐ Credential ์ค๋น
- ์ฐ๋ ๋์ CSP์ Credential ๋ฐ๊ธ ๊ฐ์ด๋ ์ฐธ๊ณ ํ์ฌ Credential ์ ๋ณด ์ค๋น
-
CB-Spider ์ฌ์ฉ์ ๊ธฐ๋ฅ ๋ฐ ํ์ฉ ๋ฐฉ๋ฒ ํ์ธ
- ์ฌ์ฉ์ ๊ธฐ๋ฅ ๋ฐ ํ์ฉ ๊ฐ์ด๋ ์ฐธ๊ณ
-
Terminal-1: CB-Spider ์๋ฒ ์คํ ํ๊ฒฝ
- CB-Spider ์ค์น ๋ฐ ์คํ ๊ฐ์ด๋ ์ฐธ๊ณ ํ์ฌ CB-Spider ์๋ฒ ์คํ
-
Terminal-2: CB-Spider CLI ๋๊ตฌ ์คํ ํ๊ฒฝ
- CLI ์ค์น ๊ฐ์ด๋ ์ฐธ๊ณ ํ์ฌ CLI ์ค์น ๋ฐ ํ์ธ ์ํ
์ดํ Terminal-2์์ ์คํ
1. ๋ฉํฐํด๋ผ์ฐ๋ ์ฐ๊ฒฐ ์ค์ ๊ด๋ฆฌ
(1) Cloud Driver ์ ๋ณด ๋ฑ๋ก ๋ฐ ๊ด๋ฆฌ
- CLI ํ์ฉ ์์
-
Register Cloud Driver Info
./spctl driver register -d \ '{ "DriverName":"aws-driver01", "ProviderName":"AWS", "DriverLibFileName":"aws-driver-v1.0.so" }'
โป ๋ฑ๋ก๋ ์ด๋ฆ
aws-driver01
์ ์ด์ฉํ ์ฌ๋ฑ๋ก์ ๊ธฐ์กด ์ ๋ณด๋ฅผ ์ ๋ฐ์ดํธ ํ๋ค. -
List Cloud Driver Info
./spctl driver list
output
{ "driver": [ { "DriverLibFileName": "aws-driver-v1.0.so", "DriverName": "aws-driver01", "ProviderName": "AWS" }, { "DriverLibFileName": "azure-driver-v1.0.so", "DriverName": "azure-driver-v1.0", "ProviderName": "AZURE" }, { "DriverLibFileName": "gcp-driver-v1.0.so", "DriverName": "gcp-driver-v1.0", "ProviderName": "GCP" },
-
Get Cloud Driver Info
./spctl driver get --DriverName aws-driver01
output
{ "DriverLibFileName": "aws-driver-v1.0.so", "DriverName": "aws-driver01", "ProviderName": "AWS" }
-
Delete Cloud Driver Info
./spctl driver unregister --DriverName aws-driver01
output
{ "Result": "true" }
-
(2) Cloud Credential ์ ๋ณด ๋ฑ๋ก ๋ฐ ๊ด๋ฆฌ
- CLI ํ์ฉ ์์
-
Register Cloud Credential Info
./spctl credential register -d \ '{ "CredentialName": "aws-credential-01", "ProviderName": "AWS", "KeyValueInfoList": [ { "Key": "ClientId", "Value": "$ACCESS_KEY" }, { "Key": "ClientSecret", "Value": "$SECRET_KEY" } ] }'
โป
$ACCESS_KEY
์$SECRET_KEY
๋ ๋ณธ์ธ cloud์ credential ์ ๋ณด๋ฅผ ์ ๋ ฅ -
List Cloud Credential Info
./spctl credential list
output
{ "credential": [ { "CredentialName": "aws-credential-01", "KeyValueInfoList": [ { "Key": "ClientId", "Value": "Hidden for security." }, { "Key": "ClientSecret", "Value": "Hidden for security." } ], "ProviderName": "AWS" }, ...
-
Get Cloud Credential Info
./spctl credential get --CredentialName aws-credential-01
output
{ "CredentialName": "aws-credential-01", "KeyValueInfoList": [ { "Key": "ClientId", "Value": "Hidden for security." }, { "Key": "ClientSecret", "Value": "Hidden for security." } ], "ProviderName": "AWS" }
-
Delete Cloud Credential Info
./spctl credential unregister --CredentialName aws-credential-01
output
{ "Result": "true" }
-
(3) Cloud Region/Zone ์ ๋ณด ๋ฑ๋ก ๋ฐ ๊ด๋ฆฌ
- CLI ํ์ฉ ์์
-
Register Cloud Region/Zone Info
./spctl region register -d \ '{ "RegionName": "aws-us-east-2", "ProviderName": "AWS", "KeyValueInfoList": [ { "Key": "Region", "Value": "us-east-2" }, { "Key": "Zone", "Value": "us-east-2a" } ] }'
-
List Cloud Region/Zone Info
./spctl region list
output
{ "region": [ { "AvailableZoneList": null, "KeyValueInfoList": [ { "Key": "Region", "Value": "ap-northeast-2" }, { "Key": "Zone", "Value": "ap-northeast-2a" }, { "Key": "ZoneStatus", "Value": "Available" } ], "ProviderName": "AWS", "RegionName": "aws_ap-northeast-2_ap-northeast-2a" }, ...
-
Get Cloud Region/Zone Info
./spctl region get --RegionName aws-us-east-2
output
{ "AvailableZoneList": null, "KeyValueInfoList": [ { "Key": "Region", "Value": "us-east-2" }, { "Key": "Zone", "Value": "us-east-2a" } ], "ProviderName": "AWS", "RegionName": "aws-us-east-2" }
-
Delete Cloud Region/Zone Info
./spctl region unregister --RegionName aws-us-east-2
output
{ "Result": "true" }
-
(4) Cloud Connection Configuration ์ ๋ณด ๋ฑ๋ก ๋ฐ ๊ด๋ฆฌ
- CLI ํ์ฉ ์์
-
Create Cloud Connection Configuration Info
./spctl connection create -d \ '{ "ConfigName": "aws-us-east-2-connection-01", "ProviderName": "AWS", "DriverName": "aws-driver01", "CredentialName": "aws-credential-01", "RegionName": "aws-us-east-2" }'
-
List Cloud Connection Configuration Info
./spctl connection list
output
{ "connectionconfig": [ { "ConfigName": "aws-us-east-2-connection-01", "CredentialName": "aws-credential-01", "DriverName": "aws-driver01", "ProviderName": "AWS", "RegionName": "aws-us-east-2" }, ...
-
Get Cloud Connection Configuration Info
./spctl connection get --ConfigName aws-us-east-2-connection-01
output
{ "ConfigName": "aws-us-east-2-connection-01", "CredentialName": "aws-credential-01", "DriverName": "aws-driver01", "ProviderName": "AWS", "RegionName": "aws-us-east-2" }
-
Delete Cloud Connection Configuration Info
./spctl connection delete --ConfigName aws-us-east-2-connection-01
output
{ "Result": "true" }
-
2. ๋ฉํฐํด๋ผ์ฐ๋ ์ธํ๋ผ ์์ ์ ์ด
(1) VM Image ์ ๋ณด ์ ๊ณต
- CLI ํ์ฉ ์์
-
List Cloud VM Image Info
./spctl image list -c aws-us-east-2-connection-01
output
{ "image": [ { "GuestOS": "windows", "IId": { "NameId": "ami-0d2ede3190020808f", "SystemId": "ami-0d2ede3190020808f" }, "KeyValueList": [ { "Key": "CreationDate", "Value": "2024-02-14T08:45:45.000Z" }, { "Key": "Architecture", "Value": "x86_64" }, ...
-
(2) VM Spec ์ ๋ณด ์ ๊ณต
- CLI ํ์ฉ ์์
-
List Cloud VM Spec Info
./spctl vmspec list -c aws-us-east-2-connection-01
output
{ "vmspec": [ { "Mem": "262144", "Name": "m7i.16xlarge", "Region": "us-east-2", "VCpu": { "Clock": "3.2", "Count": "64" }, "KeyValueList": [ { "Key": "VCpuInfo", "Value": "map[DefaultCores:32 DefaultThreadsPerCore:2 DefaultVCpus:64 ValidCores:[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 2 0 21 22 23 24 25 26 27 28 29 30 31 32] ValidThreadsPerCore:[1 2]]" }, { "Key": "DedicatedHostsSupported", "Value": "true" }, ... ] }, ...
-
(3) VPC/Subnet ์์ฑ ๋ฐ ์ ์ด
- CLI ํ์ฉ ์์ (โป ์ฐธ๊ณ : ์์๋ณ ์์ฑ์ ํ์ํ json ์
๋ ฅ ํ์ธ ๋ฐฉ๋ฒ)
-
Create Cloud VPC/Subnet Info
./spctl vpc create -d \ '{ "ConnectionName": "aws-us-east-2-connection-01", "ReqInfo": { "Name": "vpc-1", "IPv4_CIDR": "192.168.0.0/16", "SubnetInfoList": [ { "Name": "subnet-1", "IPv4_CIDR": "192.168.1.0/24" } ] } }'
-
List Cloud VPC/Subnet Info
./spctl vpc list -c aws-us-east-2-connection-01
output
{ "vpc": [ { "IId": { "NameId": "vpc-1", "SystemId": "vpc-0046395337083e599" }, "IPv4_CIDR": "192.168.0.0/16", "SubnetInfoList": [ { "IId": { "NameId": "subnet-1", "SystemId": "subnet-01d6535b5c5e4f8e8" }, "IPv4_CIDR": "192.168.1.0/24", "KeyValueList": [ { "Key": "VpcId", "Value": "vpc-0046395337083e599" }, ... ], "TagList": [ { "Key": "Name", "Value": "subnet-1-crm230rp70itoiaonq0g" } ], "Zone": "us-east-2a" } ], "TagList": [ { "Key": "Name", "Value": "vpc-1-crm230rp70itoiaonq00" } ] } ] }
-
Get Cloud VPC/Subnet Info
./spctl vpc get -n vpc-1 -c aws-us-east-2-connection-01
output
{ "IId": { "NameId": "vpc-1", "SystemId": "vpc-01ef75ec235085cd8" }, "IPv4_CIDR": "192.168.0.0/16", "SubnetInfoList": [ { "IId": { "NameId": "subnet-1", "SystemId": "subnet-061d9826ad52d3fb8" }, "IPv4_CIDR": "192.168.1.0/24", "KeyValueList": [ { "Key": "VpcId", "Value": "vpc-01ef75ec235085cd8" }, ... ], "TagList": [ { "Key": "Name", "Value": "subnet-1-crm257rp70itoiaonq1g" } ], "Zone": "us-east-2a" } ], "TagList": [ { "Key": "Name", "Value": "vpc-1-crm257rp70itoiaonq10" } ] }
-
Delete Cloud VPC/Subnet Info
./spctl vpc delete -n vpc-1 -d '{ "ConnectionName": "aws-us-east-2-connection-01" }'
output
{ "Result": "true" }
-
์ฐธ๊ณ ์ฌํญ
- CSP๋ณ๋ก Region ๋น ์์ฑํ ์ ์๋ VPC ๊ฐฏ์์ ์ ํ์ด ์กด์ฌ
-
(4) SecurityGroup ์์ฑ ๋ฐ ์ ์ด
- CLI ํ์ฉ ์์
-
Create Cloud SecurityGroup Info
./spctl securitygroup create -d \ '{ "ConnectionName": "aws-us-east-2-connection-01", "ReqInfo": { "Name": "sg-01", "VPCName": "vpc-1", "SecurityRules": [ { "FromPort": "1", "ToPort": "65535", "IPProtocol": "tcp", "Direction": "inbound", "CIDR": "0.0.0.0/0" } ] } }'
-
List Cloud SecurityGroup Info
./spctl securitygroup list -c aws-us-east-2-connection-01
output
{ "securitygroup": [ { "IId": { "NameId": "sg-01", "SystemId": "sg-04cfb8cd2e946378d" }, "KeyValueList": [ { "Key": "GroupName", "Value": "sg01-crm27arp70itoiaonq20" }, { "Key": "VpcID", "Value": "vpc-01ef75ec235085cd8" }, { "Key": "OwnerID", "Value": "635484366616" }, { "Key": "Description", "Value": "sg01-crm27arp70itoiaonq20" } ], "SecurityRules": [ { "CIDR": "0.0.0.0/0", "Direction": "inbound", "FromPort": "1", "IPProtocol": "TCP", "ToPort": "65535" }, { "CIDR": "0.0.0.0/0", ...
-
Get Cloud SecurityGroup Info
./spctl securitygroup get -n sg-01 -c aws-us-east-2-connection-01
output
{ "IId": { "NameId": "sg-01", "SystemId": "sg-0e4afa53da260cef2" }, "KeyValueList": [ { "Key": "GroupName", "Value": "sg01-crm28qbp70itoiaonq2g" }, ... ], "SecurityRules": [ { "CIDR": "0.0.0.0/0", "Direction": "inbound", "FromPort": "1", "IPProtocol": "TCP", "ToPort": "65535" }, { "CIDR": "0.0.0.0/0", "Direction": "outbound", "FromPort": "-1", "IPProtocol": "ALL", "ToPort": "-1" } ], "TagList": [ { "Key": "Name", "Value": "sg01-crm28qbp70itoiaonq2g" } ], "VpcIID": { "NameId": "vpc-1", "SystemId": "vpc-01ef75ec235085cd8" } }
-
Delete Cloud SecurityGroup Info
./spctl securitygroup delete -n sg-01 -d '{ "ConnectionName": "aws-us-east-2-connection-01" }'
output
{ "Result": "true" }
-
(5) VM KeyPair ์์ฑ ๋ฐ ์ ์ด
- CLI ํ์ฉ ์์
-
Create Cloud VM KeyPair Info
./spctl keypair create -d \ '{ "ConnectionName": "aws-us-east-2-connection-01", "ReqInfo": { "Name": "keypair-1" } }'
-
List Cloud VM KeyPair Info
./spctl keypair list -c aws-us-east-2-connection-01
output
{ "keypair": [ { "Fingerprint": "f1:97:a7:fe:a8:40:32:98:33:1d:2d:8f:3b:cc:e3:79:96:3b:ee:c9", "IId": { "NameId": "keypair-1", "SystemId": "keypair-1-crm2f6bp70itoiaonq3g" }, "PrivateKey": "Hidden for security.", "PublicKey": "Hidden for security.", "TagList": [ { "Key": "Name", "Value": "keypair-1-crm2f6bp70itoiaonq3g" } ] } ] }
-
Get Cloud VM KeyPair Info
./spctl keypair get -n keypair-1 -c aws-us-east-2-connection-01
output
{ "Fingerprint": "f1:97:a7:fe:a8:40:32:98:33:1d:2d:8f:3b:cc:e3:79:96:3b:ee:c9", "IId": { "NameId": "keypair-1", "SystemId": "keypair-1-crm2f6bp70itoiaonq3g" }, "PrivateKey": "Hidden for security.", "PublicKey": "Hidden for security.", "TagList": [ { "Key": "Name", "Value": "keypair-1-crm2f6bp70itoiaonq3g" } ] }
-
Delete VM KeyPair Info
./spctl keypair delete -n keypair-1 -d '{ "ConnectionName": "aws-us-east-2-connection-01" }'
output
{ "Result": "true" }
-
3. ๋ฉํฐํด๋ผ์ฐ๋ ๊ฐ์๋จธ์ ๋ผ์ดํ์ฌ์ดํด ์ ์ด
(1) VM ์์ฑ ๋ฐ ๋ผ์ดํ์ฌ์ดํด ์ ์ด
- CLI ํ์ฉ ์์
- Create VM
Rook Disk Type ๋ฐ Size ์ค์ ์์(์ค์ ๊ฐ์ด๋ ์ฐธ๊ณ )./spctl vm start -d \ '{ "ConnectionName": "aws-us-east-2-connection-01", "ReqInfo": { "Name": "vm-1", "ImageName": "ami-0bbe28eb2173f6167", "VPCName": "vpc-1", "SubnetName": "subnet-1", "SecurityGroupNames": [ "sg-01" ], "VMSpecName": "t2.micro", "KeyPairName": "keypair-1" } }'
./spctl vm start -d \ '{ "ConnectionName": "aws-us-east-2-connection-01", "ReqInfo": { "Name": "vm-1", "ImageName": "ami-0bbe28eb2173f6167", "VPCName": "vpc-1", "SubnetName": "subnet-1", "SecurityGroupNames": [ "sg-01" ], "VMSpecName": "t2.micro", "KeyPairName": "keypair-1", "RootDiskType": "gp3", "RootDiskSize": "24" } }'
- Create VM
(2) VM ๋ชฉ๋ก ๋ฐ ์ ๋ณด ์กฐํ
- CLI ํ์ฉ ์์
-
List VM Info(All VM List)
./spctl vm list -c aws-us-east-2-connection-01
output
{ "vm": [ { "AccessPoint": "", "IId": { "NameId": "vm-1", "SystemId": "i-0f3fb48149865e5e8" }, "ImageIId": { "NameId": "ami-0bbe28eb2173f6167", "SystemId": "ami-0bbe28eb2173f6167" }, "ImageType": "PublicImage", "KeyPairIId": { "NameId": "keypair-1", "SystemId": "keypair-1-crm2k9rp70itoiaonq40" }, "KeyValueList": [ { "Key": "State", "Value": "running" }, ... ], "NetworkInterface": "eni-attach-0883a840e2f3878a0", "Platform": "LINUX/UNIX", "PrivateDNS": "ip-192-168-1-54.us-east-2.compute.internal", "PrivateIP": "192.168.1.54", "PublicIP": "18.227.52.207", "Region": { "Region": "us-east-2", "Zone": "us-east-2a" }, "RootDeviceName": "/dev/sda1", "RootDiskSize": "24", "RootDiskType": "gp3", "SSHAccessPoint": "18.227.52.207:22", "SecurityGroupIIds": [ { "NameId": "sg-01", "SystemId": "sg-0e4afa53da260cef2" } ], "StartTime": "2024-09-19T14:01:36Z", "SubnetIID": { "NameId": "subnet-1", "SystemId": "subnet-061d9826ad52d3fb8" }, "TagList": [ { "Key": "Name", "Value": "vm-1-crm2tfjp70itoiaonq50" } ], "VMBlockDisk": "/dev/sda1", "VMSpecName": "t2.micro", "VMUserId": "cb-user", "VpcIID": { "NameId": "vpc-1", "SystemId": "vpc-01ef75ec235085cd8" } } ] }
-
Get VM Info(Specific VM)
./spctl vm get -n vm-1 -c aws-us-east-2-connection-01
output
{ "AccessPoint": "", "IId": { "NameId": "vm-1", "SystemId": "i-0f3fb48149865e5e8" }, "ImageIId": { "NameId": "ami-0bbe28eb2173f6167", "SystemId": "ami-0bbe28eb2173f6167" }, "ImageType": "PublicImage", "KeyPairIId": { "NameId": "keypair-1", "SystemId": "keypair-1-crm2k9rp70itoiaonq40" }, "KeyValueList": [ { "Key": "State", "Value": "running" }, ... ], "NetworkInterface": "eni-attach-0883a840e2f3878a0", "Platform": "LINUX/UNIX", "PrivateDNS": "ip-192-168-1-54.us-east-2.compute.internal", "PrivateIP": "192.168.1.54", "PublicIP": "18.227.52.207", "Region": { "Region": "us-east-2", "Zone": "us-east-2a" }, "RootDeviceName": "/dev/sda1", "RootDiskSize": "24", "RootDiskType": "gp3", "SSHAccessPoint": "18.227.52.207:22", "SecurityGroupIIds": [ { "NameId": "sg-01", "SystemId": "sg-0e4afa53da260cef2" } ], "StartTime": "2024-09-19T14:01:36Z", "SubnetIID": { "NameId": "subnet-1", "SystemId": "subnet-061d9826ad52d3fb8" }, "TagList": [ { "Key": "Name", "Value": "vm-1-crm2tfjp70itoiaonq50" } ], "VMBlockDisk": "/dev/sda1", "VMSpecName": "t2.micro", "VMUserId": "cb-user", "VpcIID": { "NameId": "vpc-1", "SystemId": "vpc-01ef75ec235085cd8" } }
-
(3) VM ์ํ ๋ชฉ๋ก ๋ฐ ์ ๋ณด ์กฐํ
- CLI ํ์ฉ ์์
-
List VM Status Info(All VM Status)
./spctl vm-status list -c aws-us-east-2-connection-01
output
{ "vmstatus": [ { "IId": { "NameId": "vm-1", "SystemId": "i-0f3fb48149865e5e8" }, "VmStatus": "Running" } ] }
-
Get VM Status Info(Specific VM Status)
./spctl vm-status get -n vm-1 -c aws-us-east-2-connection-01
output
{ "Status": "Running" }
-
(4) VM ์ข ๋ฃ
- CLI ํ์ฉ ์์
-
Terminate VM
./spctl vm terminate -n vm-1 -d '{ "ConnectionName": "aws-us-east-2-connection-01" }'
output
{ "Status": "Terminated" }
-