Documentation ¶
Overview ¶
Package clusters contains functionality for working with Magnum Cluster resources.
Example to Create a Cluster
masterCount := 1 nodeCount := 1 createTimeout := 30 opts := clusters.CreateOpts{ ClusterTemplateID: "0562d357-8641-4759-8fed-8173f02c9633", CreateTimeout: &createTimeout, DiscoveryURL: "", FlavorID: "m1.small", KeyPair: "my_keypair", Labels: map[string]string{}, MasterCount: &masterCount, MasterFlavorID: "m1.small", Name: "k8s", NodeCount: &nodeCount, } cluster, err := clusters.Create(serviceClient, createOpts).Extract() if err != nil { panic(err) }
Example to Get a Cluster
clusterName := "cluster123" cluster, err := clusters.Get(serviceClient, clusterName).Extract() if err != nil { panic(err) } fmt.Printf("%+v\n", cluster)
Example to List Clusters
listOpts := clusters.ListOpts{ Limit: 20, } allPages, err := clusters.List(serviceClient, listOpts).AllPages() if err != nil { panic(err) } allClusters, err := clusters.ExtractClusters(allPages) if err != nil { panic(err) } for _, cluster := range allClusters { fmt.Printf("%+v\n", cluster) }
Example to List Clusters with detailed information
allPagesDetail, err := clusters.ListDetail(serviceClient, clusters.ListOpts{}).AllPages() if err != nil { panic(err) } allClustersDetail, err := clusters.ExtractClusters(allPagesDetail) if err != nil { panic(err) } for _, clusterDetail := range allClustersDetail { fmt.Printf("%+v\n", clusterDetail) }
Example to Update a Cluster
updateOpts := []clusters.UpdateOptsBuilder{ clusters.UpdateOpts{ Op: clusters.ReplaceOp, Path: "/master_lb_enabled", Value: "True", }, clusters.UpdateOpts{ Op: clusters.ReplaceOp, Path: "/registry_enabled", Value: "True", }, } clusterUUID, err := clusters.Update(serviceClient, clusterUUID, updateOpts).Extract() if err != nil { panic(err) } fmt.Printf("%s\n", clusterUUID)
Example to Upgrade a Cluster
upgradeOpts := clusters.UpgradeOpts{ ClusterTemplate: "0562d357-8641-4759-8fed-8173f02c9633", } clusterUUID, err := clusters.Upgrade(serviceClient, clusterUUID, upgradeOpts).Extract() if err != nil { panic(err) } fmt.Printf("%s\n", clusterUUID)
Example to Delete a Cluster
clusterUUID := "dc6d336e3fc4c0a951b5698cd1236ee" err := clusters.Delete(serviceClient, clusterUUID).ExtractErr() if err != nil { panic(err) }
Index ¶
- func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
- func ListDetail(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
- type Cluster
- type ClusterPage
- type CreateOpts
- type CreateOptsBuilder
- type CreateResult
- type DeleteResult
- type GetResult
- type ListOpts
- type ListOptsBuilder
- type ResizeOpts
- type ResizeOptsBuilder
- type ResizeResult
- type UpdateOp
- type UpdateOpts
- type UpdateOptsBuilder
- type UpdateResult
- type UpgradeOpts
- type UpgradeOptsBuilder
- type UpgradeResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func List ¶
func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
List returns a Pager which allows you to iterate over a collection of clusters. It accepts a ListOptsBuilder, which allows you to sort the returned collection for greater efficiency.
func ListDetail ¶
func ListDetail(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
ListDetail returns a Pager which allows you to iterate over a collection of clusters with detailed information. It accepts a ListOptsBuilder, which allows you to sort the returned collection for greater efficiency.
Types ¶
type Cluster ¶
type Cluster struct { APIAddress string `json:"api_address"` COEVersion string `json:"coe_version"` ClusterTemplateID string `json:"cluster_template_id"` ContainerVersion string `json:"container_version"` CreateTimeout int `json:"create_timeout"` CreatedAt time.Time `json:"created_at"` DiscoveryURL string `json:"discovery_url"` DockerVolumeSize int `json:"docker_volume_size"` Faults map[string]string `json:"faults"` FlavorID string `json:"flavor_id"` KeyPair string `json:"keypair"` Labels map[string]string `json:"labels"` Links []gophercloud.Link `json:"links"` MasterFlavorID string `json:"master_flavor_id"` MasterAddresses []string `json:"master_addresses"` MasterCount int `json:"master_count"` Name string `json:"name"` NodeAddresses []string `json:"node_addresses"` NodeCount int `json:"node_count"` ProjectID string `json:"project_id"` StackID string `json:"stack_id"` Status string `json:"status"` StatusReason string `json:"status_reason"` UUID string `json:"uuid"` UpdatedAt time.Time `json:"updated_at"` UserID string `json:"user_id"` FloatingIPEnabled bool `json:"floating_ip_enabled"` FixedNetwork string `json:"fixed_network"` FixedSubnet string `json:"fixed_subnet"` HealthStatus string `json:"health_status"` HealthStatusReason map[string]interface{} `json:"health_status_reason"` }
func ExtractClusters ¶
func ExtractClusters(r pagination.Page) ([]Cluster, error)
type ClusterPage ¶
type ClusterPage struct {
pagination.LinkedPageBase
}
func (ClusterPage) IsEmpty ¶
func (r ClusterPage) IsEmpty() (bool, error)
IsEmpty checks whether a ClusterPage struct is empty.
func (ClusterPage) NextPageURL ¶
func (r ClusterPage) NextPageURL() (string, error)
type CreateOpts ¶
type CreateOpts struct { ClusterTemplateID string `json:"cluster_template_id" required:"true"` CreateTimeout *int `json:"create_timeout"` DiscoveryURL string `json:"discovery_url,omitempty"` DockerVolumeSize *int `json:"docker_volume_size,omitempty"` FlavorID string `json:"flavor_id,omitempty"` Keypair string `json:"keypair,omitempty"` Labels map[string]string `json:"labels,omitempty"` MasterCount *int `json:"master_count,omitempty"` MasterFlavorID string `json:"master_flavor_id,omitempty"` Name string `json:"name"` NodeCount *int `json:"node_count,omitempty"` FloatingIPEnabled *bool `json:"floating_ip_enabled,omitempty"` FixedNetwork string `json:"fixed_network,omitempty"` FixedSubnet string `json:"fixed_subnet,omitempty"` MergeLabels *bool `json:"merge_labels,omitempty"` }
CreateOpts params
func (CreateOpts) ToClusterCreateMap ¶
func (opts CreateOpts) ToClusterCreateMap() (map[string]interface{}, error)
ToClusterCreateMap constructs a request body from CreateOpts.
type CreateOptsBuilder ¶
CreateOptsBuilder Builder.
type CreateResult ¶
type CreateResult struct {
// contains filtered or unexported fields
}
CreateResult is the response of a Create operations.
func Create ¶
func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)
Create requests the creation of a new cluster.
func (CreateResult) Extract ¶
func (r CreateResult) Extract() (string, error)
type DeleteResult ¶
type DeleteResult struct {
gophercloud.ErrResult
}
DeleteResult is the result from a Delete operation. Call its Extract or ExtractErr method to determine if the call succeeded or failed.
func Delete ¶
func Delete(client *gophercloud.ServiceClient, id string) (r DeleteResult)
Delete deletes the specified cluster ID.
type GetResult ¶
type GetResult struct {
// contains filtered or unexported fields
}
GetResult represents the result of a get operation.
func Get ¶
func Get(client *gophercloud.ServiceClient, id string) (r GetResult)
Get retrieves a specific clusters based on its unique ID.
type ListOpts ¶
type ListOpts struct { Marker string `q:"marker"` Limit int `q:"limit"` SortKey string `q:"sort_key"` SortDir string `q:"sort_dir"` }
ListOpts allows the sorting of paginated collections through the API. SortKey allows you to sort by a particular cluster attribute. SortDir sets the direction, and is either `asc' or `desc'. Marker and Limit are used for pagination.
func (ListOpts) ToClustersListQuery ¶
ToClustersListQuery formats a ListOpts into a query string.
type ListOptsBuilder ¶
ListOptsBuilder allows extensions to add additional parameters to the List request.
type ResizeOpts ¶
type ResizeOpts struct { NodeCount *int `json:"node_count" required:"true"` NodesToRemove []string `json:"nodes_to_remove,omitempty"` NodeGroup string `json:"nodegroup,omitempty"` }
ResizeOpts params
func (ResizeOpts) ToClusterResizeMap ¶
func (opts ResizeOpts) ToClusterResizeMap() (map[string]interface{}, error)
ToClusterResizeMap constructs a request body from ResizeOpts.
type ResizeOptsBuilder ¶
ResizeOptsBuilder allows extensions to add additional parameters to the Resize request.
type ResizeResult ¶
type ResizeResult struct {
// contains filtered or unexported fields
}
ResizeResult is the response of a Resize operations.
func Resize ¶
func Resize(client *gophercloud.ServiceClient, id string, opts ResizeOptsBuilder) (r ResizeResult)
Resize an existing cluster node count.
func (ResizeResult) Extract ¶
func (r ResizeResult) Extract() (string, error)
type UpdateOpts ¶
type UpdateOpts struct { Op UpdateOp `json:"op" required:"true"` Path string `json:"path" required:"true"` Value interface{} `json:"value,omitempty"` }
func (UpdateOpts) ToClustersUpdateMap ¶
func (opts UpdateOpts) ToClustersUpdateMap() (map[string]interface{}, error)
ToClusterUpdateMap assembles a request body based on the contents of 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 is the response of a Update operations.
func Update ¶
func Update(client *gophercloud.ServiceClient, id string, opts []UpdateOptsBuilder) (r UpdateResult)
Update implements cluster updated request.
func (UpdateResult) Extract ¶
func (r UpdateResult) Extract() (string, error)
type UpgradeOpts ¶
type UpgradeOpts struct { ClusterTemplate string `json:"cluster_template" required:"true"` MaxBatchSize *int `json:"max_batch_size,omitempty"` NodeGroup string `json:"nodegroup,omitempty"` }
func (UpgradeOpts) ToClustersUpgradeMap ¶
func (opts UpgradeOpts) ToClustersUpgradeMap() (map[string]interface{}, error)
ToClustersUpgradeMap constructs a request body from UpgradeOpts.
type UpgradeOptsBuilder ¶
UpgradeOptsBuilder allows extensions to add additional parameters to the Upgrade request.
type UpgradeResult ¶
type UpgradeResult struct {
// contains filtered or unexported fields
}
UpgradeResult is the response of a Upgrade operations.
func Upgrade ¶
func Upgrade(client *gophercloud.ServiceClient, id string, opts UpgradeOptsBuilder) (r UpgradeResult)
Upgrade implements cluster upgrade request.
func (UpgradeResult) Extract ¶
func (r UpgradeResult) Extract() (string, error)