Skip to main content

DeployRevision

Deploys a revision for the specified container.

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

const DeployContainerRevisionRequest =
cloudApi.serverless.containers_container_service
.DeployContainerRevisionRequest;
const LogLevel_Level = cloudApi.logging.log_entry.LogLevel_Level;
const Mount_Mode = cloudApi.serverless.containers_container.Mount_Mode;
const Revision = cloudApi.serverless.containers_container.Revision;

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

const operation = await client.deployRevision(
DeployContainerRevisionRequest.fromPartial({
containerId: "containerId",
// description: "description",
resources: {
// memory: 0,
// cores: 0,
// coreFraction: 0
},
// executionTimeout: {
// seconds: 0,
// nanos: 0
// },
// serviceAccountId: "serviceAccountId",
imageSpec: {
imageUrl: "imageUrl",
// command: {
// command: ["command"]
// },
// args: {
// args: ["args"]
// },
// environment: {"key": "environment"},
// workingDir: "workingDir"
},
// concurrency: 0,
// secrets: [{
// id: "id",
// versionId: "versionId",
// key: "key",
// environmentVariable: "environmentVariable"
// }],
// connectivity: {
// networkId: "networkId",
// subnetIds: ["subnetIds"]
// },
// provisionPolicy: {
// minInstances: 0
// },
// scalingPolicy: {
// zoneInstancesLimit: 0,
// zoneRequestsLimit: 0
// },
// logOptions: {
// disabled: true,
// logGroupId: "logGroupId",
// folderId: "folderId",
// minLevel: LogLevel_Level.TRACE
// },
// storageMounts: [{
// bucketId: "bucketId",
// prefix: "prefix",
// readOnly: true,
// mountPointPath: "mountPointPath"
// }],
// mounts: [{
// mountPointPath: "mountPointPath",
// mode: Mount_Mode.READ_ONLY,
// objectStorage: {
// bucketId: "bucketId",
// prefix: "prefix"
// },
// ephemeralDiskSpec: {
// size: 0,
// blockSize: 0
// }
// }]
})
);
const finishedOp = await waitForOperation(operation, session);

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

DeployContainerRevisionRequest

containerId : string

ID of the container to create a revision for.

To get a container ID, make a ContainerService.List request.

description : string

Description of the revision.

resources : Resources

Resources allocated to the revision.

executionTimeout : google.protobuf.Duration

Timeout for the execution of the revision.

If the timeout is exceeded, Serverless Containers responds with a 504 HTTP code.

serviceAccountId : string

ID of the service account to associate with the revision.

imageSpec : ImageSpec

Image configuration for the revision.

concurrency : int64

The number of concurrent requests allowed per container instance.

The default value is 1.

secrets : Secret

Yandex Lockbox secrets to be used by the revision.

connectivity : Connectivity

Network access. If specified the revision will be attached to specified network/subnet(s).

provisionPolicy : ProvisionPolicy

Policy for provisioning instances of the revision.

The policy is only applied when the revision is ACTIVE.

scalingPolicy : ScalingPolicy

Policy for scaling instances of the revision.

logOptions : LogOptions

Options for logging from the container.

storageMounts : StorageMount

S3 mounts to be used by the revision.

mounts : Mount

Mounts to be used by the revision.

Resources

Resources allocated to a revision.

memory : int64

Amount of memory available to the revision, specified in bytes, multiple of 128MB.

cores : int64

Number of cores available to the revision.

coreFraction : int64

Specifies baseline performance for a core in percent, multiple of 5%. Should be 100% for cores > 1.

ImageSpec

Revision image specification.

imageUrl : string

Image URL, that is used by the revision.

command : Command

Override for the image's ENTRYPOINT.

args : Args

Override for the image's CMD.

environment : string

Additional environment for the container.

workingDir : string

Override for the image's WORKDIR.

Secret

Secret that is available to the container at run time.

id : string

ID of Yandex Lockbox secret.

versionId : string

ID of Yandex Lockbox secret.

key : string

Key in secret's payload, which value to be delivered into container environment.

One of reference

  • environmentVariable : string

    Environment variable in which secret's value is delivered.

Connectivity

Revision connectivity specification.

networkId : string

Network the revision will have access to.

subnetIds : string

The list of subnets (from the same network) the revision can be attached to.

Deprecated, it is sufficient to specify only network_id, without the list of subnet_ids.

ProvisionPolicy

minInstances : int64

Minimum number of guaranteed provisioned container instances for all zones in total.

ScalingPolicy

zoneInstancesLimit : int64

Upper limit for instance count in each zone. 0 means no limit.

zoneRequestsLimit : int64

Upper limit of requests count in each zone. 0 means no limit.

LogOptions

disabled : bool

Is logging from container disabled.

One of destination

Log entries destination.

  • logGroupId : string

    Entry should be written to log group resolved by ID.

  • folderId : string

    Entry should be written to default log group for specified folder.

minLevel : yandex.cloud.logging.v1.LogLevel.Level

Minimum log entry level.

See LogLevel.Level for details.

StorageMount

bucketId : string

S3 bucket name for mounting.

prefix : string

S3 bucket prefix for mounting.

readOnly : bool

Is mount read only.

mountPointPath : string

Mount point path inside the container for mounting.

Mount

Mount contains an information about version's external storage mount

Mode
  • MODE_UNSPECIFIED

  • READ_ONLY

  • READ_WRITE

ObjectStorage

ObjectStorage as a mount

bucketId : string

ObjectStorage bucket name for mounting.

prefix : string

ObjectStorage bucket prefix for mounting.

DiskSpec

Disk as a mount

size : int64

The size of disk for mount in bytes

blockSize : int64

Optional block size of disk for mount in bytes

mountPointPath : string

The absolute mount point path inside the container for mounting.

mode : Mode

Mount's mode

One of target

Target mount option

  • objectStorage : ObjectStorage

    Object storage mounts

  • ephemeralDiskSpec : DiskSpec

    Working disk (worker-local non-shared read-write NBS disk templates)

Command

command : string

Command that will override ENTRYPOINT of an image.

Commands will be executed as is. The runtime will not substitute environment variables or execute shell commands. If one wants to do that, they should invoke shell interpreter with an appropriate shell script.

Args

args : string

Arguments that will override CMD of an image.

Arguments will be passed as is. The runtime will not substitute environment variables or execute shell commands. If one wants to do that, they should invoke shell interpreter with an appropriate shell script.

ObjectStorage

ObjectStorage as a mount

bucketId : string

ObjectStorage bucket name for mounting.

prefix : string

ObjectStorage bucket prefix for mounting.

DiskSpec

Disk as a mount

size : int64

The size of disk for mount in bytes

blockSize : int64

Optional block size of disk for mount in bytes

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.