clusters

package
v0.0.0-...-d823fe1 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2021 License: Apache-2.0 Imports: 3 Imported by: 3

Documentation

Overview

Package Clusters enables management and retrieval of Clusters CCE service.

Example to List Clusters

listOpts:=clusters.ListOpts{}
allClusters,err:=clusters.List(client,listOpts)
if err != nil {
	panic(err)
}

for _, cluster := range allClusters {
	fmt.Printf("%+v\n", cluster)
}

Example to Create a cluster

    createOpts:=clusters.CreateOpts{Kind:"Cluster",
							        ApiVersion:"v3",
							        Metadata:clusters.CreateMetaData{Name:"test-cluster"},
							        Spec:clusters.Spec{Type: "VirtualMachine",
												       Flavor: "cce.s1.small",
												       Version:"v1.7.3-r10",
												       HostNetwork:clusters.HostNetworkSpec{VpcId:"3b9740a0-b44d-48f0-84ee-42eb166e54f7",
																					SubnetId:"3e8e5957-649f-477b-9e5b-f1f75b21c045",},
												       ContainerNetwork:clusters.ContainerNetworkSpec{Mode:"overlay_l2"},
													},
	         }
 	cluster,err := clusters.Create(client,createOpts).Extract()
	if err != nil {
		panic(err)
	}

Example to Update a cluster

updateOpts := clusters.UpdateOpts{Spec:clusters.UpdateSpec{Description:"test"}}

clusterID := "4e8e5957-649f-477b-9e5b-f1f75b21c03c"

cluster,err := clusters.Update(client,clusterID,updateOpts).Extract()
if err != nil {
	panic(err)
}

Example to Delete a cluster

clusterID := "4e8e5957-649f-477b-9e5b-f1f75b21c03c"

err := clusters.Delete(client,clusterID).ExtractErr()
if err != nil {
	panic(err)
}

Index

Constants

This section is empty.

Variables

View Source
var RequestOpts golangsdk.RequestOpts = golangsdk.RequestOpts{
	MoreHeaders: map[string]string{"Content-Type": "application/json"},
}

Functions

func GetStructNestedField

func GetStructNestedField(v *Clusters, field string, structDriller []string) string

Types

type AuthenticationSpec

type AuthenticationSpec struct {
	//Authentication mode: rbac , x509 or authenticating_proxy
	Mode                string            `json:"mode" required:"true"`
	AuthenticatingProxy map[string]string `json:"authenticatingProxy" required:"true"`
}

Authentication parameters

type CertCluster

type CertCluster struct {
	//Server IP address
	Server string `json:"server"`
	//Certificate data
	CertAuthorityData string `json:"certificate-authority-data"`
}

type CertClusters

type CertClusters struct {
	//Cluster name
	Name string `json:"name"`
	//Cluster information
	Cluster CertCluster `json:"cluster"`
}

type CertContext

type CertContext struct {
	//Cluster name
	Cluster string `json:"cluster"`
	//User name
	User string `json:"user"`
}

type CertContexts

type CertContexts struct {
	//Context name
	Name string `json:"name"`
	//Context information
	Context CertContext `json:"context"`
}

type CertUser

type CertUser struct {
	//Client certificate
	ClientCertData string `json:"client-certificate-data"`
	//Client key data
	ClientKeyData string `json:"client-key-data"`
}

type CertUsers

type CertUsers struct {
	//User name
	Name string `json:"name"`
	//Cluster information
	User CertUser `json:"user"`
}

type Certificate

type Certificate struct {
	//API type, fixed value Config
	Kind string `json:"kind"`
	//API version, fixed value v1
	ApiVersion string `json:"apiVersion"`
	//Cluster list
	Clusters []CertClusters `json:"clusters"`
	//User list
	Users []CertUsers `json:"users"`
	//Context list
	Contexts []CertContexts `json:"contexts"`
	//The current context
	CurrentContext string `json:"current-context"`
}

type Clusters

type Clusters struct {
	// API type, fixed value Cluster
	Kind string `json:"kind" required:"true"`
	//API version, fixed value v3
	ApiVersion string `json:"apiversion" required:"true"`
	//Metadata of a Cluster
	Metadata MetaData `json:"metadata" required:"true"`
	//specifications of a Cluster
	Spec Spec `json:"spec" required:"true"`
	//status of a Cluster
	Status Status `json:"status"`
}

func FilterClusters

func FilterClusters(clusters []Clusters, opts ListOpts) []Clusters

func List

func List(client *golangsdk.ServiceClient, opts ListOpts) ([]Clusters, error)

List returns collection of clusters.

type Conditions

type Conditions struct {
	//The type of component
	Type string `json:"type"`
	//The state of the component
	Status string `json:"status"`
	//The reason that the component becomes current
	Reason string `json:"reason"`
}

type ContainerNetworkSpec

type ContainerNetworkSpec struct {
	//Container network type: overlay_l2 , underlay_ipvlan or vpc-router
	Mode string `json:"mode" required:"true"`
	//Container network segment: 172.16.0.0/16 ~ 172.31.0.0/16. If there is a network segment conflict, it will be automatically reselected.
	Cidr string `json:"cidr,omitempty"`
}

Container network parameters

type CreateMetaData

type CreateMetaData struct {
	// Cluster unique name
	Name string `json:"name" required:"true"`
	// Cluster tag, key/value pair format
	Labels map[string]string `json:"labels,omitempty"`
	// Cluster annotation, key/value pair format
	Annotations map[string]string `json:"annotations,omitempty"`
}

Metadata required to create a cluster

type CreateOpts

type CreateOpts struct {
	// API type, fixed value Cluster
	Kind string `json:"kind" required:"true"`
	// API version, fixed value v3
	ApiVersion string `json:"apiversion" required:"true"`
	// Metadata required to create a cluster
	Metadata CreateMetaData `json:"metadata" required:"true"`
	// specifications to create a cluster
	Spec Spec `json:"spec" required:"true"`
}

CreateOpts contains all the values needed to create a new cluster

func (CreateOpts) ToClusterCreateMap

func (opts CreateOpts) ToClusterCreateMap() (map[string]interface{}, error)

ToClusterCreateMap builds a create request body from CreateOpts.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToClusterCreateMap() (map[string]interface{}, error)
}

CreateOptsBuilder allows extensions to add additional parameters to the Create request.

type CreateResult

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

CreateResult represents the result of a create operation. Call its Extract method to interpret it as a Cluster.

func Create

Create accepts a CreateOpts struct and uses the values to create a new logical cluster.

func (CreateResult) Extract

func (r CreateResult) Extract() (*Clusters, error)

Extract is a function that accepts a result and extracts a cluster.

func (CreateResult) ExtractClusters

func (r CreateResult) ExtractClusters() ([]Clusters, error)

ExtractCluster is a function that accepts a ListOpts struct, which allows you to filter and sort the returned collection for greater efficiency.

type DeleteOpts

type DeleteOpts struct {
	ErrorStatus string `q:"errorStatus"`
	DeleteEfs   string `q:"delete_efs"`
	DeleteENI   string `q:"delete_eni"`
	DeleteEvs   string `q:"delete_evs"`
	DeleteNet   string `q:"delete_net"`
	DeleteObs   string `q:"delete_obs"`
	DeleteSfs   string `q:"delete_sfs"`
}

func (DeleteOpts) ToDeleteQuery

func (opts DeleteOpts) ToDeleteQuery() (string, error)

type DeleteOptsBuilder

type DeleteOptsBuilder interface {
	ToDeleteQuery() (string, error)
}

type DeleteResult

type DeleteResult struct {
	golangsdk.ErrResult
}

DeleteResult represents the result of a delete operation. Call its ExtractErr method to determine if the request succeeded or failed.

func Delete

func Delete(c *golangsdk.ServiceClient, id string) (r DeleteResult)

Delete will permanently delete a particular cluster based on its unique ID.

func DeleteWithOpts

func DeleteWithOpts(c *golangsdk.ServiceClient, id string, opts DeleteOptsBuilder) (r DeleteResult)

DeleteWithOpts will permanently delete a particular cluster based on its unique ID, and can delete associated resources based on DeleteOpts.

type Endpoints

type Endpoints struct {
	//The address accessed within the user's subnet - Huawei
	Url string `json:"url"`
	//Public network access address - Huawei
	Type string `json:"type"`
	//Internal network address - OTC
	Internal string `json:"internal"`
	//External network address - OTC
	External string `json:"external"`
	//Endpoint of the cluster to be accessed through API Gateway - OTC
	ExternalOTC string `json:"external_otc"`
}

type EniNetworkSpec

type EniNetworkSpec struct {
	//Eni network subnet id
	SubnetId string `json:"eniSubnetId" required:"true"`
	//Eni network cidr
	Cidr string `json:"eniSubnetCIDR" required:"true"`
}

type FilterStruct

type FilterStruct struct {
	Value   string
	Driller []string
}

type GetCertResult

type GetCertResult struct {
	golangsdk.Result
}

func GetCert

func GetCert(c *golangsdk.ServiceClient, id string) (r GetCertResult)

GetCert retrieves a particular cluster certificate based on its unique ID.

func (GetCertResult) Extract

func (r GetCertResult) Extract() (*Certificate, error)

Extract is a function that accepts a result and extracts a cluster.

type GetResult

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

GetResult represents the result of a get operation. Call its Extract method to interpret it as a Cluster.

func Get

func Get(c *golangsdk.ServiceClient, id string) (r GetResult)

Get retrieves a particular cluster based on its unique ID.

func (GetResult) Extract

func (r GetResult) Extract() (*Clusters, error)

Extract is a function that accepts a result and extracts a cluster.

func (GetResult) ExtractClusters

func (r GetResult) ExtractClusters() ([]Clusters, error)

ExtractCluster is a function that accepts a ListOpts struct, which allows you to filter and sort the returned collection for greater efficiency.

type HostNetworkSpec

type HostNetworkSpec struct {
	//The ID of the VPC used to create the node
	VpcId string `json:"vpc" required:"true"`
	//The ID of the subnet used to create the node
	SubnetId string `json:"subnet" required:"true"`
	// The ID of the high speed network used to create bare metal nodes.
	// This parameter is required when creating a bare metal cluster.
	HighwaySubnet string `json:"highwaySubnet,omitempty"`
	//The ID of the Security Group used to create the node
	SecurityGroup string `json:"SecurityGroup,omitempty"`
}

Node network parameters

type IpSpec

type IpSpec struct {
	ID string `json:"id" required:"true"`
}

type ListCluster

type ListCluster struct {
	// API type, fixed value Cluster
	Kind string `json:"kind"`
	//API version, fixed value v3
	ApiVersion string `json:"apiVersion"`
	//all Clusters
	Clusters []Clusters `json:"items"`
}

type ListOpts

type ListOpts struct {
	Name  string `json:"name"`
	ID    string `json:"uuid"`
	Type  string `json:"type"`
	VpcID string `json:"vpc"`
	Phase string `json:"phase"`
}

ListOpts allows the filtering of list data using given parameters.

type ListResult

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

ListResult represents the result of a list operation. Call its ExtractCluster method to interpret it as a Cluster.

func (ListResult) Extract

func (r ListResult) Extract() (*Clusters, error)

Extract is a function that accepts a result and extracts a cluster.

func (ListResult) ExtractClusters

func (r ListResult) ExtractClusters() ([]Clusters, error)

ExtractCluster is a function that accepts a ListOpts struct, which allows you to filter and sort the returned collection for greater efficiency.

type MasterSpec

type MasterSpec struct {
	// AZ of master node
	MasterAZ string `json:"availabilityZone,omitempty"`
}

type MetaData

type MetaData struct {
	//Cluster unique name
	Name string `json:"name"`
	//Cluster unique Id
	Id string `json:"uid"`
	// Cluster tag, key/value pair format
	Labels map[string]string `json:"labels,omitempty"`
	//Cluster annotation, key/value pair format
	Annotations map[string]string `json:"annotations,omitempty"`
}

Metadata required to create a cluster

type OperationResult

type OperationResult struct {
	golangsdk.ErrResult
}

func Operation

func Operation(c *golangsdk.ServiceClient, id, action string) (r OperationResult)

type Spec

type Spec struct {
	//Cluster Type: VirtualMachine, BareMetal, or Windows
	Type string `json:"type" required:"true"`
	// Cluster specifications
	Flavor string `json:"flavor" required:"true"`
	// For the cluster version, please fill in v1.7.3-r10 or v1.9.2-r1. Currently only Kubernetes 1.7 and 1.9 clusters are supported.
	Version string `json:"version,omitempty"`
	//Cluster description
	Description string `json:"description,omitempty"`
	//Public IP ID
	PublicIP string `json:"publicip_id,omitempty"`
	// Node network parameters
	HostNetwork HostNetworkSpec `json:"hostNetwork" required:"true"`
	//Container network parameters
	ContainerNetwork ContainerNetworkSpec `json:"containerNetwork" required:"true"`
	//ENI network parameters
	EniNetwork *EniNetworkSpec `json:"eniNetwork,omitempty"`
	//Authentication parameters
	Authentication AuthenticationSpec `json:"authentication,omitempty"`
	// Charging mode of the cluster, which is 0 (on demand)
	BillingMode int `json:"billingMode,omitempty"`
	//Extended parameter for a cluster
	ExtendParam map[string]interface{} `json:"extendParam,omitempty"`
	//Advanced configuration of master node
	Masters []MasterSpec `json:"masters,omitempty"`
	//Range of kubernetes clusterIp
	KubernetesSvcIPRange string `json:"kubernetesSvcIpRange,omitempty"`
}

Specifications to create a cluster

type Status

type Status struct {
	//The state of the cluster
	Phase string `json:"phase"`
	//The ID of the Job that is operating asynchronously in the cluster
	JobID string `json:"jobID"`
	//Reasons for the cluster to become current
	Reason string `json:"reason"`
	//The status of each component in the cluster
	Conditions Conditions `json:"conditions"`
	//Kube-apiserver access address in the cluster
	Endpoints []Endpoints `json:"-"`
}

func (*Status) UnmarshalJSON

func (r *Status) UnmarshalJSON(b []byte) error

UnmarshalJSON helps to unmarshal Status fields into needed values. OTC and Huawei have different data types and child fields for `endpoints` field in Cluster Status. This function handles the unmarshal for both

type UpdateIpOpts

type UpdateIpOpts struct {
	Action    string `json:"action" required:"true"`
	Spec      IpSpec `json:"spec,omitempty"`
	ElasticIp string `json:"elasticIp"`
}

func (UpdateIpOpts) ToMasterIpUpdateMap

func (opts UpdateIpOpts) ToMasterIpUpdateMap() (map[string]interface{}, error)

type UpdateIpOptsBuilder

type UpdateIpOptsBuilder interface {
	ToMasterIpUpdateMap() (map[string]interface{}, error)
}

type UpdateIpResult

type UpdateIpResult struct {
	golangsdk.ErrResult
}

UpdateIpResult represents the result of an update operation. Call its Extract method to interpret it as a Cluster.

func UpdateMasterIp

func UpdateMasterIp(c *golangsdk.ServiceClient, id string, opts UpdateIpOptsBuilder) (r UpdateIpResult)

Update the access information of a specified cluster.

type UpdateOpts

type UpdateOpts struct {
	Spec UpdateSpec `json:"spec" required:"true"`
}

UpdateOpts contains all the values needed to update a new cluster

func (UpdateOpts) ToClusterUpdateMap

func (opts UpdateOpts) ToClusterUpdateMap() (map[string]interface{}, error)

ToClusterUpdateMap builds an update body based on UpdateOpts.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToClusterUpdateMap() (map[string]interface{}, error)
}

UpdateOptsBuilder allows extensions to add additional parameters to the Update request.

type UpdateResult

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

UpdateResult represents the result of an update operation. Call its Extract method to interpret it as a Cluster.

func Update

Update allows clusters to update description.

func (UpdateResult) Extract

func (r UpdateResult) Extract() (*Clusters, error)

Extract is a function that accepts a result and extracts a cluster.

func (UpdateResult) ExtractClusters

func (r UpdateResult) ExtractClusters() ([]Clusters, error)

ExtractCluster is a function that accepts a ListOpts struct, which allows you to filter and sort the returned collection for greater efficiency.

type UpdateSpec

type UpdateSpec struct {
	// Cluster description
	Description string `json:"description,omitempty"`
}

Directories

Path Synopsis
cluster unit tests
cluster unit tests

Jump to

Keyboard shortcuts

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