Skip to main content

Update

Updates the specified node group.

import {
cloudApi,
decodeMessage,
serviceClients,
Session,
waitForOperation,
} from "@yandex-cloud/nodejs-sdk";

import { google } from "googleapis";

const ContainerRuntimeSettings_Type =
cloudApi.k8s.node.ContainerRuntimeSettings_Type;
const DayOfWeek = google.type.dayofweek.DayOfWeek;
const GpuSettings_GpuEnvironment = cloudApi.k8s.node.GpuSettings_GpuEnvironment;
const IpVersion = cloudApi.k8s.node.IpVersion;
const NetworkSettings_Type = cloudApi.k8s.node.NetworkSettings_Type;
const NodeGroup = cloudApi.k8s.node_group.NodeGroup;
const Taint_Effect = cloudApi.k8s.node.Taint_Effect;
const UpdateNodeGroupRequest =
cloudApi.k8s.node_group_service.UpdateNodeGroupRequest;

(async () => {
const authToken = process.env["YC_OAUTH_TOKEN"];
const session = new Session({ oauthToken: authToken });
const client = session.client(serviceClients.NodeGroupServiceClient);

const operation = await client.update(
UpdateNodeGroupRequest.fromPartial({
nodeGroupId: "nodeGroupId",
// updateMask: {
// paths: ["paths"]
// },
// name: "name",
// description: "description",
// labels: {"key": "labels"},
// nodeTemplate: {
// name: "name",
// labels: {"key": "labels"},
// platformId: "platformId",
// resourcesSpec: {
// memory: 0,
// cores: 0,
// coreFraction: 0,
// gpus: 0
// },
// bootDiskSpec: {
// diskTypeId: "diskTypeId",
// diskSize: 0
// },
// metadata: {"key": "metadata"},
// v4AddressSpec: {
// oneToOneNatSpec: {
// ipVersion: IpVersion.IPV4
// },
// dnsRecordSpecs: [{
// fqdn: "fqdn",
// dnsZoneId: "dnsZoneId",
// ttl: 0,
// ptr: true
// }]
// },
// schedulingPolicy: {
// preemptible: true
// },
// networkInterfaceSpecs: [{
// subnetIds: ["subnetIds"],
// primaryV4AddressSpec: {
// oneToOneNatSpec: {
// ipVersion: IpVersion.IPV4
// },
// dnsRecordSpecs: [{
// fqdn: "fqdn",
// dnsZoneId: "dnsZoneId",
// ttl: 0,
// ptr: true
// }]
// },
// primaryV6AddressSpec: {
// oneToOneNatSpec: {
// ipVersion: IpVersion.IPV4
// },
// dnsRecordSpecs: [{
// fqdn: "fqdn",
// dnsZoneId: "dnsZoneId",
// ttl: 0,
// ptr: true
// }]
// },
// securityGroupIds: ["securityGroupIds"]
// }],
// placementPolicy: {
// placementGroupId: "placementGroupId"
// },
// networkSettings: {
// type: NetworkSettings_Type.STANDARD
// },
// containerRuntimeSettings: {
// type: ContainerRuntimeSettings_Type.DOCKER
// },
// containerNetworkSettings: {
// podMtu: 0
// },
// gpuSettings: {
// gpuClusterId: "gpuClusterId",
// gpuEnvironment: GpuSettings_GpuEnvironment.RUNC_DRIVERS_CUDA
// }
// },
// scalePolicy: {
// fixedScale: {
// size: 0
// },
// autoScale: {
// minSize: 0,
// maxSize: 0,
// initialSize: 0
// }
// },
// allocationPolicy: {
// locations: [{
// zoneId: "zoneId",
// subnetId: "subnetId"
// }]
// },
// deployPolicy: {
// maxUnavailable: 0,
// maxExpansion: 0
// },
// version: {
// version: "version",
// latestRevision: true
// },
// maintenancePolicy: {
// autoUpgrade: true,
// autoRepair: true,
// maintenanceWindow: {
// anytime: {

// },
// dailyMaintenanceWindow: {
// startTime: {
// hours: 0,
// minutes: 0,
// seconds: 0,
// nanos: 0
// },
// duration: {
// seconds: 0,
// nanos: 0
// }
// },
// weeklyMaintenanceWindow: {
// daysOfWeek: [{
// days: [DayOfWeek.MONDAY],
// startTime: {
// hours: 0,
// minutes: 0,
// seconds: 0,
// nanos: 0
// },
// duration: {
// seconds: 0,
// nanos: 0
// }
// }]
// }
// }
// },
// allowedUnsafeSysctls: ["allowedUnsafeSysctls"],
// nodeTaints: [{
// key: "key",
// value: "value",
// effect: Taint_Effect.NO_SCHEDULE
// }],
// nodeLabels: {"key": "nodeLabels"}
})
);
const finishedOp = await waitForOperation(operation, session);

if (finishedOp.response) {
const result = decodeMessage<typeof NodeGroup>(finishedOp.response);
console.log(result);
}
})();

UpdateNodeGroupRequest

nodeGroupId : string

ID of the node group to update. To get the node group ID use a NodeGroupService.List request.

updateMask : google.protobuf.FieldMask

Field mask that specifies which fields of the node group are going to be updated.

name : string

Name of the node group. The name must be unique within the folder.

description : string

Description of the node group.

labels : string

Resource labels as key:value pairs.

Existing set of labels is completely replaced by the provided set.

nodeTemplate : NodeTemplate

Node template for the node group. Change may trigger nodes rolling reboot or recreate.

scalePolicy : ScalePolicy

Scale policy of the node group.

allocationPolicy : NodeGroupAllocationPolicy

Allocation policy of the node group by the zones and regions.

deployPolicy : DeployPolicy

Deploy policy according to which the updates are rolled out. If not specified, the default is used.

version : UpdateVersionSpec

Version of Kubernetes components that runs on the nodes.

maintenancePolicy : NodeGroupMaintenancePolicy

Maintenance policy of the node group.

allowedUnsafeSysctls : string

Support for unsafe sysctl parameters. For more details see documentation.

nodeTaints : Taint

Taints that are applied to the nodes of the node group at creation time.

nodeLabels : string

Labels that are assigned to the nodes of the node group at creation time.

NodeTemplate

NetworkSettings
Type
  • TYPE_UNSPECIFIED

  • STANDARD

  • SOFTWARE_ACCELERATED

type : Type
ContainerRuntimeSettings
Type
  • TYPE_UNSPECIFIED

  • DOCKER

  • CONTAINERD

type : Type
ContainerNetworkSettings
podMtu : int64
name : string

Name of the instance. In order to be unique it must contain at least on of instance unique placeholders: {instance.short_id} {instance.index} combination of {instance.zone_id} and {instance.index_in_zone} Example: my-instance-{instance.index} If not set, default is used: {instance_group.id}-{instance.short_id} It may also contain another placeholders, see metadata doc for full list.

labels : string

these labels will be assigned to compute nodes (instances), created by the nodegroup

platformId : string

ID of the hardware platform configuration for the node.

resourcesSpec : ResourcesSpec

Computing resources of the node such as the amount of memory and number of cores.

bootDiskSpec : DiskSpec

Specification for the boot disk that will be attached to the node.

metadata : string

The metadata as key:value pairs assigned to this instance template. Only SSH keys are supported as metadata.

For more information, see Connecting to a node over SSH.

v4AddressSpec : NodeAddressSpec

Specification for the create network interfaces for the node group compute instances. Deprecated, please use network_interface_specs.

schedulingPolicy : SchedulingPolicy

Scheduling policy configuration.

networkInterfaceSpecs : NetworkInterfaceSpec

New api, to specify network interfaces for the node group compute instances. Can not be used together with 'v4_address_spec'

placementPolicy : PlacementPolicy
networkSettings : NetworkSettings

this parameter allows to specify type of network acceleration used on nodes (instances)

containerRuntimeSettings : ContainerRuntimeSettings
containerNetworkSettings : ContainerNetworkSettings
gpuSettings : GpuSettings

GPU settings

ScalePolicy

FixedScale
size : int64

Number of nodes in the node group.

AutoScale
minSize : int64

Minimum number of nodes in the node group.

maxSize : int64

Maximum number of nodes in the node group.

initialSize : int64

Initial number of nodes in the node group.

One of scaleType

  • fixedScale : FixedScale

    Fixed scale policy of the node group.

  • autoScale : AutoScale

    Auto scale policy of the node group.

NodeGroupAllocationPolicy

locations : NodeGroupLocation

List of locations where resources for the node group will be allocated.

DeployPolicy

maxUnavailable : int64

The maximum number of running instances that can be taken offline (i.e., stopped or deleted) at the same time during the update process. If max_expansion is not specified or set to zero, max_unavailable must be set to a non-zero value.

maxExpansion : int64

The maximum number of instances that can be temporarily allocated above the group's target size during the update process. If max_unavailable is not specified or set to zero, max_expansion must be set to a non-zero value.

UpdateVersionSpec

One of specifier

  • version : string

    Request update to a newer version of Kubernetes (1.x -> 1.y).

  • latestRevision : bool

    Request update to the latest revision for the current version.

NodeGroupMaintenancePolicy

autoUpgrade : bool

If set to true, automatic updates are installed in the specified period of time with no interaction from the user. If set to false, automatic upgrades are disabled.

autoRepair : bool

If set to true, automatic repairs are enabled. Default value is false.

maintenanceWindow : MaintenanceWindow

Maintenance window settings. Update will start at the specified time and last no more than the specified duration. The time is set in UTC.

Taint

Effect
  • EFFECT_UNSPECIFIED

  • NO_SCHEDULE

    Do not allow new pods to schedule onto the node unless they tolerate the taint, but allow all pods submitted to Kubelet without going through the scheduler to start, and allow all already-running pods to continue running.

  • PREFER_NO_SCHEDULE

    Like NO_SCHEDULE, but the scheduler tries not to schedule new pods onto the node, rather than prohibiting new pods from scheduling onto the node entirely. Enforced by the scheduler.

  • NO_EXECUTE

    Evict any already-running pods that do not tolerate the taint.

key : string

The taint key to be applied to a node.

value : string

The taint value corresponding to the taint key.

effect : Effect

The effect of the taint on pods that do not tolerate the taint.

ResourcesSpec

memory : int64

Amount of memory available to the node, specified in bytes.

cores : int64

Number of cores available to the node.

coreFraction : int64

Baseline level of CPU performance with the possibility to burst performance above that baseline level. This field sets baseline performance for each core.

gpus : int64

Number of GPUs available to the node.

DiskSpec

diskTypeId : string

ID of the disk type.

diskSize : int64

Size of the disk, specified in bytes.

NodeAddressSpec

oneToOneNatSpec : OneToOneNatSpec

One-to-one NAT configuration. Setting up one-to-one NAT ensures that public IP addresses are assigned to nodes, and therefore internet is accessible for all nodes of the node group. If the field is not set, NAT will not be set up.

dnsRecordSpecs : DnsRecordSpec

Internal DNS configuration.

SchedulingPolicy

preemptible : bool

True for preemptible compute instances. Default value is false. Preemptible compute instances are stopped at least once every 24 hours, and can be stopped at any time if their resources are needed by Compute. For more information, see Preemptible Virtual Machines.

NetworkInterfaceSpec

subnetIds : string

IDs of the subnets.

primaryV4AddressSpec : NodeAddressSpec

Primary IPv4 address that is assigned to the instance for this network interface.

primaryV6AddressSpec : NodeAddressSpec

Primary IPv6 address that is assigned to the instance for this network interface.

securityGroupIds : string

IDs of security groups.

PlacementPolicy

placementGroupId : string

Identifier of placement group

NetworkSettings

Type
  • TYPE_UNSPECIFIED

  • STANDARD

  • SOFTWARE_ACCELERATED

type : Type

ContainerRuntimeSettings

Type
  • TYPE_UNSPECIFIED

  • DOCKER

  • CONTAINERD

type : Type

ContainerNetworkSettings

podMtu : int64

GpuSettings

GpuEnvironment
  • GPU_ENVIRONMENT_UNSPECIFIED

    Use one of the values below, depending on the default for the specific Cloud installation.

  • RUNC_DRIVERS_CUDA

    Use a node image with the pre-installed GPU toolkit, drivers and CUDA.

  • RUNC

    Use a node image with the pre-installed GPU toolkit but without drivers. You should install drivers on a node yourself in that case. There are tools to help you to do that, for example gpu-operator.

gpuClusterId : string

GPU cluster id, that mk8s node will join.

gpuEnvironment : GpuEnvironment

GPU environment configured on node.

FixedScale

size : int64

Number of nodes in the node group.

AutoScale

minSize : int64

Minimum number of nodes in the node group.

maxSize : int64

Maximum number of nodes in the node group.

initialSize : int64

Initial number of nodes in the node group.

NodeGroupLocation

zoneId : string

ID of the availability zone where the nodes may reside.

subnetId : string

ID of the subnet. If a network chosen for the Kubernetes cluster has only one subnet in the specified zone, subnet ID may be omitted.

MaintenanceWindow

One of policy

Maintenance policy.

  • anytime : AnytimeMaintenanceWindow

    Updating the master at any time.

  • dailyMaintenanceWindow : DailyMaintenanceWindow

    Updating the master on any day during the specified time window.

  • weeklyMaintenanceWindow : WeeklyMaintenanceWindow

    Updating the master on selected days during the specified time window.

OneToOneNatSpec

ipVersion : IpVersion

IP version for the public IP address.

DnsRecordSpec

fqdn : string

FQDN (required).

dnsZoneId : string

DNS zone id (optional, if not set, private zone is used).

ttl : int64

DNS record ttl, values in 0-86400 (optional).

ptr : bool

When set to true, also create PTR DNS record (optional).

AnytimeMaintenanceWindow

DailyMaintenanceWindow

startTime : google.type.TimeOfDay

Window start time, in the UTC timezone.

duration : google.protobuf.Duration

Window duration.

WeeklyMaintenanceWindow

daysOfWeek : DaysOfWeekMaintenanceWindow

Days of the week and the maintenance window for these days when automatic updates are allowed.

DaysOfWeekMaintenanceWindow

days : google.type.DayOfWeek

Days of the week when automatic updates are allowed.

startTime : google.type.TimeOfDay

Window start time, in the UTC timezone.

duration : google.protobuf.Duration

Window duration.

Operation

An Operation resource. For more information, see Operation.

id : string

ID of the operation.

description : string

Description of the operation. 0-256 characters long.

createdAt : google.protobuf.Timestamp

Creation timestamp.

createdBy : string

ID of the user or service account who initiated the operation.

modifiedAt : google.protobuf.Timestamp

The time when the Operation resource was last modified.

done : bool

If the value is false, it means the operation is still in progress. If true, the operation is completed, and either error or response is available.

metadata : google.protobuf.Any

Service-specific metadata associated with the operation. It typically contains the ID of the target resource that the operation is performed on. Any method that returns a long-running operation should document the metadata type, if any.

One of result

The operation result. If done == false and there was no failure detected, neither error nor response is set. If done == false and there was a failure detected, error is set. If done == true, exactly one of error or response is set.

  • error : google.rpc.Status

    The error result of the operation in case of failure or cancellation.

  • response : google.protobuf.Any
    The normal response of the operation in case of success.

    If the original method returns no data on success, such as Delete, the response is google.protobuf.Empty. If the original method is the standard Create/Update, the response should be the target resource of the operation. Any method that returns a long-running operation should document the response type, if any.