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 ¶
- Variables
- func GetStructNestedField(v *Clusters, field string, structDriller []string) string
- type AuthenticationSpec
- type CertCluster
- type CertClusters
- type CertContext
- type CertContexts
- type CertUser
- type CertUsers
- type Certificate
- type CidrSpec
- type Clusters
- type Conditions
- type ContainerNetworkSpec
- type CreateMetaData
- type CreateOpts
- type CreateOptsBuilder
- type CreateResult
- type DeleteOpts
- type DeleteOptsBuilder
- type DeleteResult
- type Endpoints
- type EniNetworkSpec
- type EniSubnetSpec
- type FilterStruct
- type GetCertOpts
- type GetCertResult
- type GetResult
- type HostNetworkSpec
- type IpSpec
- type ListCluster
- type ListOpts
- type ListResult
- type MasterSpec
- type MetaData
- type OperationResult
- type PackageConfiguration
- type ResizeExtendParam
- type ResizeOpts
- type ResizeResp
- type ServiceNetwork
- type Spec
- type Status
- type UpdateContainerNetworkSpec
- type UpdateHostNetworkSpec
- type UpdateIpOpts
- type UpdateIpOptsBuilder
- type UpdateIpResult
- func AddTags(c *golangsdk.ServiceClient, id string, tagList []tags.ResourceTag) (r UpdateIpResult)
- func RemoveTags(c *golangsdk.ServiceClient, id string, tagList []tags.ResourceTag) (r UpdateIpResult)
- func UpdateMasterIp(c *golangsdk.ServiceClient, id string, opts UpdateIpOptsBuilder) (r UpdateIpResult)
- type UpdateMetadata
- type UpdateOpts
- type UpdateOptsBuilder
- type UpdateResult
- type UpdateSpec
- type UpdateTagsOpts
Constants ¶
This section is empty.
Variables ¶
var RequestOpts golangsdk.RequestOpts = golangsdk.RequestOpts{ MoreHeaders: map[string]string{"Content-Type": "application/json"}, }
Functions ¶
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 CertClusters ¶
type CertClusters struct { //Cluster name Name string `json:"name"` //Cluster information Cluster CertCluster `json:"cluster"` }
type CertContext ¶
type CertContexts ¶
type CertContexts struct { //Context name Name string `json:"name"` //Context information Context CertContext `json:"context"` }
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 CidrSpec ¶
type CidrSpec struct { // Container network segment. Recommended: 10.0.0.0/12-19, 172.16.0.0/16-19, and 192.168.0.0/16-19 Cidr string `json:"cidr" required:"true"` }
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 ¶
type Conditions ¶
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"` // List of container CIDR blocks. In clusters of v1.21 and later, the cidrs field is used. // When the cluster network type is vpc-router, you can add multiple container CIDR blocks. // In versions earlier than v1.21, if the cidrs field is used, the first CIDR element in the array is used as the container CIDR block. Cidrs []CidrSpec `json:"cidrs,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"` // Cluster alias Alias string `json:"alias,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 ¶
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 ¶
func Create(c *golangsdk.ServiceClient, opts CreateOptsBuilder) (r CreateResult)
Create accepts a CreateOpts struct and uses the values to create a new logical cluster.
func (CreateResult) ExtractClusters ¶
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"` DeleteSfs30 string `q:"delete_sfs30"` LtsReclaimPolicy string `q:"lts_reclaim_policy"` }
func (DeleteOpts) ToDeleteQuery ¶
func (opts DeleteOpts) ToDeleteQuery() (string, error)
type DeleteOptsBuilder ¶
type DeleteResult ¶
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, will be deprecated in the future SubnetId string `json:"eniSubnetId,omitempty"` //Eni network cidr, will be deprecated in the future Cidr string `json:"eniSubnetCIDR,omitempty"` // Eni network subnet IDs Subnets []EniSubnetSpec `json:"subnets" required:"true"` }
type EniSubnetSpec ¶
type EniSubnetSpec struct {
SubnetID string `json:"subnetID" required:"true"`
}
type FilterStruct ¶
type GetCertOpts ¶
type GetCertOpts struct {
Duration int `json:"duration" required:"true"`
}
type GetCertResult ¶
func GetCert ¶
func GetCert(c *golangsdk.ServiceClient, id string, opts GetCertOpts) (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) ExtractClusters ¶
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 ListCluster ¶
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"` EnterpriseProjectID string `json:"enterpriseProjectId"` }
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) ExtractClusters ¶
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"` // Cluster alias Alias string `json:"alias"` }
Metadata required to create a cluster
type OperationResult ¶
func Operation ¶
func Operation(c *golangsdk.ServiceClient, id, action string) (r OperationResult)
type PackageConfiguration ¶
type PackageConfiguration struct { Name string `json:"name,omitempty"` Configurations []interface{} `json:"configurations,omitempty"` }
type ResizeExtendParam ¶
type ResizeOpts ¶
type ResizeOpts struct { FavorResize string `json:"flavorResize" required:"true"` ExtendParam *ResizeExtendParam `json:"extendParam,omitempty"` }
type ResizeResp ¶
func Resize ¶
func Resize(c *golangsdk.ServiceClient, id string, opts ResizeOpts) (ResizeResp, error)
type ServiceNetwork ¶
type ServiceNetwork struct {
IPv4Cidr string `json:"IPv4CIDR,omitempty"`
}
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"` // Enable Distributed Cluster Management EnableDistMgt bool `json:"enableDistMgt,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"` // Service network, use this to replace KubernetesSvcIPRange ServiceNetwork *ServiceNetwork `json:"serviceNetwork,omitempty"` //Custom san list for certificates CustomSan []string `json:"customSan,omitempty"` // Tags of cluster, key value pair format ClusterTags []tags.ResourceTag `json:"clusterTags,omitempty"` // configurationsOverride ConfigurationsOverride []PackageConfiguration `json:"configurationsOverride,omitempty"` // Whether to enable IPv6 IPv6Enable bool `json:"ipv6enable,omitempty"` // K8s proxy mode KubeProxyMode string `json:"kubeProxyMode,omitempty"` // Whether to enable Istio SupportIstio bool `json:"supportIstio,omitempty"` // The category, the value can be CCE and CCE Category string `json:"category,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 ¶
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 UpdateContainerNetworkSpec ¶
type UpdateContainerNetworkSpec struct { // List of container CIDR blocks. In clusters of v1.21 and later, the cidrs field is used. // When the cluster network type is vpc-router, you can add multiple container CIDR blocks. // In versions earlier than v1.21, if the cidrs field is used, the first CIDR element in the array is used as the container CIDR block. Cidrs []CidrSpec `json:"cidrs,omitempty"` }
type UpdateHostNetworkSpec ¶
type UpdateHostNetworkSpec struct { //The ID of the Security Group used to create the node SecurityGroup string `json:"SecurityGroup,omitempty"` }
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 UpdateIpResult ¶
UpdateIpResult represents the result of an update operation. Call its Extract method to interpret it as a Cluster.
func AddTags ¶
func AddTags(c *golangsdk.ServiceClient, id string, tagList []tags.ResourceTag) (r UpdateIpResult)
AddTags will add tags to the cluster.
func RemoveTags ¶
func RemoveTags(c *golangsdk.ServiceClient, id string, tagList []tags.ResourceTag) (r UpdateIpResult)
RemoveTags will remove tags from the cluster.
func UpdateMasterIp ¶
func UpdateMasterIp(c *golangsdk.ServiceClient, id string, opts UpdateIpOptsBuilder) (r UpdateIpResult)
Update the access information of a specified cluster.
type UpdateMetadata ¶
type UpdateMetadata struct { // Cluster alias Alias string `json:"alias"` }
type UpdateOpts ¶
type UpdateOpts struct { Spec UpdateSpec `json:"spec" required:"true"` Metadata *UpdateMetadata `json:"metadata,omitempty"` }
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 ¶
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 ¶
func Update(c *golangsdk.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult)
Update allows clusters to update description.
func (UpdateResult) ExtractClusters ¶
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"` // Custom san list for certificates CustomSan []string `json:"customSan,omitempty"` //Container network parameters ContainerNetwork *UpdateContainerNetworkSpec `json:"containerNetwork,omitempty"` // ENI network parameters EniNetwork *EniNetworkSpec `json:"eniNetwork,omitempty"` // Node network parameters HostNetwork *UpdateHostNetworkSpec `json:"hostNetwork,omitempty"` }
type UpdateTagsOpts ¶
type UpdateTagsOpts struct {
Tags []tags.ResourceTag `json:"tags" required:"true"`
}