Skip to content

Commit 0b3b72a

Browse files
feat(k8s): add MigratePoolsToNewImages handler (scaleway#2559)
Co-authored-by: Laure-di <[email protected]>
1 parent f551ea5 commit 0b3b72a

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

api/k8s/v1/k8s_sdk.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,9 @@ type Pool struct {
891891
// PublicIPDisabled: defines if the public IP should be removed from Nodes. To use this feature, your Cluster must have an attached Private Network set up with a Public Gateway.
892892
PublicIPDisabled bool `json:"public_ip_disabled"`
893893

894+
// Deprecated: NewImagesEnabled: defines whether the pool is migrated to new images.
895+
NewImagesEnabled *bool `json:"new_images_enabled,omitempty"`
896+
894897
// Region: cluster region of the pool.
895898
Region scw.Region `json:"region"`
896899
}
@@ -1209,6 +1212,9 @@ type Cluster struct {
12091212

12101213
// IamNodesGroupID: iAM group that nodes are members of (this field might be empty during early stage of cluster creation).
12111214
IamNodesGroupID string `json:"iam_nodes_group_id"`
1215+
1216+
// Deprecated: NewImagesEnabled: defines whether all pools are migrated to new images.
1217+
NewImagesEnabled *bool `json:"new_images_enabled,omitempty"`
12121218
}
12131219

12141220
// Node: node.
@@ -1950,6 +1956,16 @@ type ListVersionsResponse struct {
19501956
Versions []*Version `json:"versions"`
19511957
}
19521958

1959+
// MigratePoolsToNewImagesRequest: migrate pools to new images request.
1960+
type MigratePoolsToNewImagesRequest struct {
1961+
// Region: region to target. If none is passed will use default region from the config.
1962+
Region scw.Region `json:"-"`
1963+
1964+
ClusterID string `json:"-"`
1965+
1966+
PoolIDs []string `json:"pool_ids"`
1967+
}
1968+
19531969
// NodeMetadata: node metadata.
19541970
type NodeMetadata struct {
19551971
ID string `json:"id"`
@@ -2908,6 +2924,40 @@ func (s *API) DeletePool(req *DeletePoolRequest, opts ...scw.RequestOption) (*Po
29082924
return &resp, nil
29092925
}
29102926

2927+
// MigratePoolsToNewImages: If no pool is specified, all pools of the cluster will be migrated to new images.
2928+
func (s *API) MigratePoolsToNewImages(req *MigratePoolsToNewImagesRequest, opts ...scw.RequestOption) error {
2929+
var err error
2930+
2931+
if req.Region == "" {
2932+
defaultRegion, _ := s.client.GetDefaultRegion()
2933+
req.Region = defaultRegion
2934+
}
2935+
2936+
if fmt.Sprint(req.Region) == "" {
2937+
return errors.New("field Region cannot be empty in request")
2938+
}
2939+
2940+
if fmt.Sprint(req.ClusterID) == "" {
2941+
return errors.New("field ClusterID cannot be empty in request")
2942+
}
2943+
2944+
scwReq := &scw.ScalewayRequest{
2945+
Method: "POST",
2946+
Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/clusters/" + fmt.Sprint(req.ClusterID) + "/migrate-pools-to-new-images",
2947+
}
2948+
2949+
err = scwReq.SetBody(req)
2950+
if err != nil {
2951+
return err
2952+
}
2953+
2954+
err = s.client.Do(scwReq, nil, opts...)
2955+
if err != nil {
2956+
return err
2957+
}
2958+
return nil
2959+
}
2960+
29112961
// GetNodeMetadata: Rerieve metadata to instantiate a Kapsule/Kosmos node. This method is not intended to be called by end users but rather programmatically by the node-installer.
29122962
func (s *API) GetNodeMetadata(req *GetNodeMetadataRequest, opts ...scw.RequestOption) (*NodeMetadata, error) {
29132963
var err error

0 commit comments

Comments
 (0)