cs

package
v0.0.0-...-c22dda2 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2018 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CRMDefaultEndpoint is the default API endpoint of CRM services
	CSDefaultEndpoint = "https://cs.aliyuncs.com"
	CSAPIVersion      = "2015-12-15"
)
View Source
const (
	Initial      = ClusterState("initial")
	Running      = ClusterState("running")
	Updating     = ClusterState("updating")
	Scaling      = ClusterState("scaling")
	Failed       = ClusterState("failed")
	Deleting     = ClusterState("deleting")
	DeleteFailed = ClusterState("deleteFailed")
	Deleted      = ClusterState("deleted")
	InActive     = ClusterState("inactive")
)
View Source
const (
	ClassicNetwork = NetworkModeType("classic")
	VPCNetwork     = NetworkModeType("vpc")
)
View Source
const (
	CRDefaultEndpoint = "https://cr.cn-hangzhou.aliyuncs.com"
	CRAPIVersion      = "2016-06-07"
)
View Source
const ClusterDefaultTimeout = 300
View Source
const DefaultPreSleepTime = 240
View Source
const DefaultWaitForInterval = 10

Variables

This section is empty.

Functions

This section is empty.

Types

type CRAuthorizationToken

type CRAuthorizationToken struct {
	Data struct {
		AuthorizationToken string `json:"authorizationToken"`
		TempUserName       string `json:"tempUserName"`
		ExpireDate         int64  `json:"expireDate"`
	} `json:"data"`
	RequestId string `json:"requestId"`
}

type Client

type Client struct {
	AccessKeyId     string
	AccessKeySecret string
	SecurityToken   string

	Version string
	// contains filtered or unexported fields
}

The Client type encapsulates operations with an OSS region.

func NewCRClientWithSecurityToken

func NewCRClientWithSecurityToken(region, accessKeyId, accessKeySecret, securityToken string) *Client

func NewClient

func NewClient(accessKeyId, accessKeySecret string) *Client

NewClient creates a new instance of CRM client

func NewClientForAussumeRole

func NewClientForAussumeRole(accessKeyId, accessKeySecret, securityToken string) *Client

func (*Client) CreateCluster

func (client *Client) CreateCluster(region common.Region, args *ClusterCreationArgs) (cluster ClusterCreationResponse, err error)

func (*Client) CreateKubernetesCluster

func (client *Client) CreateKubernetesCluster(region common.Region, args *KubernetesCreationArgs) (cluster ClusterCreationResponse, err error)

func (*Client) DeleteCluster

func (client *Client) DeleteCluster(clusterID string) error

func (*Client) DescribeCluster

func (client *Client) DescribeCluster(id string) (cluster ClusterType, err error)

func (*Client) DescribeClusters

func (client *Client) DescribeClusters(nameFilter string) (clusters []ClusterType, err error)

func (*Client) GetCRAuthorizationToken

func (client *Client) GetCRAuthorizationToken() (crtoken CRAuthorizationToken, err error)

func (*Client) GetCRRepoInfo

func (client *Client) GetCRRepoInfo(repoNamespace, repoName string) (str string, err error)

func (*Client) GetClusterCerts

func (client *Client) GetClusterCerts(id string) (certs ClusterCerts, err error)

func (*Client) GetClusterConfig

func (client *Client) GetClusterConfig(id string) (config ClusterConfig, err error)

func (*Client) GetKubernetesClusterNodes

func (client *Client) GetKubernetesClusterNodes(id string, pagination common.Pagination) (nodes []KubernetesNodeType, paginationResult *PaginationResult, err error)

func (*Client) GetProjectClient

func (client *Client) GetProjectClient(clusterId string) (projectClient *ProjectClient, err error)

func (*Client) Invoke

func (client *Client) Invoke(region common.Region, method string, path string, query url.Values, args interface{}, response interface{}) error

Invoke sends the raw HTTP request for ECS services

func (*Client) ModifyClusterName

func (client *Client) ModifyClusterName(clusterID, clusterName string) error

func (*Client) ResizeCluster

func (client *Client) ResizeCluster(clusterID string, args *ClusterResizeArgs) error

func (*Client) ResizeKubernetes

func (client *Client) ResizeKubernetes(clusterID string, args *KubernetesCreationArgs) error

func (*Client) SetDebug

func (client *Client) SetDebug(debug bool)

SetDebug sets debug mode to log the request/response message

func (*Client) SetUserAgent

func (client *Client) SetUserAgent(userAgent string)

SetUserAgent sets user agent to log the request/response message

func (*Client) WaitForClusterAsyn

func (client *Client) WaitForClusterAsyn(clusterId string, status ClusterState, timeout int) error

WaitForCluster waits for instance to given status when instance.NotFound wait until timeout

type ClusterCerts

type ClusterCerts struct {
	CA   string `json:"ca,omitempty"`
	Key  string `json:"key,omitempty"`
	Cert string `json:"cert,omitempty"`
}

type ClusterConfig

type ClusterConfig struct {
	Config string `json:"config"`
}

type ClusterCreationArgs

type ClusterCreationArgs struct {
	Name             string           `json:"name"`
	Size             int64            `json:"size"`
	NetworkMode      NetworkModeType  `json:"network_mode"`
	SubnetCIDR       string           `json:"subnet_cidr,omitempty"`
	InstanceType     string           `json:"instance_type"`
	VPCID            string           `json:"vpc_id,omitempty"`
	VSwitchID        string           `json:"vswitch_id,omitempty"`
	Password         string           `json:"password"`
	DataDiskSize     int64            `json:"data_disk_size"`
	DataDiskCategory ecs.DiskCategory `json:"data_disk_category"`
	ECSImageID       string           `json:"ecs_image_id,omitempty"`
	IOOptimized      ecs.IoOptimized  `json:"io_optimized"`
	ReleaseEipFlag   bool             `json:"release_eip_flag"`
}

type ClusterCreationResponse

type ClusterCreationResponse struct {
	Response
	ClusterID string `json:"cluster_id"`
}

type ClusterResizeArgs

type ClusterResizeArgs struct {
	Size             int64            `json:"size"`
	InstanceType     string           `json:"instance_type"`
	Password         string           `json:"password"`
	DataDiskSize     int64            `json:"data_disk_size"`
	DataDiskCategory ecs.DiskCategory `json:"data_disk_category"`
	ECSImageID       string           `json:"ecs_image_id,omitempty"`
	IOOptimized      ecs.IoOptimized  `json:"io_optimized"`
}

type ClusterState

type ClusterState string

type ClusterType

type ClusterType struct {
	AgentVersion           string           `json:"agent_version"`
	ClusterID              string           `json:"cluster_id"`
	Name                   string           `json:"name"`
	Created                util.ISO6801Time `json:"created"`
	ExternalLoadbalancerID string           `json:"external_loadbalancer_id"`
	MasterURL              string           `json:"master_url"`
	NetworkMode            NetworkModeType  `json:"network_mode"`
	RegionID               common.Region    `json:"region_id"`
	SecurityGroupID        string           `json:"security_group_id"`
	Size                   int64            `json:"size"`
	State                  ClusterState     `json:"state"`
	Updated                util.ISO6801Time `json:"updated"`
	VPCID                  string           `json:"vpc_id"`
	VSwitchID              string           `json:"vswitch_id"`
	NodeStatus             string           `json:"node_status"`
	DockerVersion          string           `json:"docker_version"`
}

https://help.aliyun.com/document_detail/26053.html

type Container

type Container struct {
	Name      string            `json:"name"`
	Node      string            `json:"node"`
	VMID      string            `json:"vm_id"`
	IP        string            `json:"ip"`
	Running   bool              `json:"running"`
	Status    string            `json:"status"`
	Health    string            `json:"health"`
	StatusExt string            `json:"status_ext"`
	FailCount int               `json:"fail_count"`
	Ports     map[string][]Port `json:"ports"`
}

type Definition

type Definition struct {
	Environment        []string `json:"environment"`
	Image              string   `json:"image"`
	KernelMemory       int      `json:"kernel_memory"`
	Labels             Labels   `json:"labels"`
	MemLimit           int      `json:"mem_limit"`
	MemswapLimit       int      `json:"memswap_limit"`
	MemswapReservation int      `json:"memswap_reservation"`
	OomKillDisable     bool     `json:"oom_kill_disable"`
	Restart            string   `json:"restart"`
	ShmSize            int      `json:"shm_size"`
	Volumes            []string `json:"volumes"`
}

type DriverOptions

type DriverOptions interface {
	// contains filtered or unexported methods
}

type GetKubernetesClusterNodesResponse

type GetKubernetesClusterNodesResponse struct {
	Response
	Page  PaginationResult     `json:"page"`
	Nodes []KubernetesNodeType `json:"nodes"`
}

type GetProjectResponse

type GetProjectResponse Project

type GetProjectsResponse

type GetProjectsResponse []Project

type GetServiceResponse

type GetServiceResponse Service

type GetServicesResponse

type GetServicesResponse []Service

type GetSwarmClusterNodesResponse

type GetSwarmClusterNodesResponse []SwarmNodeType

type GetVolumeResponse

type GetVolumeResponse struct {
	Name       string            `json:"Name"`
	Driver     string            `json:"Driver"`
	Mountpoint string            `json:"Mountpoint"`
	Labels     map[string]string `json:"Labels"`
	Scope      string            `json:"Scope"`
	Node       string            `json:"Node"`
	Refs       []VolumeRef       `json:"Refs"`
}

type GetVolumesResponse

type GetVolumesResponse struct {
	Volumes []GetVolumeResponse `json:"Volumes"`
}

type KubernetesCreationArgs

type KubernetesCreationArgs struct {
	ClusterType       string              `json:"cluster_type"`
	Name              string              `json:"name"`
	DisableRollback   bool                `json:"disable_rollback"`
	TimeoutMins       int64               `json:"timeout_mins"`
	KubernetesVersion string              `json:"kubernetes_version"`
	StackParams       KubernetesStackArgs `json:"stack_params"`
}

type KubernetesNodeType

type KubernetesNodeType struct {
	InstanceType       string   `json:"instance_type"`
	IpAddress          []string `json:"ip_address"`
	InstanceChargeType string   `json:"instance_charge_type"`
	InstanceRole       string   `json:"instance_role"`
	CreationTime       string   `json:"creation_time"`
	InstanceName       string   `json:"instance_name"`
	InstanceTypeFamily string   `json:"instance_type_family"`
	HostName           string   `json:"host_name"`
	ImageId            string   `json:"image_id"`
	InstanceId         string   `json:"instance_id"`
}

type KubernetesStackArgs

type KubernetesStackArgs struct {
	VPCID                    string           `json:"VpcId,omitempty"`
	VSwitchID                string           `json:"VSwitchId,omitempty"`
	MasterInstanceType       string           `json:"MasterInstanceType"`
	WorkerInstanceType       string           `json:"WorkerInstanceType"`
	NumOfNodes               int64            `json:"NumOfNodes"`
	Password                 string           `json:"LoginPassword"`
	DockerVersion            string           `json:"DockerVersion"`
	KubernetesVersion        string           `json:"KubernetesVersion"`
	ZoneId                   string           `json:"ZoneId"`
	ContainerCIDR            string           `json:"ContainerCIDR"`
	ServiceCIDR              string           `json:"ServiceCIDR"`
	SSHFlags                 bool             `json:"SSHFlags"`
	MasterSystemDiskSize     int64            `json:"MasterSystemDiskSize"`
	MasterSystemDiskCategory ecs.DiskCategory `json:"MasterSystemDiskCategory"`
	WorkerSystemDiskSize     int64            `json:"WorkerSystemDiskSize"`
	WorkerSystemDiskCategory ecs.DiskCategory `json:"WorkerSystemDiskCategory"`
	ImageID                  string           `json:"ImageId,omitempty"`
	CloudMonitorFlags        bool             `json:"CloudMonitorFlags"`
	SNatEntry                bool             `json:"SNatEntry"`
}

type Labels

type Labels map[string]string

type ModifyClusterNameArgs

type ModifyClusterNameArgs struct {
	Name string `json:"name"`
}

type NASOpts

type NASOpts struct {
	DiskId string `json:"disk_id"`
	Host   string `json:"host"`
	Path   string `json:"path"`
	Mode   string `json:"mode"`
}

type NetworkModeType

type NetworkModeType string

type NodeStatus

type NodeStatus struct {
	Health   int64 `json:"health"`
	Unhealth int64 `json:"unhealth"`
}

type OSSOpts

type OSSOpts struct {
	Bucket          string `json:"bucket"`
	AccessKeyId     string `json:"ak_id"`
	AccessKeySecret string `json:"ak_secret"`
	URL             string `json:"url"`
	NoStatCache     string `json:"no_stat_cache"`
	OtherOpts       string `json:"other_opts"`
}

type PaginationResult

type PaginationResult struct {
	TotalCount int `json:"total_count"`
	PageNumber int `json:"page_number"`
	PageSize   int `json:"page_size"`
}

type Port

type Port struct {
	HostIP   string `json:"host_ip"`
	HostPort string `json:"host_port"`
}

type Project

type Project struct {
	Name         string            `json:"name"`
	Description  string            `json:"description"`
	Template     string            `json:"template"`
	Version      string            `json:"version"`
	Created      string            `json:"created"`
	Updated      string            `json:"updated"`
	DesiredState string            `json:"desired_state"`
	CurrentState string            `json:"current_state"`
	Environment  map[string]string `json:"environment"`
	Services     []Service         `json:"services"`
}

type ProjectClient

type ProjectClient struct {
	// contains filtered or unexported fields
}

func NewProjectClient

func NewProjectClient(clusterId, endpoint string, clusterCerts ClusterCerts) (client *ProjectClient, err error)

func (*ProjectClient) ClusterId

func (client *ProjectClient) ClusterId() string

func (*ProjectClient) ConfirmBlueGreenProject

func (client *ProjectClient) ConfirmBlueGreenProject(name string, force bool) (err error)

func (*ProjectClient) CreateProject

func (client *ProjectClient) CreateProject(args *ProjectCreationArgs) (err error)

func (*ProjectClient) CreateVolume

func (client *ProjectClient) CreateVolume(args *VolumeCreationArgs) (err error)

func (*ProjectClient) DeleteProject

func (client *ProjectClient) DeleteProject(name string, forceDelete, deleteVolume bool) (err error)

func (*ProjectClient) DeleteVolume

func (client *ProjectClient) DeleteVolume(name string) (err error)

func (*ProjectClient) Endpoint

func (client *ProjectClient) Endpoint() string

func (*ProjectClient) GetProject

func (client *ProjectClient) GetProject(name string) (project GetProjectResponse, err error)

func (*ProjectClient) GetProjects

func (client *ProjectClient) GetProjects(q string, services, containers bool) (projects GetProjectsResponse, err error)

func (*ProjectClient) GetService

func (client *ProjectClient) GetService(serviceId string) (service GetServiceResponse, err error)

func (*ProjectClient) GetServices

func (client *ProjectClient) GetServices(q string, containers bool) (services GetServicesResponse, err error)

func (*ProjectClient) GetSwarmClusterNodes

func (client *ProjectClient) GetSwarmClusterNodes() (project GetSwarmClusterNodesResponse, err error)

func (*ProjectClient) GetVolume

func (client *ProjectClient) GetVolume(name string) (volume GetVolumeResponse, err error)

func (*ProjectClient) GetVolumes

func (client *ProjectClient) GetVolumes() (volumes GetVolumesResponse, err error)

func (*ProjectClient) Invoke

func (client *ProjectClient) Invoke(method string, path string, query url.Values, args interface{}, response interface{}) error

func (*ProjectClient) KillProject

func (client *ProjectClient) KillProject(name string, signal ...string) (err error)

func (*ProjectClient) KillService

func (client *ProjectClient) KillService(serviceId string, signal ...string) (err error)

func (*ProjectClient) RollBackBlueGreenProject

func (client *ProjectClient) RollBackBlueGreenProject(name string, force bool) (err error)

func (*ProjectClient) ScaleService

func (client *ProjectClient) ScaleService(args *ScaleServiceArgs) (err error)

func (*ProjectClient) SetDebug

func (client *ProjectClient) SetDebug(debug bool)

SetDebug sets debug mode to log the request/response message

func (*ProjectClient) SetUserAgent

func (client *ProjectClient) SetUserAgent(userAgent string)

SetUserAgent sets user agent to log the request/response message

func (*ProjectClient) StartProject

func (client *ProjectClient) StartProject(name string) (err error)

func (*ProjectClient) StartService

func (client *ProjectClient) StartService(serviceId string) (err error)

func (*ProjectClient) StopProject

func (client *ProjectClient) StopProject(name string, timeout ...time.Duration) (err error)

func (*ProjectClient) StopService

func (client *ProjectClient) StopService(serviceId string, timeout ...time.Duration) (err error)

func (*ProjectClient) UpdateProject

func (client *ProjectClient) UpdateProject(args *ProjectUpdationArgs) (err error)

type ProjectCreationArgs

type ProjectCreationArgs struct {
	Name        string            `json:"name"`
	Description string            `json:"description"`
	Template    string            `json:"template"`
	Version     string            `json:"version"`
	Environment map[string]string `json:"environment"`
	LatestImage bool              `json:"latest_image"`
}

type ProjectUpdationArgs

type ProjectUpdationArgs struct {
	Name         string            `json:"-"`
	Description  string            `json:"description"`
	Template     string            `json:"template"`
	Version      string            `json:"version"`
	Environment  map[string]string `json:"environment"`
	LatestImage  bool              `json:"latest_image"`
	UpdateMethod string            `json:"update_method"`
}

type Request

type Request struct {
	Method          string
	URL             string
	Version         string
	Region          common.Region
	Signature       string
	SignatureMethod string
	SignatureNonce  string
	Timestamp       util.ISO6801Time
	Body            []byte
}

type Response

type Response struct {
	RequestId string `json:"request_id"`
}

type ScaleServiceArgs

type ScaleServiceArgs struct {
	ServiceId string    `json:"-"`
	Type      ScaleType `json:"type"`
	Value     int       `json:"value"`
}

type ScaleType

type ScaleType string
const (
	ScaleTo ScaleType = "scale_to"
)

type Service

type Service struct {
	ID             string                 `json:"id"`
	Name           string                 `json:"name"`
	Project        string                 `json:"project"`
	ComposeVersion string                 `json:"compose_version"`
	Containers     map[string]Container   `json:"containers"`
	Created        time.Time              `json:"created"`
	CurrentState   string                 `json:"current_state"`
	Definition     Definition             `json:"definition"`
	DesiredState   string                 `json:"desired_state"`
	Extensions     map[string]interface{} `json:"extensions"`
	Hash           string                 `json:"hash"`
	Updated        time.Time              `json:"updated"`
	Version        string                 `json:"version"`
}

type SwarmNodeType

type SwarmNodeType struct {
	IP                string
	Healthy           bool
	InstanceId        string
	ZoneId            string
	RegionId          string
	Status            string
	CreationTime      string `json:"created"`
	UpdatedTime       string `json:"updated"`
	Containers        int
	ContainersRunning int
	ContainersPaused  int
	ContainersStopped int
	AgentVersion      string
	Name              string
}

type VolumeCreationArgs

type VolumeCreationArgs struct {
	Name       string           `json:"name"`
	Driver     VolumeDriverType `json:"driver"`
	DriverOpts DriverOptions    `json:"driverOpts"`
}

type VolumeCreationResponse

type VolumeCreationResponse struct {
	Name       string            `json:"Name"`
	Driver     string            `json:"Driver"`
	Mountpoint string            `json:"Mountpoint"`
	Labels     map[string]string `json:"Labels"`
	Scope      string            `json:"Scope"`
}

type VolumeDriverType

type VolumeDriverType string
const (
	OSSFSDriver VolumeDriverType = "ossfs"
	NASDriver   VolumeDriverType = "nas"
)

type VolumeRef

type VolumeRef struct {
	Name string `json:"Name"`
	ID   string `json:"ID"`
}

Jump to

Keyboard shortcuts

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