Documentation
¶
Index ¶
- Constants
- func CheckMachineType(Name string) bool
- func ConvertVMStatusString(vmStatus string) (irs.VMStatus, error)
- func CreateHashString(credentialInfo idrv.CredentialInfo) (string, error)
- func FindImageByID(client *compute.Service, imageIID irs.IID) (*compute.Image, error)
- func GetCBDefaultSubnetName() string
- func GetCBDefaultVNetName() string
- func GetDiskInfo(client *compute.Service, credential idrv.CredentialInfo, ...) (*compute.Disk, error)
- func GetKeyValueList(i map[string]interface{}) []irs.KeyValue
- func GetMachineImageInfo(client *compute.Service, projectId string, imageName string) (*compute.MachineImage, error)
- func GetPublicImageInfo(client *compute.Service, imageIID irs.IID) (*compute.Image, error)
- func GetPublicKey(credentialInfo idrv.CredentialInfo, keyPairName string) (string, error)
- func WaitOperationComplete(client *compute.Service, project string, region string, zone string, ...) error
- func WaitUntilComplete(client *compute.Service, project string, region string, resourceId string, ...) error
- type AccessConfig
- type AdvancedMachineFeatures
- type AliasIpRange
- type ConfidentialInstanceConfig
- type ContentAndFileType
- type Disk
- type DiskConfig
- type DiskEncryptionKey
- type GCPDiskHandler
- func (DiskHandler *GCPDiskHandler) AttachDisk(diskIID irs.IID, ownerVM irs.IID) (irs.DiskInfo, error)
- func (DiskHandler *GCPDiskHandler) ChangeDiskSize(diskIID irs.IID, size string) (bool, error)
- func (DiskHandler *GCPDiskHandler) CreateDisk(diskReqInfo irs.DiskInfo) (irs.DiskInfo, error)
- func (DiskHandler *GCPDiskHandler) DeleteDisk(diskIID irs.IID) (bool, error)
- func (DiskHandler *GCPDiskHandler) DetachDisk(diskIID irs.IID, ownerVM irs.IID) (bool, error)
- func (DiskHandler *GCPDiskHandler) GetDisk(diskIID irs.IID) (irs.DiskInfo, error)
- func (DiskHandler *GCPDiskHandler) ListDisk() ([]*irs.DiskInfo, error)
- type GCPImageHandler
- func (imageHandler *GCPImageHandler) CheckWindowsImage(imageIID irs.IID) (bool, error)
- func (imageHandler *GCPImageHandler) ConvertGcpImageInfoToCbImageInfo(imageInfo GcpImageInfo) irs.ImageInfo
- func (imageHandler *GCPImageHandler) CreateImage(imageReqInfo irs.ImageReqInfo) (irs.ImageInfo, error)
- func (imageHandler *GCPImageHandler) DeleteImage(imageIID irs.IID) (bool, error)
- func (imageHandler *GCPImageHandler) FindImageInfo(reqImageName string) (GcpImageInfo, error)
- func (imageHandler *GCPImageHandler) FindImageInfoByName(reqImageName string) (GcpImageInfo, error)
- func (imageHandler *GCPImageHandler) GetImage(imageIID irs.IID) (irs.ImageInfo, error)
- func (imageHandler *GCPImageHandler) GetImageByUrl(imageIID irs.IID) (irs.ImageInfo, error)
- func (imageHandler *GCPImageHandler) ListImage() ([]*irs.ImageInfo, error)
- type GCPKeyPairHandler
- func (keyPairHandler *GCPKeyPairHandler) CreateKey(keyPairReqInfo irs.KeyPairReqInfo) (irs.KeyPairInfo, error)
- func (keyPairHandler *GCPKeyPairHandler) DeleteKey(keyIID irs.IID) (bool, error)
- func (keyPairHandler *GCPKeyPairHandler) GetKey(keyIID irs.IID) (irs.KeyPairInfo, error)
- func (keyPairHandler *GCPKeyPairHandler) ListKey() ([]*irs.KeyPairInfo, error)
- type GCPMyImageHandler
- func (MyImageHandler *GCPMyImageHandler) CheckWindowsImage(myImageIID irs.IID) (bool, error)
- func (MyImageHandler *GCPMyImageHandler) DeleteMyImage(myImageIID irs.IID) (bool, error)
- func (MyImageHandler *GCPMyImageHandler) GetMyImage(myImageIID irs.IID) (irs.MyImageInfo, error)
- func (MyImageHandler *GCPMyImageHandler) ListMyImage() ([]*irs.MyImageInfo, error)
- func (MyImageHandler *GCPMyImageHandler) SnapshotVM(snapshotReqInfo irs.MyImageInfo) (irs.MyImageInfo, error)
- type GCPNLBHandler
- func (nlbHandler *GCPNLBHandler) AddVMs(nlbIID irs.IID, vmIIDs *[]irs.IID) (irs.VMGroupInfo, error)
- func (nlbHandler *GCPNLBHandler) ChangeHealthCheckerInfo(nlbIID irs.IID, healthChecker irs.HealthCheckerInfo) (irs.HealthCheckerInfo, error)
- func (nlbHandler *GCPNLBHandler) ChangeListener(nlbIID irs.IID, listener irs.ListenerInfo) (irs.ListenerInfo, error)
- func (nlbHandler *GCPNLBHandler) ChangeVMGroupInfo(nlbIID irs.IID, vmGroup irs.VMGroupInfo) (irs.VMGroupInfo, error)
- func (nlbHandler *GCPNLBHandler) CreateNLB(nlbReqInfo irs.NLBInfo) (irs.NLBInfo, error)
- func (nlbHandler *GCPNLBHandler) DeleteNLB(nlbIID irs.IID) (bool, error)
- func (nlbHandler *GCPNLBHandler) GetNLB(nlbIID irs.IID) (irs.NLBInfo, error)
- func (nlbHandler *GCPNLBHandler) GetVMGroupHealthInfo(nlbIID irs.IID) (irs.HealthInfo, error)
- func (nlbHandler *GCPNLBHandler) ListNLB() ([]*irs.NLBInfo, error)
- func (nlbHandler *GCPNLBHandler) RemoveVMs(nlbIID irs.IID, vmIIDs *[]irs.IID) (bool, error)
- type GCPSecurityHandler
- func (securityHandler *GCPSecurityHandler) AddRules(sgIID irs.IID, securityRules *[]irs.SecurityRuleInfo) (irs.SecurityInfo, error)
- func (securityHandler *GCPSecurityHandler) CreateSecurity(securityReqInfo irs.SecurityReqInfo) (irs.SecurityInfo, error)
- func (securityHandler *GCPSecurityHandler) DeleteSecurity(securityIID irs.IID) (bool, error)
- func (securityHandler *GCPSecurityHandler) GetSecurity(securityIID irs.IID) (irs.SecurityInfo, error)
- func (securityHandler *GCPSecurityHandler) ListSecurity() ([]*irs.SecurityInfo, error)
- func (securityHandler *GCPSecurityHandler) RemoveRules(sgIID irs.IID, securityRules *[]irs.SecurityRuleInfo) (bool, error)
- func (securityHandler *GCPSecurityHandler) WaitUntilComplete(resourceId string) error
- type GCPVMHandler
- func (vmHandler *GCPVMHandler) GCPInstanceStop(projectID string, zoneID string, gpcInstanceID string) (*compute.Operation, error)
- func (vmHandler *GCPVMHandler) GetVM(vmID irs.IID) (irs.VMInfo, error)
- func (vmHandler *GCPVMHandler) GetVMStatus(vmID irs.IID) (irs.VMStatus, error)
- func (vmHandler *GCPVMHandler) GetVmById(vmID irs.IID) (irs.VMInfo, error)
- func (vmHandler *GCPVMHandler) ListVM() ([]*irs.VMInfo, error)
- func (vmHandler *GCPVMHandler) ListVMStatus() ([]*irs.VMStatusInfo, error)
- func (vmHandler *GCPVMHandler) RebootVM(vmID irs.IID) (irs.VMStatus, error)
- func (vmHandler *GCPVMHandler) ResumeVM(vmID irs.IID) (irs.VMStatus, error)
- func (vmHandler *GCPVMHandler) StartVM(vmReqInfo irs.VMReqInfo) (irs.VMInfo, error)
- func (vmHandler *GCPVMHandler) SuspendVM(vmID irs.IID) (irs.VMStatus, error)
- func (vmHandler *GCPVMHandler) TerminateVM(vmID irs.IID) (irs.VMStatus, error)
- func (vmHandler *GCPVMHandler) WaitForRun(vmIID irs.IID) (irs.VMStatus, error)
- type GCPVMSpecHandler
- func (vmSpecHandler *GCPVMSpecHandler) GetOrgVMSpec(Name string) (string, error)
- func (vmSpecHandler *GCPVMSpecHandler) GetVMSpec(Name string) (irs.VMSpecInfo, error)
- func (vmSpecHandler *GCPVMSpecHandler) ListOrgVMSpec() (string, error)
- func (vmSpecHandler *GCPVMSpecHandler) ListVMSpec() ([]*irs.VMSpecInfo, error)
- type GCPVPCHandler
- func (VPCHandler *GCPVPCHandler) AddSubnet(vpcIID irs.IID, subnetInfo irs.SubnetInfo) (irs.VPCInfo, error)
- func (vVPCHandler *GCPVPCHandler) CreateSubnet(vpcId string, reqSubnetInfo irs.SubnetInfo) (irs.SubnetInfo, error)
- func (vVPCHandler *GCPVPCHandler) CreateVPC(vpcReqInfo irs.VPCReqInfo) (irs.VPCInfo, error)
- func (vVPCHandler *GCPVPCHandler) DeleteVPC(vpcID irs.IID) (bool, error)
- func (vVPCHandler *GCPVPCHandler) GetVPC(vpcIID irs.IID) (irs.VPCInfo, error)
- func (vVPCHandler *GCPVPCHandler) ListVPC() ([]*irs.VPCInfo, error)
- func (vVPCHandler *GCPVPCHandler) RemoveSubnet(vpcIID irs.IID, subnetIID irs.IID) (bool, error)
- func (vVPCHandler *GCPVPCHandler) WaitForRunSubnet(subnetName string, waitFound bool) error
- func (vVPCHandler *GCPVPCHandler) WaitForRunVpc(name string, waitFound bool) error
- func (vVPCHandler *GCPVPCHandler) WaitUntilComplete(resourceId string, isGlobalAction bool) error
- type GcpCBNetworkInfo
- type GcpImageInfo
- type GuestAccelerator
- type GuestOsFeature
- type InitializeParam
- type InstanceTemplateInfo
- type KeyValue
- type Label
- type Metadata
- type NetworkInterface
- type NetworkPerformanceConfig
- type NodeAffinity
- type Property
- type RevervationAffinity
- type Scheduling
- type ServiceAccount
- type ShieldedInstanceConfig
- type ShieldedInstanceInitialState
- type SourceEncryptionKey
- type SourceInstanceParam
- type Tag
Constants ¶
const ( CBVMUser = "cscservice" //CBKeyPairPath = "/cloud-control-manager/cloud-driver/driver-libs/.ssh-gcp/" // by powerkim, 2019.10.30 CBKeyPairPath = "/meta_db/.ssh-gcp/" CBKeyPairProvider = "GCP" )
const ( GCPDiskCreating string = "CREATING" GCPDiskReady string = "READY" GCPDiskFailed string = "FAILED" GCPDiskDeleting string = "DELETING" DefaultDiskType string = "pd-standard" )
const ( //HealthCheck_types : TCP, SSL, HTTP, HTTPS HealthCheck_Http string = "HTTP" HealthCheck_Https string = "HTTPS" HealthCheck_Http2 string = "HTTP2" HealthCheck_TCP string = "TCP" HealthCheck_SSL string = "SSL" HealthState_UNHEALTHY string = "UNHEALTHY" HealthState_HEALTHY string = "HEALTHY" GCP_ForwardingRuleScheme_EXTERNAL = "EXTERNAL" SPIDER_LoadBalancerType_PUBLIC = "PUBLIC" SCOPE_REGION = "REGION" SCOPE_GLOBAL = "GLOBAL" ErrorCode_NotFound = 404 RequestStatus_DONE string = "DONE" StringSeperator_Slash string = "/" StringSeperator_Hypen string = "-" String_Empty string = "" NLB_Component_HEALTHCHECKER string = "HEALTHCHECKER" NLB_Component_TARGETPOOL string = "TARGETPOOL" NLB_Component_FORWARDINGRULE string = "FORWARDINGRULE" )
const ( Const_SecurityRule_Add = "add" Const_SecurityRule_Remove = "remove" Const_Firewall_Allow = true Const_Firewall_Deny = false Const_GCP_Direction_INGRESS = "INGRESS" Const_GCP_Direction_EGRESS = "EGRESS" Const_Spider_Direction_INBOUND = "inbound" Const_Spider_Direction_OUTBOUND = "outbound" Const_IPPROTOCOL_ALL = "ALL" Const_IPPROTOCOL_TCP = "TCP" Const_IPPROTOCOL_UDP = "UDP" Const_IPPROTOCOL_ICMP = "ICMP" Const_IPPROTOCOL_ETC = "ETC" )
const CBDefaultSubnetName string = "cb-vnet" // CB Default Subnet Name
const CBDefaultVNetName string = "cb-vnet" // CB Default Virtual Network Name
const (
GCPMyImageReady string = "READY"
)
const OperationGlobal = 1
const OperationRegion = 2
const OperationZone = 3
Variables ¶
This section is empty.
Functions ¶
func CheckMachineType ¶
func CreateHashString ¶
func CreateHashString(credentialInfo idrv.CredentialInfo) (string, error)
KeyPair 해시 생성 함수
func FindImageByID ¶ added in v0.6.16
IID 에서 systemID로 image 조회.
func GetDiskInfo ¶ added in v0.6.7
func GetDiskInfo(client *compute.Service, credential idrv.CredentialInfo, region idrv.RegionInfo, diskName string) (*compute.Disk, error)
Get 공통으로 사용
func GetKeyValueList ¶
func GetMachineImageInfo ¶ added in v0.6.9
func GetPublicImageInfo ¶ added in v0.6.16
IID 에서 systemID로 image 조회. : systemID가 URL로 되어있어 필요한 값들을 추출하여 사용. projectId, imageName
func GetPublicKey ¶
func GetPublicKey(credentialInfo idrv.CredentialInfo, keyPairName string) (string, error)
Public KeyPair 정보 가져오기
func WaitOperationComplete ¶ added in v0.6.0
Types ¶
type AccessConfig ¶ added in v0.5.10
type AdvancedMachineFeatures ¶ added in v0.5.10
type AliasIpRange ¶ added in v0.5.10
type ConfidentialInstanceConfig ¶ added in v0.5.10
type ConfidentialInstanceConfig struct {
EnableConfidentialCompute bool
}
type ContentAndFileType ¶ added in v0.5.10
type Disk ¶ added in v0.5.10
type Disk struct { Kind string Type string //enum, Mode string //": enum, Source string DeviceName string Index int Boot bool InitializeParams InitializeParam AutoDelete bool Licenses []string Interface string //enum GuestOsFeatures []GuestOsFeature DiskEncryptionKey DiskEncryptionKey DiskSizeGb string ShieldedInstanceInitialState ShieldedInstanceInitialState }
type DiskConfig ¶ added in v0.5.10
type DiskEncryptionKey ¶ added in v0.5.10
type GCPDiskHandler ¶ added in v0.6.7
type GCPDiskHandler struct { Region idrv.RegionInfo Ctx context.Context Client *compute.Service Credential idrv.CredentialInfo }
func (*GCPDiskHandler) AttachDisk ¶ added in v0.6.7
func (*GCPDiskHandler) ChangeDiskSize ¶ added in v0.6.7
func (*GCPDiskHandler) CreateDisk ¶ added in v0.6.7
disk 생성
func (*GCPDiskHandler) DeleteDisk ¶ added in v0.6.7
func (DiskHandler *GCPDiskHandler) DeleteDisk(diskIID irs.IID) (bool, error)
func (*GCPDiskHandler) DetachDisk ¶ added in v0.6.7
type GCPImageHandler ¶
type GCPImageHandler struct { Region idrv.RegionInfo Ctx context.Context Client *compute.Service Credential idrv.CredentialInfo }
func (*GCPImageHandler) CheckWindowsImage ¶ added in v0.6.15
func (imageHandler *GCPImageHandler) CheckWindowsImage(imageIID irs.IID) (bool, error)
windows os 여부 return
func (*GCPImageHandler) ConvertGcpImageInfoToCbImageInfo ¶ added in v0.1.5
func (imageHandler *GCPImageHandler) ConvertGcpImageInfoToCbImageInfo(imageInfo GcpImageInfo) irs.ImageInfo
GCP 호출을 줄이기 위해 조회된 정보를 CB형태로 직접 변환해서 전달 함.
func (*GCPImageHandler) CreateImage ¶
func (imageHandler *GCPImageHandler) CreateImage(imageReqInfo irs.ImageReqInfo) (irs.ImageInfo, error)
func (*GCPImageHandler) DeleteImage ¶
func (imageHandler *GCPImageHandler) DeleteImage(imageIID irs.IID) (bool, error)
public Image 는 지울 수 없는데 어떻게 해야 하는가?
func (*GCPImageHandler) FindImageInfo ¶ added in v0.1.5
func (imageHandler *GCPImageHandler) FindImageInfo(reqImageName string) (GcpImageInfo, error)
이슈 #239에 의해 Name 기반에서 URL 기반으로 로직 변경 사용의 편의를 위해 이미지 URL을 전달 받아서 이미지 정보를 리턴 함. https://cloud.google.com/compute/docs/images?hl=ko @TODO : 효율을 위해서 최소한 ProjectId 정보를 입력 받아야 하지만 현재는 이미지 URL만 전달 받기 때문에 하나로 통합해 놓음.
func (*GCPImageHandler) FindImageInfoByName ¶ added in v0.2.1
func (imageHandler *GCPImageHandler) FindImageInfoByName(reqImageName string) (GcpImageInfo, error)
목록에서 이미지 Name으로 정보를 찾아서 리턴 함. - 2020-07-24 URL기반으로 변경되어서 이 메소드는 사용 안 함. @TODO : 효율을 위해서 최소한 ProjectId 정보를 입력 받아야 하지만 현재는 이미지 명만 전달 받기 때문에 하나로 통합해 놓음.
func (*GCPImageHandler) GetImage ¶
이슈 #239에 의해 Name 기반에서 URL 기반으로 로직 변경 전달 받은 URL에서 projectId와 Name을 추출해서 조회함.
func (*GCPImageHandler) GetImageByUrl ¶ added in v0.2.1
이슈 #239에 의해 Name 기반에서 URL 기반으로 로직 변경 전체 목록에서 이미지 정보를 조회 함. - 위의 GetImage()로 검색되지 않는 경우가 발생하면 이 함수를 이용할 것.
type GCPKeyPairHandler ¶
type GCPKeyPairHandler struct { CredentialInfo idrv.CredentialInfo Region idrv.RegionInfo }
func (*GCPKeyPairHandler) CreateKey ¶
func (keyPairHandler *GCPKeyPairHandler) CreateKey(keyPairReqInfo irs.KeyPairReqInfo) (irs.KeyPairInfo, error)
func (*GCPKeyPairHandler) DeleteKey ¶
func (keyPairHandler *GCPKeyPairHandler) DeleteKey(keyIID irs.IID) (bool, error)
func (*GCPKeyPairHandler) GetKey ¶
func (keyPairHandler *GCPKeyPairHandler) GetKey(keyIID irs.IID) (irs.KeyPairInfo, error)
func (*GCPKeyPairHandler) ListKey ¶
func (keyPairHandler *GCPKeyPairHandler) ListKey() ([]*irs.KeyPairInfo, error)
type GCPMyImageHandler ¶ added in v0.6.9
type GCPMyImageHandler struct { Region idrv.RegionInfo Ctx context.Context Client *compute.Service Credential idrv.CredentialInfo }
func (*GCPMyImageHandler) CheckWindowsImage ¶ added in v0.6.15
func (MyImageHandler *GCPMyImageHandler) CheckWindowsImage(myImageIID irs.IID) (bool, error)
https://cloud.google.com/compute/docs/reference/rest/beta/machineImages/list machine Image에서 os속성이 없음.
func (*GCPMyImageHandler) DeleteMyImage ¶ added in v0.6.9
func (MyImageHandler *GCPMyImageHandler) DeleteMyImage(myImageIID irs.IID) (bool, error)
func (*GCPMyImageHandler) GetMyImage ¶ added in v0.6.9
func (MyImageHandler *GCPMyImageHandler) GetMyImage(myImageIID irs.IID) (irs.MyImageInfo, error)
func (*GCPMyImageHandler) ListMyImage ¶ added in v0.6.9
func (MyImageHandler *GCPMyImageHandler) ListMyImage() ([]*irs.MyImageInfo, error)
func (*GCPMyImageHandler) SnapshotVM ¶ added in v0.6.9
func (MyImageHandler *GCPMyImageHandler) SnapshotVM(snapshotReqInfo irs.MyImageInfo) (irs.MyImageInfo, error)
type GCPNLBHandler ¶ added in v0.5.10
type GCPNLBHandler struct { Region idrv.RegionInfo Ctx context.Context Client *compute.Service Credential idrv.CredentialInfo }
* Adderess(LB) -> pool(backend) -> firewallrule(Listener)
func (*GCPNLBHandler) AddVMs ¶ added in v0.5.10
func (nlbHandler *GCPNLBHandler) AddVMs(nlbIID irs.IID, vmIIDs *[]irs.IID) (irs.VMGroupInfo, error)
targetPool에 vm 추가 필요한 parameter는 instanceUrl이며 vmIID.SystemID에서 vm을 조회하여 사용해야 함. 수정 후 해당 vmGroupInfo(instance 들) return
func (*GCPNLBHandler) ChangeHealthCheckerInfo ¶ added in v0.5.10
func (nlbHandler *GCPNLBHandler) ChangeHealthCheckerInfo(nlbIID irs.IID, healthChecker irs.HealthCheckerInfo) (irs.HealthCheckerInfo, error)
// HealthCheckerInfo 변경
cspId = selfLink healthCheckerName = nbl name 다른 health checker로 변경은 기존 health checker 삭제 후 추가 됨.
func (*GCPNLBHandler) ChangeListener ¶ added in v0.5.10
func (nlbHandler *GCPNLBHandler) ChangeListener(nlbIID irs.IID, listener irs.ListenerInfo) (irs.ListenerInfo, error)
Listener 정보 변경 -> 수정기능이 없으므로 Error return
수정 가능한 항목은 Protocol, IP, Port, DNSName(현재 버전에서는 사용x. 향후 사용가능) : patch function이 있으나 현재는 NetworkTier만 수정가능하여 해당 function사용 못함 부하 분산기를 전환하려면 다음 단계를 따르세요. 프리미엄 등급 IP 주소를 사용하는 새로운 부하 분산기 전달 규칙을 만듭니다. 현재 표준 등급 IP 주소에서 새로운 프리미엄 등급 IP 주소로 트래픽을 천천히 마이그레이션하려면 DNS를 사용합니다. 마이그레이션이 완료되면 표준 등급 IP 주소 및 이와 연결된 리전 부하 분산기를 해제할 수 있습니다. 여러 부하 분산기가 동일한 백엔드를 가리키도록 할 수 있으므로 백엔드를 변경할 필요는 없습니다. (참고) patch 사용하려던 로직 if !strings.EqualFold(listener.Protocol, "") { patchRegionForwardingRule.IPProtocol = listener.Protocol } if !strings.EqualFold(listener.IP, "") { patchRegionForwardingRule.IPAddress = listener.IP } if !strings.EqualFold(listener.Port, "") { patchRegionForwardingRule.PortRange = listener.Port } patchRegionForwardingRule.NetworkTier = "STANDARD" //networkTier : // . If this field is not specified, it is assumed to be PREMIUM. // . If IPAddress is specified, this value must be equal to the networkTier of the Address. // - Region forwording rule : PREMIUM and STANDARD // - Global forwording rule : PREMIUM only nlbHandler.patchRegionForwardingRules(regionID, forwardingRuleName, &patchRegionForwardingRule)
func (*GCPNLBHandler) ChangeVMGroupInfo ¶ added in v0.5.10
func (nlbHandler *GCPNLBHandler) ChangeVMGroupInfo(nlbIID irs.IID, vmGroup irs.VMGroupInfo) (irs.VMGroupInfo, error)
VM Group 변경에서는 VMs 는 제외임. GCP의 경우 frontend와 backend를 protocol, ip로 연결하지 않으므로 해당 기능은 제외한다.
func (*GCPNLBHandler) CreateNLB ¶ added in v0.5.10
// GCP는 동일 vpc가 아니어도 LB 생성가능, but Spider는 동일 vpc에 있어야하므로 사용할 instance 들이 동일한 VPC에 있는지 체크 필요 // 대상 풀 기반 외부 TCP/UDP 네트워크 부하 분산 // 아키텍쳐 : 대상 풀 1개, 여러 전달규칙 ( https://cloud.google.com/load-balancing/docs/network/networklb-target-pools?hl=ko ) // 1LNB = 1 Listener , 1 backend, 1 health checker
// 방법 1. nameId = targetPoolName, systemId = forwardingRulename // * 방법 2. nameId = targetPoolName, systemId = targetPoolUrl // targetPoolName = forwardingRule name 이므로 적당. 단, front-end 와 back-end가 1:1 이어야 함. // 방법 3. nameId = targetPoolUrl, systemId = forwardingRule name // 방법 4. nameId = targetPoolName, systemId = forwardingRule // url 형태가 필요한 resource에 대하여. 조회시에는 끝의 id만 , 실제 사용시에는 id를 바탕으로 url을 만들어 사용 // url set이 가능한 parma은 cspID임.
func (*GCPNLBHandler) DeleteNLB ¶ added in v0.5.10
func (nlbHandler *GCPNLBHandler) DeleteNLB(nlbIID irs.IID) (bool, error)
// NLB 삭제. // delete 는 forwardingRule -> targetPool순으로 삭제. (healthchecker는 어디에 있어도 상관없음.) // targetPool을 먼저 삭제하면 Error 400: The target_pool resource 'xxx' is already being used by 'yyy', resourceInUseByAnotherResource // 두 개가 transaction으로 묶이지 않기 때문에 비정상적인 상태로 존재 가능 // 이 경우에 다시 삭제 요청이 들어 왔을 때 기존에 지워진 것은 skip하고 있는 것만 삭제
// ex) frontend는 삭제되고 targetPool이 어떤이유에서 삭제가 되지 않았을 때, // 다음 시도에서 삭제
삭제 시도 시 404 Error인 경우는 이미 지워진 것일 수 있음. 3가지 resource가 모두 없으면 404 Error 1가지라도 있어서 삭제하면 삭제처리.
func (*GCPNLBHandler) GetNLB ¶ added in v0.5.10
Load balancer 조회 nlbIID 에서 NameId = lbName, targetPoolName, forwardingRuleName
func (*GCPNLBHandler) GetVMGroupHealthInfo ¶ added in v0.5.10
func (nlbHandler *GCPNLBHandler) GetVMGroupHealthInfo(nlbIID irs.IID) (irs.HealthInfo, error)
get HealthCheckerInfo VMGroup의 healthcheckResult
func (*GCPNLBHandler) ListNLB ¶ added in v0.5.10
func (nlbHandler *GCPNLBHandler) ListNLB() ([]*irs.NLBInfo, error)
At the API level, there is no Load Balancer, only the components that make it up. Your best bet to get a view similar to the UI is to list forwarding rules (global and regional).
You can use gcloud compute forwarding-rules list which will show you all the forwarding rules in use (similar to the UI view), along with the IPs of each and the target (which may be a backend service or a target pool).
load balancer => GCP forwardingrules listener => GCP frontend vmGroup => GCP backend. vm instances target pull or instance group list healthchecker => GCP Healthchecker
- backend service 없음. - region forwarding rule, targetpool, targetpool안의 instance에서 사용하는 healthchecker
NLBInfo의 IID 에서 NameId = targetPool name, SystemId = targetPool Url
- VPC정보조회를 위해 INSTANCE 정보 조회 시 같은 region의 다른 zone은 가져오지 못함. getVPCInfoFromVM 으로 가져오도록 함.
type GCPSecurityHandler ¶
type GCPSecurityHandler struct { Region idrv.RegionInfo Ctx context.Context Client *compute.Service Credential idrv.CredentialInfo }
func (*GCPSecurityHandler) AddRules ¶ added in v0.5.4
func (securityHandler *GCPSecurityHandler) AddRules(sgIID irs.IID, securityRules *[]irs.SecurityRuleInfo) (irs.SecurityInfo, error)
func (*GCPSecurityHandler) CreateSecurity ¶
func (securityHandler *GCPSecurityHandler) CreateSecurity(securityReqInfo irs.SecurityReqInfo) (irs.SecurityInfo, error)
SecurityGroup 생성. GCP는 firewall 추가 시 tag = securityGroupName .GCP 기본 정책이 outbound에 대해 all allow이므로
- 우선순위가 가장 낮은(65535) all deny outbound rule 추가
- 우선순위 = 100 인 all allow outbound rule 추가
.사용자의 요청에서 outbound all open 이 있는 경우. default로 생성하므로 skip
func (*GCPSecurityHandler) DeleteSecurity ¶
func (securityHandler *GCPSecurityHandler) DeleteSecurity(securityIID irs.IID) (bool, error)
SecurityGroup 삭제 (해당 Tag를 가진 firewall 삭제)
func (*GCPSecurityHandler) GetSecurity ¶
func (securityHandler *GCPSecurityHandler) GetSecurity(securityIID irs.IID) (irs.SecurityInfo, error)
TAG를 이용해서 해당 security(firewall)를 모두 가와야 하기 때문에 해당 project의 모든 list에서 해당 하는 TAG를 추출
func (*GCPSecurityHandler) ListSecurity ¶
func (securityHandler *GCPSecurityHandler) ListSecurity() ([]*irs.SecurityInfo, error)
func (*GCPSecurityHandler) RemoveRules ¶ added in v0.5.4
func (securityHandler *GCPSecurityHandler) RemoveRules(sgIID irs.IID, securityRules *[]irs.SecurityRuleInfo) (bool, error)
요청받은 Security 그룹안의 SecurityRule이 동일한 firewall 삭제 추가가 allow만 가능 하므로 삭제도 allow만 가능
func (*GCPSecurityHandler) WaitUntilComplete ¶ added in v0.5.5
func (securityHandler *GCPSecurityHandler) WaitUntilComplete(resourceId string) error
securityGroup(firewall) 은 global
type GCPVMHandler ¶
type GCPVMHandler struct { Region idrv.RegionInfo Ctx context.Context Client *compute.Service Credential idrv.CredentialInfo }
func (*GCPVMHandler) GCPInstanceStop ¶ added in v0.6.0
func (vmHandler *GCPVMHandler) GCPInstanceStop(projectID string, zoneID string, gpcInstanceID string) (*compute.Operation, error)
GCP Instance Stop Spider 의 suspendVM와 reboot에서 공통으로 사용하기 위해 별도로 뺌 suspend/resume/reboot는 async 인데 다른 function에서 사용하려면 해당 operation이 종료됐는지 체크 필요 호출하는 function에 operaion을 전달하여 종료여부 판단이 필요하면 사용
func (*GCPVMHandler) GetVMStatus ¶
func (*GCPVMHandler) GetVmById ¶ added in v0.6.2
GCP에서 instance 조회는 Project, ZONE 이 필수임. 경우에 따라서 Zone 없이 VM ID만으로 조회하느 기능이 필요하여 전체 목록에서 id를 filter해서 가져옴. vmID는 project에서 unique
func (*GCPVMHandler) ListVMStatus ¶
func (vmHandler *GCPVMHandler) ListVMStatus() ([]*irs.VMStatusInfo, error)
func (*GCPVMHandler) RebootVM ¶
reboot vm : using reset function Suspend/Resume/Reboot 는 async 이므로 바로 return
func (*GCPVMHandler) StartVM ¶
https://cloud.google.com/compute/docs/reference/rest/v1/instances https://cloud.google.com/compute/docs/disks#disk-types
func (*GCPVMHandler) TerminateVM ¶
func (*GCPVMHandler) WaitForRun ¶ added in v0.1.5
VM 정보를 조회할 수 있을 때까지 최대 30초간 대기
type GCPVMSpecHandler ¶
type GCPVMSpecHandler struct { Region idrv.RegionInfo Ctx context.Context Client *compute.Service Credential idrv.CredentialInfo }
func (*GCPVMSpecHandler) GetOrgVMSpec ¶
func (vmSpecHandler *GCPVMSpecHandler) GetOrgVMSpec(Name string) (string, error)
func (*GCPVMSpecHandler) GetVMSpec ¶
func (vmSpecHandler *GCPVMSpecHandler) GetVMSpec(Name string) (irs.VMSpecInfo, error)
func (*GCPVMSpecHandler) ListOrgVMSpec ¶
func (vmSpecHandler *GCPVMSpecHandler) ListOrgVMSpec() (string, error)
func (*GCPVMSpecHandler) ListVMSpec ¶
func (vmSpecHandler *GCPVMSpecHandler) ListVMSpec() ([]*irs.VMSpecInfo, error)
type GCPVPCHandler ¶ added in v0.1.3
type GCPVPCHandler struct { Region idrv.RegionInfo Ctx context.Context Client *compute.Service Credential idrv.CredentialInfo }
func (*GCPVPCHandler) AddSubnet ¶ added in v0.2.1
func (VPCHandler *GCPVPCHandler) AddSubnet(vpcIID irs.IID, subnetInfo irs.SubnetInfo) (irs.VPCInfo, error)
func (*GCPVPCHandler) CreateSubnet ¶ added in v0.2.1
func (vVPCHandler *GCPVPCHandler) CreateSubnet(vpcId string, reqSubnetInfo irs.SubnetInfo) (irs.SubnetInfo, error)
리턴 값은 구현하지 않고 nil을 리턴함. - 현재 사용되는 곳이 없어서 시간상 누락 시킴.
func (*GCPVPCHandler) CreateVPC ¶ added in v0.1.3
func (vVPCHandler *GCPVPCHandler) CreateVPC(vpcReqInfo irs.VPCReqInfo) (irs.VPCInfo, error)
@TODO : VPC 생성 로직 변경 필요 / 서브넷이 백그라운드로 생성되기 때문에 조회 시 모두 생성될 때까지 대기하는 로직 필요(그렇지 않으면 일부 정보가 누락됨)
func (*GCPVPCHandler) DeleteVPC ¶ added in v0.1.3
func (vVPCHandler *GCPVPCHandler) DeleteVPC(vpcID irs.IID) (bool, error)
func (*GCPVPCHandler) ListVPC ¶ added in v0.1.3
func (vVPCHandler *GCPVPCHandler) ListVPC() ([]*irs.VPCInfo, error)
func (*GCPVPCHandler) RemoveSubnet ¶ added in v0.2.1
func (*GCPVPCHandler) WaitForRunSubnet ¶ added in v0.1.9
func (vVPCHandler *GCPVPCHandler) WaitForRunSubnet(subnetName string, waitFound bool) error
Subnet 정보가 조회될때까지 대기 waitFound : true - 정보가 조회될때까지 대기(생성 시) / false - 정보가 조회되지 않을때까지 대기(삭제 시)
func (*GCPVPCHandler) WaitForRunVpc ¶ added in v0.1.9
func (vVPCHandler *GCPVPCHandler) WaitForRunVpc(name string, waitFound bool) error
VPC 정보가 조회될때까지 대기 waitFound : true - 정보가 조회될때까지 대기(생성 시) / false - 정보가 조회되지 않을때까지 대기(삭제 시)
func (*GCPVPCHandler) WaitUntilComplete ¶ added in v0.1.9
func (vVPCHandler *GCPVPCHandler) WaitUntilComplete(resourceId string, isGlobalAction bool) error
https://cloud.google.com/compute/docs/reference/rest/v1/globalOperations/get
resourceId : API 호출후 받은 리소스 값 VPC : 글로벌 https://www.googleapis.com/compute/v1/projects/mcloud-barista2020/global/networks/cb-vpc-load-test Subnet : Regions https://www.googleapis.com/compute/v1/projects/mcloud-barista2020/regions/asia-northeast3/operations/operation-1590139586815-5a6393937274c-71aebdca-1574e4d7 404 에러 체크해서 global과 region 자동으로 처리 가능하니 필요하면 나중에 공통 유틸로 변경할 것
type GcpCBNetworkInfo ¶
type GcpImageInfo ¶ added in v0.1.5
type GcpImageInfo struct { ImageUrl string //for CB(VM Start) Name string //for CB GuestOS string //for CB (Item.Family) Status string //for CB ProjectId string //for image api call //Id uint64 //for image api call Id string SourceType string //for keyValue SourceImage string //for keyValue SelfLink string //for keyValue Family string //for keyValue }
Name 기반으로 VM생성에 필요한 URL및 Image API 호출과 CB 리턴 정보 조회용
type GuestAccelerator ¶ added in v0.5.10
type GuestOsFeature ¶ added in v0.5.10
type GuestOsFeature struct {
Type string // enum
}
type InitializeParam ¶ added in v0.5.10
type InitializeParam struct { DiskName string SourceImage string DiskSizeGb string DiskType string SourceImageEncryptionKey SourceEncryptionKey Labels Label SourceSnapshot string SourceSnapshotEncryptionKey SourceEncryptionKey Description string ResourcePolicies []string OnUpdateAction string // enum ProvisionedIops string Licenses []string }
type InstanceTemplateInfo ¶ added in v0.5.10
type NetworkInterface ¶ added in v0.5.10
type NetworkInterface struct { Kind string Network string Subnetwork string NetworkIP string Ipv6Address string InternalIpv6PrefixLength int Name string AccessConfigs []AccessConfig Ipv6AccessConfigs []AccessConfig AliasIpRanges []AliasIpRange Fingerprint string StackType string // enum, Ipv6AccessType string // enum, QueueCount int NicType string // enum }
type NetworkPerformanceConfig ¶ added in v0.5.10
type NetworkPerformanceConfig struct {
TotalEgressBandwidthTier string //enum
}
type NodeAffinity ¶ added in v0.5.10
type Property ¶ added in v0.5.10
type Property struct { Description string Tags Tag Fingerprint string ResourceManagerTags string // struct인가? MachineType string CanIpForward bool NetworkInterfaces []NetworkInterface Disks []Disk Metadata Metadata ServiceAccounts []ServiceAccount Scheduling Scheduling Label Label GuestAccelerators []GuestAccelerator MinCpuPlatform string RevervationAffinity RevervationAffinity ShieldedInstanceConfig ShieldedInstanceConfig ResourcePolicies []string ConfidentialInstanceConfig ConfidentialInstanceConfig PrivateIpv6GoogleAccess string // enum AdvancedMachineFeatures AdvancedMachineFeatures NetworkPerformanceConfig NetworkPerformanceConfig }
type RevervationAffinity ¶ added in v0.5.10
type Scheduling ¶ added in v0.5.10
type ServiceAccount ¶ added in v0.5.10
type ShieldedInstanceConfig ¶ added in v0.5.10
type ShieldedInstanceInitialState ¶ added in v0.5.10
type ShieldedInstanceInitialState struct { Pk ContentAndFileType Keys []ContentAndFileType Dbs []ContentAndFileType Dbxs []ContentAndFileType }
type SourceEncryptionKey ¶ added in v0.5.10
type SourceInstanceParam ¶ added in v0.5.10
type SourceInstanceParam struct {
DiskConfigs []DiskConfig
}