Skip to main content

Create

Creates a Kubernetes cluster in the specified folder.

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

const Cluster = cloudApi.dataproc.cluster.Cluster;
const CreateClusterRequest =
cloudApi.dataproc.cluster_service.CreateClusterRequest;
const HadoopConfig_Service = cloudApi.dataproc.cluster.HadoopConfig_Service;
const Role = cloudApi.dataproc.subcluster.Role;

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

const operation = await client.create(
CreateClusterRequest.fromPartial({
folderId: "folderId",
// name: "name",
// description: "description",
// labels: {"key": "labels"},
configSpec: {
// versionId: "versionId",
// hadoop: {
// services: [HadoopConfig_Service.HDFS],
// properties: {"key": "properties"},
// sshPublicKeys: ["sshPublicKeys"],
// initializationActions: [{
// uri: "uri",
// args: ["args"],
// timeout: 0
// }]
// },
// subclustersSpec: [{
// name: "name",
// role: Role.MASTERNODE,
// resources: {
// resourcePresetId: "resourcePresetId",
// diskTypeId: "diskTypeId",
// diskSize: 0
// },
// subnetId: "subnetId",
// hostsCount: 0,
// assignPublicIp: true,
// autoscalingConfig: {
// maxHostsCount: 0,
// preemptible: true,
// measurementDuration: {
// seconds: 0,
// nanos: 0
// },
// warmupDuration: {
// seconds: 0,
// nanos: 0
// },
// stabilizationDuration: {
// seconds: 0,
// nanos: 0
// },
// cpuUtilizationTarget: 0,
// decommissionTimeout: 0
// }
// }]
},
zoneId: "zoneId",
serviceAccountId: "serviceAccountId",
// bucket: "bucket",
// uiProxy: true,
// securityGroupIds: ["securityGroupIds"],
// hostGroupIds: ["hostGroupIds"],
// deletionProtection: true,
// logGroupId: "logGroupId"
})
);
const finishedOp = await waitForOperation(operation, session);

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

CreateClusterRequest

folderId : string

ID of the folder to create a Kubernetes cluster in. To get the folder ID use a yandex.cloud.resourcemanager.v1.FolderService.List request.

name : string

Name of the Kubernetes cluster. The name must be unique within the folder.

description : string

Description of the Kubernetes cluster.

labels : string

Resource labels as key:value pairs.

networkId : string

ID of the network.

masterSpec : MasterSpec

Master specification of the Kubernetes cluster.

ipAllocationPolicy : IPAllocationPolicy

IP allocation policy of the Kubernetes cluster.

One of internetGateway

  • gatewayIpv4Address : string

    Gateway IPv4 address.

serviceAccountId : string

Service account to be used for provisioning Compute Cloud and VPC resources for Kubernetes cluster. Selected service account should have edit role on the folder where the Kubernetes cluster will be located and on the folder where selected network resides.

nodeServiceAccountId : string

Service account to be used by the worker nodes of the Kubernetes cluster to access Container Registry or to push node logs and metrics.

releaseChannel : ReleaseChannel

Release channel for the master.

networkPolicy : NetworkPolicy
kmsProvider : KMSProvider

KMS provider configuration.

One of networkImplementation

  • cilium : Cilium

MasterSpec

One of masterType

  • zonalMasterSpec : ZonalMasterSpec

    Specification of the zonal master.

  • regionalMasterSpec : RegionalMasterSpec

    Specification of the regional master.

locations : LocationSpec

Locations specification for Kubernetes control-plane (master) instances. Works in conjunction with etcd_cluster_size. See it's documentation for details. Possible combinations:

  • 1 location and etcd_cluster_size = 1 - a single node cluster whose availability is limited by the availability of a single Compute Instance; downtime is expected during cluster updates.
  • 1 location and etcd_cluster_size = 3 - a highly available cluster within a single availability zone; can survive the failure of a Compute Instance, a server, or an individual server rack.
  • 3 location and etcd_cluster_size = 3 - a highly available cluster with each etcd instance located within separate availability zone; can survive the failure of a single availability zone.
etcdClusterSize : int64

Number of etcd nodes in cluster. Works in conjunction with locations. See it's documentation for details. Optional. If not set, will be assumed equal to the number of locations.

externalV4AddressSpec : ExternalAddressSpec

Specification of parameters for external IPv4 networking.

externalV6AddressSpec : ExternalAddressSpec

Specification of parameters for external IPv6 networking.

version : string

Version of Kubernetes components that runs on the master.

maintenancePolicy : MasterMaintenancePolicy

Maintenance policy of the master.

securityGroupIds : string

Master security groups.

masterLogging : MasterLogging

Cloud Logging for master components.

IPAllocationPolicy

clusterIpv4CidrBlock : string

CIDR block. IP range for allocating pod addresses.

It should not overlap with any subnet in the network the Kubernetes cluster located in. Static routes will be set up for this CIDR blocks in node subnets.

nodeIpv4CidrMaskSize : int64

Size of the masks that are assigned for each node in the cluster.

If not specified, 24 is used.

serviceIpv4CidrBlock : string

CIDR block. IP range Kubernetes service Kubernetes cluster IP addresses will be allocated from.

It should not overlap with any subnet in the network the Kubernetes cluster located in.

clusterIpv6CidrBlock : string

IPv6 range for allocating pod IP addresses.

serviceIpv6CidrBlock : string

IPv6 range for allocating Kubernetes service IP addresses

NetworkPolicy

Provider
  • PROVIDER_UNSPECIFIED

  • CALICO

provider : Provider

KMSProvider

keyId : string

KMS key ID for secrets encryption. To obtain a KMS key ID use a yandex.cloud.kms.v1.SymmetricKeyService.List request.

Cilium

RoutingMode
  • ROUTING_MODE_UNSPECIFIED

  • TUNNEL

routingMode : RoutingMode

ZonalMasterSpec

zoneId : string

ID of the availability zone.

internalV4AddressSpec : InternalAddressSpec

Specification of parameters for internal IPv4 networking.

externalV4AddressSpec : ExternalAddressSpec

Specification of parameters for external IPv4 networking.

RegionalMasterSpec

regionId : string

ID of the availability zone where the master resides.

locations : MasterLocation

List of locations where the master will be allocated.

externalV4AddressSpec : ExternalAddressSpec

Specify to allocate a static public IP for the master.

externalV6AddressSpec : ExternalAddressSpec

Specification of parameters for external IPv6 networking.

LocationSpec

zoneId : string

ID of the availability zone where the master resides.

subnetId : string

ID of the VPC network's subnet where the master resides. If not specified and there is a single subnet in specified zone, address in this subnet will be allocated.

ExternalAddressSpec

address : string

IP address.

MasterMaintenancePolicy

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.

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.

MasterLogging

enabled : bool

Identifies whether Cloud Logging is enabled for master components.

One of destination

The destination of master components' logs.

  • logGroupId : string

    ID of the log group where logs of master components should be stored.

  • folderId : string

    ID of the folder where logs should be stored (in default group).

auditEnabled : bool

Identifies whether Cloud Logging is enabled for audit logs.

clusterAutoscalerEnabled : bool

Identifies whether Cloud Logging is enabled for cluster-autoscaler.

kubeApiserverEnabled : bool

Identifies whether Cloud Logging is enabled for kube-apiserver.

eventsEnabled : bool

Identifies whether Cloud Logging is enabled for events.

InternalAddressSpec

subnetId : string

ID of the subnet. If no ID is specified, and there only one subnet in specified zone, an address in this subnet will be allocated.

MasterLocation

zoneId : string

ID of the availability zone.

internalV4AddressSpec : InternalAddressSpec

If not specified and there is a single subnet in specified zone, address in this subnet will be allocated.

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.

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.