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 DeleteWithOpts(c *golangsdk.ServiceClient, id string, opts DeleteOpts) error
- 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 Clusters
- type Conditions
- type ContainerNetworkSpec
- type CreateMetaData
- type CreateOpts
- type CreateOptsBuilder
- type CreateResult
- type DeleteOpts
- type DeleteResult
- type Endpoints
- type EniNetworkSpec
- type ExpirationOpts
- type ExpirationOptsBuilder
- type FilterStruct
- type GetCertResult
- type GetResult
- type HostNetworkSpec
- type IpSpec
- type ListCluster
- type ListOpts
- type ListResult
- type MetaData
- type Spec
- type Status
- type UpdateIpOpts
- type UpdateIpOptsBuilder
- type UpdateIpResult
- type UpdateOpts
- type UpdateOptsBuilder
- type UpdateResult
- type UpdateSpec
Constants ¶
This section is empty.
Variables ¶
var RequestOpts = golangsdk.RequestOpts{ MoreHeaders: map[string]string{"Content-Type": "application/json"}, }
Functions ¶
func DeleteWithOpts ¶ added in v0.8.0
func DeleteWithOpts(c *golangsdk.ServiceClient, id string, opts DeleteOpts) error
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 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"`
}
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 ¶
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 ¶ added in v0.8.0
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.
type Endpoints ¶
type Endpoints struct {
// The address accessed within the user's subnet - OpenTelekomCloud
Url string `json:"url"`
// Public network access address - OpenTelekomCloud
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 ¶ added in v0.5.9
type ExpirationOpts ¶ added in v0.5.8
type ExpirationOpts struct {
Duration int `json:"duration" required:"true"`
}
func (ExpirationOpts) ToExpirationGetMap ¶ added in v0.5.8
func (opts ExpirationOpts) ToExpirationGetMap() (map[string]interface{}, error)
type ExpirationOptsBuilder ¶ added in v0.5.8
type FilterStruct ¶
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 GetCertWithExpiration ¶ added in v0.5.8
func GetCertWithExpiration(c *golangsdk.ServiceClient, id string, opts ExpirationOptsBuilder) (r GetCertResult)
GetCertWithExpiration 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.
func (GetCertResult) ExtractMap ¶ added in v0.5.8
func (r GetCertResult) ExtractMap() (map[string]interface{}, error)
ExtractMap is a function that accepts a result and extracts a kubeconfig.
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 (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"`
}
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 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 Spec ¶
type Spec struct {
// Cluster category: CCE, Turbo
Category string `json:"category,omitempty"`
// Cluster Type: VirtualMachine, BareMetal, or Windows
Type string `json:"type" required:"true"`
// Cluster specifications
Flavor string `json:"flavor" required:"true"`
// Cluster's baseline Kubernetes version. The latest version is recommended
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]string `json:"extendParam,omitempty"`
// KubernetesSvcIpRange Service CIDR block or the IP address range which the kubernetes clusterIp must fall within.
// This parameter is available only for clusters of v1.11.7 and later.
KubernetesSvcIpRange string `json:"kubernetesSvcIpRange,omitempty"`
// KubeProxyMode Service forwarding mode. One of `iptables`, `ipvs`
KubeProxyMode string `json:"kubeProxyMode,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 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 ¶
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 ¶
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"`
}