Skip to content

Commit e4e1b61

Browse files
feat(k8s): add MigratePoolsToNewImages handler (#2139)
Co-authored-by: Laure-di <[email protected]>
1 parent 362b5b3 commit e4e1b61

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

packages_generated/k8s/src/v1/api.gen.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
marshalAddClusterACLRulesRequest,
1818
marshalCreateClusterRequest,
1919
marshalCreatePoolRequest,
20+
marshalMigratePoolsToNewImagesRequest,
2021
marshalSetClusterACLRulesRequest,
2122
marshalSetClusterTypeRequest,
2223
marshalUpdateClusterRequest,
@@ -77,6 +78,7 @@ import type {
7778
ListPoolsResponse,
7879
ListVersionsRequest,
7980
ListVersionsResponse,
81+
MigratePoolsToNewImagesRequest,
8082
Node,
8183
NodeMetadata,
8284
Pool,
@@ -545,6 +547,23 @@ This will drain and replace the nodes in that pool.
545547
unmarshalPool,
546548
)
547549

550+
/**
551+
* Migrate specific pools or all pools of a cluster to new images.. If no pool is specified, all pools of the cluster will be migrated to new images.
552+
*
553+
* @param request - The request {@link MigratePoolsToNewImagesRequest}
554+
*/
555+
migratePoolsToNewImages = (
556+
request: Readonly<MigratePoolsToNewImagesRequest>,
557+
) =>
558+
this.client.fetch<void>({
559+
body: JSON.stringify(
560+
marshalMigratePoolsToNewImagesRequest(request, this.client.settings),
561+
),
562+
headers: jsonContentHeaders,
563+
method: 'POST',
564+
path: `/k8s/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/clusters/${validatePathParam('clusterId', request.clusterId)}/migrate-pools-to-new-images`,
565+
})
566+
548567
/**
549568
* Fetch node metadata. 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.
550569
*

packages_generated/k8s/src/v1/index.gen.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export type {
6363
ListVersionsResponse,
6464
MaintenanceWindow,
6565
MaintenanceWindowDayOfTheWeek,
66+
MigratePoolsToNewImagesRequest,
6667
Node,
6768
NodeMetadata,
6869
NodeMetadataCoreV1Taint,

packages_generated/k8s/src/v1/marshalling.gen.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import type {
3838
ListPoolsResponse,
3939
ListVersionsResponse,
4040
MaintenanceWindow,
41+
MigratePoolsToNewImagesRequest,
4142
Node,
4243
NodeMetadata,
4344
NodeMetadataCoreV1Taint,
@@ -88,6 +89,7 @@ export const unmarshalPool = (data: unknown): Pool => {
8889
maxSize: data.max_size,
8990
minSize: data.min_size,
9091
name: data.name,
92+
newImagesEnabled: data.new_images_enabled,
9193
nodeType: data.node_type,
9294
placementGroupId: data.placement_group_id,
9395
publicIpDisabled: data.public_ip_disabled,
@@ -223,6 +225,7 @@ export const unmarshalCluster = (data: unknown): Cluster => {
223225
iamNodesGroupId: data.iam_nodes_group_id,
224226
id: data.id,
225227
name: data.name,
228+
newImagesEnabled: data.new_images_enabled,
226229
openIdConnectConfig: data.open_id_connect_config
227230
? unmarshalClusterOpenIDConnectConfig(data.open_id_connect_config)
228231
: undefined,
@@ -741,6 +744,13 @@ export const marshalCreatePoolRequest = (
741744
zone: request.zone ?? defaults.defaultZone,
742745
})
743746

747+
export const marshalMigratePoolsToNewImagesRequest = (
748+
request: MigratePoolsToNewImagesRequest,
749+
defaults: DefaultValues,
750+
): Record<string, unknown> => ({
751+
pool_ids: request.poolIds,
752+
})
753+
744754
export const marshalSetClusterACLRulesRequest = (
745755
request: SetClusterACLRulesRequest,
746756
defaults: DefaultValues,

packages_generated/k8s/src/v1/types.gen.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,10 @@ export interface Pool {
321321
* 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.
322322
*/
323323
publicIpDisabled: boolean
324+
/**
325+
* @deprecated Defines whether the pool is migrated to new images.
326+
*/
327+
newImagesEnabled?: boolean
324328
/**
325329
* Cluster region of the pool.
326330
*/
@@ -718,6 +722,10 @@ export interface Cluster {
718722
* IAM group that nodes are members of (this field might be empty during early stage of cluster creation).
719723
*/
720724
iamNodesGroupId: string
725+
/**
726+
* @deprecated Defines whether all pools are migrated to new images.
727+
*/
728+
newImagesEnabled?: boolean
721729
}
722730

723731
export interface Node {
@@ -1461,6 +1469,15 @@ export interface ListVersionsResponse {
14611469
versions: Version[]
14621470
}
14631471

1472+
export type MigratePoolsToNewImagesRequest = {
1473+
/**
1474+
* Region to target. If none is passed will use default region from the config.
1475+
*/
1476+
region?: ScwRegion
1477+
clusterId: string
1478+
poolIds?: string[]
1479+
}
1480+
14641481
export interface NodeMetadata {
14651482
id: string
14661483
name: string

0 commit comments

Comments
 (0)