Skip to content

Commit

Permalink
feat(k8s): expose MigrateClusterToSBSCSI (#2199)
Browse files Browse the repository at this point in the history
  • Loading branch information
scaleway-bot authored Sep 9, 2024
1 parent ffad205 commit f0b2e3a
Showing 1 changed file with 45 additions and 0 deletions.
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

0 comments on commit f0b2e3a

Please sign in to comment.