resources

package
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2024 License: Apache-2.0 Imports: 30 Imported by: 1

Documentation

Index

Constants

View Source
const (
	GCP_PMKS_SECURITYGROUP_TAG = "cb-spider-pmks-securitygroup-"
	GCP_PMKS_INSTANCEGROUP_KEY = "InstanceGroup_"
	GCP_PMKS_KEYPAIR_KEY       = "keypair"

	GCP_CONTAINER_OPERATION_TYPE_UNSPECIFIED         = -1 //"Not set."
	GCP_CONTAINER_OPERATION_CREATE_CLUSTER           = 1  //"Cluster create."
	GCP_CONTAINER_OPERATION_DELETE_CLUSTER           = 2  //"Cluster delete."
	GCP_CONTAINER_OPERATION_UPGRADE_MASTER           = 3  //"A master upgrade."
	GCP_CONTAINER_OPERATION_REPAIR_CLUSTER           = 4  //"Cluster repair."
	GCP_CONTAINER_OPERATION_UPDATE_CLUSTER           = 5  //"Cluster update."
	GCP_CONTAINER_OPERATION_CREATE_NODE_POOL         = 11 //"Node pool create."
	GCP_CONTAINER_OPERATION_DELETE_NODE_POOL         = 12 //"Node pool delete."
	GCP_CONTAINER_OPERATION_SET_NODE_POOL_MANAGEMENT = 13 //"Set node pool management."
	GCP_CONTAINER_OPERATION_SET_NODE_POOL_SIZE       = 14 //"Set node pool size."
	GCP_CONTAINER_OPERATION_UPGRADE_NODES            = 21 //"A node upgrade."
	GCP_CONTAINER_OPERATION_AUTO_REPAIR_NODES        = 22 //"Automatic node pool repair."
	GCP_CONTAINER_OPERATION_AUTO_UPGRADE_NODES       = 23 //"Automatic node upgrade."
	GCP_CONTAINER_OPERATION_SET_LABELS               = 31 //"Set labels."
	GCP_CONTAINER_OPERATION_SET_MASTER_AUTH          = 32 //"Set/generate master auth materials"
	GCP_CONTAINER_OPERATION_SET_NETWORK_POLICY       = 33 //"Updates network policy for a cluster."
	GCP_CONTAINER_OPERATION_SET_MAINTENANCE_POLICY   = 34 //"Set the maintenance policy."

	GCP_SET_AUTOSCALING_ENABLE   = "SET_AUTOSCALING_ENABLE"
	GCP_SET_AUTOSCALING_NODESIZE = "SET_AUTOSCALING_NODESIZE"
)
View Source
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"
)
View Source
const (
	GCPDiskCreating string = "CREATING"
	GCPDiskReady    string = "READY"
	GCPDiskFailed   string = "FAILED"
	GCPDiskDeleting string = "DELETING"

	DefaultDiskType string = "pd-standard"
)
View Source
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"
)
View Source
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"
)
View Source
const CBDefaultSubnetName string = "cb-vnet" // CB Default Subnet Name
View Source
const CBDefaultVNetName string = "cb-vnet" // CB Default Virtual Network Name
View Source
const (
	GCPMyImageReady string = "READY"
)
View Source
const KEY_VALUE_CONVERT_DEBUG_INFO bool = false
View Source
const OperationGlobal = 1
View Source
const OperationRegion = 2
View Source
const OperationZone = 3

Variables

This section is empty.

Functions

func CheckMachineType

func CheckMachineType(Name string) bool

func ConvertJsonStringNoEscape added in v0.8.2

func ConvertJsonStringNoEscape(v interface{}) (string, error)

Convert from Cloud Object to JSON String type

func ConvertKeyValueList added in v0.7.6

func ConvertKeyValueList(v interface{}) ([]irs.KeyValue, error)

Cloud Object를 CB-KeyValue 형식으로 변환이 필요할 경우 이용

func ConvertToString added in v0.7.6

func ConvertToString(value interface{}) (string, error)

CB-KeyValue 등을 위해 String 타입으로 변환

func ConvertVMStatusString

func ConvertVMStatusString(vmStatus string) (irs.VMStatus, error)

func CreateHashString

func CreateHashString(credentialInfo idrv.CredentialInfo) (string, error)

KeyPair 해시 생성 함수

func FindImageByID added in v0.6.16

func FindImageByID(client *compute.Service, imageIID irs.IID) (*compute.Image, error)

IID 에서 systemID로 image 조회.

func GetCBDefaultSubnetName

func GetCBDefaultSubnetName() string

Subnet

func GetCBDefaultVNetName

func GetCBDefaultVNetName() string

VPC

func GetCallLogScheme added in v0.7.3

func GetCallLogScheme(region idrv.RegionInfo, resourceType call.RES_TYPE, resourceName string, apiName string) call.CLOUDLOGSCHEMA

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 GetInstance added in v0.7.3

func GetInstance(client *compute.Service, credential idrv.CredentialInfo, region idrv.RegionInfo, instance string) (*compute.Instance, error)

Instance 정보조회

func GetInstancesOfInstanceGroup added in v0.7.3

func GetInstancesOfInstanceGroup(client *compute.Service, credential idrv.CredentialInfo, region idrv.RegionInfo, instanceGroup string) ([]string, error)

InstanceGroup의 인스턴스 목록 return

func GetKeyValueList

func GetKeyValueList(i map[string]interface{}) []irs.KeyValue

KeyValue gen func

func GetMachineImageInfo added in v0.6.9

func GetMachineImageInfo(client *compute.Service, projectId string, imageName string) (*compute.MachineImage, error)

func GetPublicImageInfo added in v0.6.16

func GetPublicImageInfo(client *compute.Service, imageIID irs.IID) (*compute.Image, error)

IID 에서 systemID로 image 조회. : systemID가 URL로 되어있어 필요한 값들을 추출하여 사용. projectId, imageName

func GetPublicKey

func GetPublicKey(credentialInfo idrv.CredentialInfo, keyPairName string) (string, error)

Public KeyPair 정보 가져오기

func GetRegion added in v0.7.6

func GetRegion(client *compute.Service, projectId string, regionName string) (*compute.Region, error)

region 조회 GCP에서 region은 regionName과 regionUri로 구분 됨. regionName으로 찾는 function임.

func GetZoneListByRegion added in v0.7.6

func GetZoneListByRegion(client *compute.Service, projectId string, regionUrl string) (*compute.ZoneList, error)

region에 해당하는 zone 목록 조회 filter조건으로 사용하는 region조건은 regionUrl로 넘겨야 함. filter조건 자체가 string이며 regionUrl에 특수문자가 있고 따옴표로 감싸야만 결과가 정상적으로 나옴 region="xxx/xxx/xxx" 형태로 보내야하며 ` ` 로 감싸야 함. filter := "region=https://www.googleapis.com/compute/v1/projects/xxx/regions/us-east1" -> error return. filter := `region="https://www.googleapis.com/compute/v1/projects/xxx/regions/us-east1"` -> 조회결과 옴 filter := `region="us-east1"`// -> 조회결과 없음

func GetZoneStatus added in v0.7.6

func GetZoneStatus(status string) irs.ZoneStatus

Available or Unavailable 로 return Status of the zone, either UP or DOWN. (지원하지 않는 경우 NotSupported)

func InitLog added in v0.7.3

func InitLog()

func ListRegion added in v0.7.6

func ListRegion(client *compute.Service, projectId string) (*compute.RegionList, error)

리전 목록 조회

func LoggingError added in v0.7.3

func LoggingError(hiscallInfo call.CLOUDLOGSCHEMA, err error)

func LoggingInfo added in v0.7.3

func LoggingInfo(hiscallInfo call.CLOUDLOGSCHEMA, start time.Time)

func WaitContainerOperationComplete added in v0.7.3

func WaitContainerOperationComplete(client *container.Service, project string, region string, zone string, resourceId string, operationType int) error

container 의 operation

func WaitContainerOperationDone added in v0.7.3

func WaitContainerOperationDone(client *container.Service, project string, region string, zone string, resourceId string, operationType int, maxTime int) error

20분

func WaitContainerOperationFail added in v0.7.3

func WaitContainerOperationFail(client *container.Service, project string, region string, zone string, resourceId string, operationType int) error

30초동안 Fail 이 떨어지지 않으면 성공

func WaitOperationComplete added in v0.6.0

func WaitOperationComplete(client *compute.Service, project string, region string, zone string, resourceId string, operationType int) error

func WaitUntilComplete added in v0.5.10

func WaitUntilComplete(client *compute.Service, project string, region string, resourceId string, isGlobalAction bool) error

Operation 이 완료 될 때까지 기다림.

Types

type AccessConfig added in v0.5.10

type AccessConfig struct {
	Kind                     string
	Type                     string //enum
	Name                     string
	NatIP                    string
	ExternalIpv6             string
	ExternalIpv6PrefixLength int
	SetPublicPtr             bool
	PublicPtrDomainName      string
	NetworkTier              string // enum
}

type AdvancedMachineFeatures added in v0.5.10

type AdvancedMachineFeatures struct {
	EnableNestedVirtualization bool
	ThreadsPerCore             int
	EnableUefiNetworking       bool
}

type AliasIpRange added in v0.5.10

type AliasIpRange struct {
	IpCidrRange         string
	SubnetworkRangeName string
}

type ConfidentialInstanceConfig added in v0.5.10

type ConfidentialInstanceConfig struct {
	EnableConfidentialCompute bool
}

type ContentAndFileType added in v0.5.10

type ContentAndFileType struct {
	Content  string
	FileType string //enum
}

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 DiskConfig struct {
	DeviceName      string
	InstantiateFrom string // enum,
	AutoDelete      bool
	CustomImage     string
}

type DiskEncryptionKey added in v0.5.10

type DiskEncryptionKey struct {
	RawKey               string
	RsaEncryptedKey      string
	KmsKeyName           string
	Sha256               string
	KmsKeyServiceAccount string
}

type GCPClusterHandler added in v0.7.3

type GCPClusterHandler struct {
	Region          idrv.RegionInfo
	Ctx             context.Context
	Client          *compute.Service
	ContainerClient *container.Service
	Credential      idrv.CredentialInfo
}

func (*GCPClusterHandler) AddNodeGroup added in v0.7.3

func (ClusterHandler *GCPClusterHandler) AddNodeGroup(clusterIID irs.IID, nodeGroupReqInfo irs.NodeGroupInfo) (irs.NodeGroupInfo, error)

객체 조회를 하는 것은 status 가 ing로 나타날 것이므로 operation 수행후 얼마간 실패로 떨어지는지 대기 실패하지 않으면 대기를 종료하고 조회시킴

func (*GCPClusterHandler) ChangeNodeGroupScaling added in v0.7.3

func (ClusterHandler *GCPClusterHandler) ChangeNodeGroupScaling(clusterIID irs.IID, nodeGroupIID irs.IID, desiredNodeSize int, minNodeSize int, maxNodeSize int) (irs.NodeGroupInfo, error)

autoScaling에 대한 설정 값을 바꾼다. TODO : 현재 autoScaling 설정값을 조회해서 다르면 Set 해야하나

func (*GCPClusterHandler) CreateCluster added in v0.7.3

func (ClusterHandler *GCPClusterHandler) CreateCluster(clusterReqInfo irs.ClusterInfo) (irs.ClusterInfo, error)

NodePool 이름이 default-pool로 생성 됨. Machine Type 이 e2-medium으로 생성 됨. BootDisk 도 100으로 생성 됨 sg(firewall rule) 추가 안됨.

fail 기다리는것 처리 확인할 것.

func (*GCPClusterHandler) DeleteCluster added in v0.7.3

func (ClusterHandler *GCPClusterHandler) DeleteCluster(clusterIID irs.IID) (bool, error)

성공 실패여부만 return하는 경우는 Done까지 기다린 후 결과를 return

func (*GCPClusterHandler) GetCluster added in v0.7.3

func (ClusterHandler *GCPClusterHandler) GetCluster(clusterIID irs.IID) (irs.ClusterInfo, error)

func (*GCPClusterHandler) ListCluster added in v0.7.3

func (ClusterHandler *GCPClusterHandler) ListCluster() ([]*irs.ClusterInfo, error)

location은 region 또는 zone path param으로 location이 사용되고 기존 request 객체 내 projectId, zone 은 deprecated Location "-" matches all zones and all regions.

func (*GCPClusterHandler) RemoveNodeGroup added in v0.7.3

func (ClusterHandler *GCPClusterHandler) RemoveNodeGroup(clusterIID irs.IID, nodeGroupIID irs.IID) (bool, error)

성공 실패여부만 return하는 경우는 Done까지 기다린 후 결과를 return

func (*GCPClusterHandler) SetNodeGroupAutoScaling added in v0.7.3

func (ClusterHandler *GCPClusterHandler) SetNodeGroupAutoScaling(clusterIID irs.IID, nodeGroupIID irs.IID, on bool) (bool, error)

autoScaling 에 대한 true/false 만 바꾼다.

func (*GCPClusterHandler) UpgradeCluster added in v0.7.3

func (ClusterHandler *GCPClusterHandler) UpgradeCluster(clusterIID irs.IID, newVersion string) (irs.ClusterInfo, error)

cluster version upgrade 객체 조회를 하는 것은 status 가 ing로 나타날 것이므로 operation 수행후 얼마간 실패로 떨어지는지 대기 실패하지 않으면 대기를 종료하고 조회시킴

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 (DiskHandler *GCPDiskHandler) AttachDisk(diskIID irs.IID, ownerVM irs.IID) (irs.DiskInfo, error)

func (*GCPDiskHandler) ChangeDiskSize added in v0.6.7

func (DiskHandler *GCPDiskHandler) ChangeDiskSize(diskIID irs.IID, size string) (bool, error)

func (*GCPDiskHandler) CreateDisk added in v0.6.7

func (DiskHandler *GCPDiskHandler) CreateDisk(diskReqInfo irs.DiskInfo) (irs.DiskInfo, error)

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

func (DiskHandler *GCPDiskHandler) DetachDisk(diskIID irs.IID, ownerVM irs.IID) (bool, error)

func (*GCPDiskHandler) GetDisk added in v0.6.7

func (DiskHandler *GCPDiskHandler) GetDisk(diskIID irs.IID) (irs.DiskInfo, error)

func (*GCPDiskHandler) ListDisk added in v0.6.7

func (DiskHandler *GCPDiskHandler) ListDisk() ([]*irs.DiskInfo, error)

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

func (imageHandler *GCPImageHandler) GetImage(imageIID irs.IID) (irs.ImageInfo, error)

이슈 #239에 의해 Name 기반에서 URL 기반으로 로직 변경 전달 받은 URL에서 projectId와 Name을 추출해서 조회함.

func (*GCPImageHandler) GetImageByUrl added in v0.2.1

func (imageHandler *GCPImageHandler) GetImageByUrl(imageIID irs.IID) (irs.ImageInfo, error)

이슈 #239에 의해 Name 기반에서 URL 기반으로 로직 변경 전체 목록에서 이미지 정보를 조회 함. - 위의 GetImage()로 검색되지 않는 경우가 발생하면 이 함수를 이용할 것.

func (*GCPImageHandler) ListImage

func (imageHandler *GCPImageHandler) ListImage() ([]*irs.ImageInfo, error)

리스트의 경우 Name 기반으로 조회해서 처리하기에는 너무 느리기 때문에 직접 컨버팅함.

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

func (nlbHandler *GCPNLBHandler) CreateNLB(nlbReqInfo irs.NLBInfo) (irs.NLBInfo, error)

// 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

func (nlbHandler *GCPNLBHandler) GetNLB(nlbIID irs.IID) (irs.NLBInfo, error)

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 으로 가져오도록 함.

func (*GCPNLBHandler) RemoveVMs added in v0.5.10

func (nlbHandler *GCPNLBHandler) RemoveVMs(nlbIID irs.IID, vmIIDs *[]irs.IID) (bool, error)
	targetPool에 vm 삭제
    필요한 parameter는 instanceUrl이며 vmIID.SystemID에 들어있음.
	수정 성공여부 return

type GCPPriceInfoHandler added in v0.8.2

type GCPPriceInfoHandler struct {
	Region               idrv.RegionInfo
	Ctx                  context.Context
	Client               *compute.Service
	BillingCatalogClient *cloudbilling.APIService
	CostEstimationClient *cbb.Service
	Credential           idrv.CredentialInfo
}

func (*GCPPriceInfoHandler) GetPriceInfo added in v0.8.2

func (priceInfoHandler *GCPPriceInfoHandler) GetPriceInfo(productFamily string, regionName string, additionalFilterList []irs.KeyValue) (string, error)

Return the price information of products belonging to the specified Region's PriceFamily in JSON format

func (*GCPPriceInfoHandler) ListProductFamily added in v0.8.2

func (priceInfoHandler *GCPPriceInfoHandler) ListProductFamily(regionName string) ([]string, error)

* BillingCatalogClient.Services.Skus.List()을 호출하여 가져온 Category.ResourceFamily 를 중복 제거하여 리스트 생성

type GCPRegionZoneHandler added in v0.7.6

type GCPRegionZoneHandler struct {
	Region     idrv.RegionInfo
	Ctx        context.Context
	Client     *compute.Service
	Credential idrv.CredentialInfo
}

func (*GCPRegionZoneHandler) GetRegionZone added in v0.7.6

func (regionZoneHandler *GCPRegionZoneHandler) GetRegionZone(regionName string) (irs.RegionZoneInfo, error)

GetRegionZone implements resources.RegionZoneHandler. 특정 region 정보만 가져올 때. regions.list에 filter 조건으로 name=asia-east1 을 추가해도 되나 get api가 있어 해당 api 사용

func (*GCPRegionZoneHandler) ListOrgRegion added in v0.7.6

func (regionZoneHandler *GCPRegionZoneHandler) ListOrgRegion() (string, error)

func (*GCPRegionZoneHandler) ListOrgZone added in v0.7.6

func (regionZoneHandler *GCPRegionZoneHandler) ListOrgZone() (string, error)

func (*GCPRegionZoneHandler) ListRegionZone added in v0.7.6

func (regionZoneHandler *GCPRegionZoneHandler) ListRegionZone() ([]*irs.RegionZoneInfo, error)

required Compute Engine IAM ROLE : compute.regions.list

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 GCPTagHandler added in v0.9.2

type GCPTagHandler struct {
	Region     idrv.RegionInfo
	Ctx        context.Context
	Credential idrv.CredentialInfo

	ComputeClient   *compute.Service
	ContainerClient *container.Service
}

func (*GCPTagHandler) AddTag added in v0.9.2

func (t *GCPTagHandler) AddTag(resType irs.RSType, resIID irs.IID, tag irs.KeyValue) (irs.KeyValue, error)

func (*GCPTagHandler) FindTag added in v0.9.2

func (t *GCPTagHandler) FindTag(resType irs.RSType, keyword string) ([]*irs.TagInfo, error)

func (*GCPTagHandler) GetTag added in v0.9.2

func (t *GCPTagHandler) GetTag(resType irs.RSType, resIID irs.IID, key string) (irs.KeyValue, error)

func (*GCPTagHandler) ListTag added in v0.9.2

func (t *GCPTagHandler) ListTag(resType irs.RSType, resIID irs.IID) ([]irs.KeyValue, error)

func (*GCPTagHandler) RemoveTag added in v0.9.2

func (t *GCPTagHandler) RemoveTag(resType irs.RSType, resIID irs.IID, key string) (bool, error)

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) GetVM

func (vmHandler *GCPVMHandler) GetVM(vmID irs.IID) (irs.VMInfo, error)

func (*GCPVMHandler) GetVMStatus

func (vmHandler *GCPVMHandler) GetVMStatus(vmID irs.IID) (irs.VMStatus, error)

func (*GCPVMHandler) GetVmById added in v0.6.2

func (vmHandler *GCPVMHandler) GetVmById(vmID irs.IID) (irs.VMInfo, error)

GCP에서 instance 조회는 Project, ZONE 이 필수임. 경우에 따라서 Zone 없이 VM ID만으로 조회하느 기능이 필요하여 전체 목록에서 id를 filter해서 가져옴. vmID는 project에서 unique

func (*GCPVMHandler) ListVM

func (vmHandler *GCPVMHandler) ListVM() ([]*irs.VMInfo, error)

func (*GCPVMHandler) ListVMStatus

func (vmHandler *GCPVMHandler) ListVMStatus() ([]*irs.VMStatusInfo, error)

func (*GCPVMHandler) RebootVM

func (vmHandler *GCPVMHandler) RebootVM(vmID irs.IID) (irs.VMStatus, error)

reboot vm : using reset function Suspend/Resume/Reboot 는 async 이므로 바로 return

func (*GCPVMHandler) ResumeVM

func (vmHandler *GCPVMHandler) ResumeVM(vmID irs.IID) (irs.VMStatus, error)

func (*GCPVMHandler) SuspendVM

func (vmHandler *GCPVMHandler) SuspendVM(vmID irs.IID) (irs.VMStatus, error)

stop이라고 보면 될듯

func (*GCPVMHandler) TerminateVM

func (vmHandler *GCPVMHandler) TerminateVM(vmID irs.IID) (irs.VMStatus, error)

func (*GCPVMHandler) WaitForRun added in v0.1.5

func (vmHandler *GCPVMHandler) WaitForRun(vmIID irs.IID) (irs.VMStatus, error)

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 생성 로직 변경 필요 / 서브넷이 백그라운드로 생성되기 때문에 조회 시 모두 생성될 때까지 대기하는 로직 필요(그렇지 않으면 일부 정보가 누락됨) #1067 : gcp는 subnet 생성시 zone을 사용하지 않음.

func (*GCPVPCHandler) DeleteVPC added in v0.1.3

func (vVPCHandler *GCPVPCHandler) DeleteVPC(vpcID irs.IID) (bool, error)

func (*GCPVPCHandler) GetVPC added in v0.1.3

func (vVPCHandler *GCPVPCHandler) GetVPC(vpcIID irs.IID) (irs.VPCInfo, 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 (vVPCHandler *GCPVPCHandler) RemoveSubnet(vpcIID irs.IID, subnetIID irs.IID) (bool, error)

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 GcpCBNetworkInfo struct {
	VpcName   string
	VpcId     string
	CidrBlock string
	IsDefault bool
	State     string

	SubnetName string
	SubnetId   string
}

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 GuestAccelerator struct {
	AcceleratorType  string
	AcceleratorCount int
}

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 InstanceTemplateInfo struct {
	Kind                 string
	Id                   string
	CreationTimestamp    string
	Name                 string
	Description          string
	Properties           Property
	SelfLink             string
	SourceInstance       string
	SourceInstanceParams SourceInstanceParam
}

type KeyValue added in v0.5.10

type KeyValue struct {
	Key   string
	Value string
}

type Label added in v0.5.10

type Label struct {
	String string
}

type Metadata added in v0.5.10

type Metadata struct {
	Kind        string
	Fingerprint string
	Items       []KeyValue
}

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 NodeAffinity struct {
	Key      string
	Operator string //enum
	Values   []string
}

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 RevervationAffinity struct {
	ConsumeReservationType string // enum,
	Key                    string
	Values                 []string
}

type Scheduling added in v0.5.10

type Scheduling struct {
	OnHostMaintenance         string // enum,
	AutomaticRestart          bool
	Preemptible               bool
	NodeAffinities            []NodeAffinity
	MinNodeCpus               int
	LocationHint              string
	ProvisioningModel         string // enum,
	InstanceTerminationAction string // enum
}

type ServiceAccount added in v0.5.10

type ServiceAccount struct {
	Email  string
	Scopes []string
}

type ShieldedInstanceConfig added in v0.5.10

type ShieldedInstanceConfig struct {
	EnableSecureBoot          bool
	EnableVtpm                bool
	EnableIntegrityMonitoring bool
}

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 SourceEncryptionKey struct {
	Sha256               string
	MmsKeyServiceAccount string

	RawKey          string
	RsaEncryptedKey string
	KmsKeyName      string
}

type SourceInstanceParam added in v0.5.10

type SourceInstanceParam struct {
	DiskConfigs []DiskConfig
}

type Tag added in v0.5.10

type Tag struct {
	Items []string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL