DeployRevision
Deploys a revision for the specified container.
- TypeScript
- Python
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);
}
})();
import os
import grpc
import yandexcloud
from yandex.cloud.serverless.containers.v1.container_pb2 import Args
from yandex.cloud.serverless.containers.v1.container_pb2 import Command
from yandex.cloud.serverless.containers.v1.container_pb2 import Connectivity
from yandex.cloud.serverless.containers.v1.container_service_pb2_grpc import ContainerServiceStub
from yandex.cloud.serverless.containers.v1.container_service_pb2 import (
DeployContainerRevisionMetadata,
)
from yandex.cloud.serverless.containers.v1.container_service_pb2 import (
DeployContainerRevisionRequest,
)
from yandex.cloud.serverless.containers.v1.container_service_pb2 import ImageSpec
from yandex.cloud.serverless.containers.v1.container_pb2 import LogOptions
from yandex.cloud.serverless.containers.v1.container_pb2 import Mount
from yandex.cloud.serverless.containers.v1.container_pb2 import ProvisionPolicy
from yandex.cloud.serverless.containers.v1.container_pb2 import Resources
from yandex.cloud.serverless.containers.v1.container_pb2 import Revision
from yandex.cloud.serverless.containers.v1.container_pb2 import ScalingPolicy
from yandex.cloud.serverless.containers.v1.container_pb2 import Secret
from yandex.cloud.serverless.containers.v1.container_pb2 import StorageMount
token = os.getenv("YC_OAUTH_TOKEN")
sdk = yandexcloud.SDK(token=token)
service = sdk.client(ContainerServiceStub)
operation = service.DeployRevision(
DeployContainerRevisionRequest(
container_id="containerId",
# description = "description",
resources=Resources(
# memory = 0,
# cores = 0,
# core_fraction = 0
),
# execution_timeout = Duration(
# seconds = 0,
# nanos = 0
# ),
# service_account_id = "serviceAccountId",
image_spec=ImageSpec(
image_url="imageUrl",
# command = Command(
# command = ["command"]
# ),
# args = Args(
# args = ["args"]
# ),
# environment = {"key": "environment"},
# working_dir = "workingDir"
),
# concurrency = 0,
# secrets = [Secret(
# id = "id",
# version_id = "versionId",
# key = "key",
# environment_variable = "environmentVariable"
# )],
# connectivity = Connectivity(
# network_id = "networkId",
# subnet_ids = ["subnetIds"]
# ),
# provision_policy = ProvisionPolicy(
# min_instances = 0
# ),
# scaling_policy = ScalingPolicy(
# zone_instances_limit = 0,
# zone_requests_limit = 0
# ),
# log_options = LogOptions(
# disabled = true,
# log_group_id = "logGroupId",
# folder_id = "folderId",
# min_level = LogLevel.Level.TRACE
# ),
# storage_mounts = [StorageMount(
# bucket_id = "bucketId",
# prefix = "prefix",
# read_only = true,
# mount_point_path = "mountPointPath"
# )],
# mounts = [Mount(
# mount_point_path = "mountPointPath",
# mode = Mount.Mode.READ_ONLY,
# object_storage = Mount.ObjectStorage(
# bucket_id = "bucketId",
# prefix = "prefix"
# ),
# ephemeral_disk_spec = Mount.DiskSpec(
# size = 0,
# block_size = 0
# )
# )]
)
)
operation_result = sdk.wait_operation_and_get_result(
operation,
response_type=Revision,
meta_type=DeployContainerRevisionMetadata,
)
print(operation_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
: stringEnvironment 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
: stringEntry should be written to log group resolved by ID.
folderId
: stringEntry 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
: ObjectStorageObject storage mounts
ephemeralDiskSpec
: DiskSpecWorking 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.StatusThe error result of the operation in case of failure or cancellation.
response
: google.protobuf.AnyThe 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.