Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions api/k8s/v1/k8s_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -1827,6 +1827,15 @@ type MigrateClusterToRoutedIPsRequest struct {
ClusterID string `json:"-"`
}

// MigrateClusterToSBSCSIRequest: migrate cluster to sbscsi request.
type MigrateClusterToSBSCSIRequest struct {
// Region: region to target. If none is passed will use default region from the config.
Region scw.Region `json:"-"`

// ClusterID: cluster ID for which the latest CSI compatible with Scaleway Block Storage will be enabled.
ClusterID string `json:"-"`
}

// NodeMetadata: node metadata.
type NodeMetadata struct {
ID string `json:"id"`
Expand Down Expand Up @@ -2440,6 +2449,42 @@ func (s *API) MigrateClusterToRoutedIPs(req *MigrateClusterToRoutedIPsRequest, o
return &resp, nil
}

// MigrateClusterToSBSCSI: Enable the latest CSI compatible with Scaleway Block Storage (SBS) and migrate all existing PersistentVolumes/VolumeSnapshotContents to SBS.
func (s *API) MigrateClusterToSBSCSI(req *MigrateClusterToSBSCSIRequest, opts ...scw.RequestOption) (*Cluster, error) {
var err error

if req.Region == "" {
defaultRegion, _ := s.client.GetDefaultRegion()
req.Region = defaultRegion
}

if fmt.Sprint(req.Region) == "" {
return nil, errors.New("field Region cannot be empty in request")
}

if fmt.Sprint(req.ClusterID) == "" {
return nil, errors.New("field ClusterID cannot be empty in request")
}

scwReq := &scw.ScalewayRequest{
Method: "POST",
Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/clusters/" + fmt.Sprint(req.ClusterID) + "/migrate-to-sbs-csi",
}

err = scwReq.SetBody(req)
if err != nil {
return nil, err
}

var resp Cluster

err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}

// ListPools: List all the existing pools for a specific Kubernetes cluster.
func (s *API) ListPools(req *ListPoolsRequest, opts ...scw.RequestOption) (*ListPoolsResponse, error) {
var err error
Expand Down