general-purpose runtime class runs standard Linux container images without changes. Each Instance runs in its own lightweight virtual machine with its own kernel, so the image gets the compatibility of a container and the isolation of a virtual machine.
Compute is in preview, and the
v1alpha API can change.Before you begin
- Select a project, install the
computeplugin, and get access to Compute. For more information, see Compute commands. - Push your image to a registry that Compute can reach, or use a public image.
Image requirements
A container image runs ongeneral-purpose Instances if it meets the following requirements:
- The image reference includes a registry host: Use
docker.io/library/redis:7orghcr.io/example/api:1.4.2, notredis:7. Datum rejects references without a registry host. - The app listens on IPv6: Instances have IPv6 addresses only. An app that listens only on an IPv4 address, such as
0.0.0.0, is unreachable. Configure it to listen on::(all IPv6 addresses), for example[::]:8080. - The app serves plain HTTP if you publish it: Datum terminates TLS for public URLs and connects to your Instances over plain HTTP. For more information, see Publish a workload.
- Private images have credentials: To pull from a private registry, add registry credentials to the workload. For more information, see Use images from a private registry.
datumctl compute build for general-purpose workloads. Build and push your image with the tools that you already use.
Deploy a container image
To deploy an image and publish it on a public URL, run the following command:WORKLOAD_NAME: a name for your workload.IMAGE: the full image reference, including the registry host.LOCATION: one or more locations, separated by commas, such asus-central-1,us-east-1.PORT: the port that your container serves HTTP on. To run the workload without a public URL, omit--http-port.
--runtime-class=general-purpose when you create the workload. Without it, Datum uses the unikernel class, and a standard image doesn’t boot.
Deploy from a manifest
Use a manifest when you need settings that thedeploy flags don’t expose, such as a custom command, a second placement, or a variable set from one key of a Secret. A flag-based deploy saves its result to workload.yaml, which you can edit as a starting point. Each flag-based deploy overwrites workload.yaml in the current directory, so keep edited manifests under another name.
The following manifest runs Redis in Dallas with a custom command:
spec.template.spec.
runtime.class: the runtime class. Set it togeneral-purpose.runtime.resources.instanceType: the Instance size.datumcloud/d1-standard-2(1 vCPU, 2 GiB) is the only type.sandbox.containers[].commandandargs: override the image’s entrypoint and command, in the same way as in Kubernetes.sandbox.containers[].ports: the ports the container listens on. A port on its own doesn’t make the workload reachable from the internet.networkInterfaces: the network the Instances attach to. Every workload needs exactly one network interface.
datumctl apply -f cache.yaml, which doesn’t wait for the rollout.
Control Linux capabilities
Every container starts with all Linux capabilities dropped. When a container doesn’t set a security context, Datum applies the class default and writes it into the workload, sodatumctl get workload cache -o yaml shows exactly what runs for the cache workload. The default does the following:
- Adds back
CHOWN,DAC_OVERRIDE,FOWNER,FSETID,KILL,NET_BIND_SERVICE,SETFCAP,SETGID,SETPCAP, andSETUID. - Sets
allowPrivilegeEscalationtofalse. - Sets
seccompProfile.typetoRuntimeDefault.
securityContext.capabilities on the container. The following example grants only NET_BIND_SERVICE and NET_ADMIN:
- A
capabilitieslist that you set replaces the class default. The default isn’t merged in, so list every capability your container needs. - Use capability names without the
CAP_prefix.ALLisn’t accepted inadd. general-purposeInstances can add any Linux capability, includingSYS_ADMIN, because the capability applies only inside the Instance’s own virtual machine.allowPrivilegeEscalationandseccompProfiledefault independently ofcapabilities.seccompProfile.typeacceptsRuntimeDefaultorUnconfined.- Datum applies the default when you create a workload. A later change to the class default doesn’t affect existing workloads.
Images that use sudo or setuid
BecauseallowPrivilegeEscalation defaults to false, a process can’t gain privileges after it starts. sudo, su, and other setuid programs fail inside the container, even though the capabilities are granted. This often affects vendor images that run as a non-root user and use sudo in an entrypoint script, for example to fix file ownership at startup.
To fix it, do one of the following:
- Preferred: do the privileged work when you build the image, such as running
chownin theContainerfile, so the container doesn’t needsudoat runtime. - Set
allowPrivilegeEscalation: truein the container’ssecurityContext. It only affects the Instance’s own virtual machine.
Limitations
In addition to the limitations that apply to all of Compute, thegeneral-purpose runtime class has the following limitations:
- Instances take several seconds to start, mostly spent booting a kernel and pulling the image.
- Host namespaces, host ports, host paths, and privileged host access aren’t available.
- The Instance’s kernel can’t load kernel modules. Features that need a module that isn’t built in, such as in-kernel WireGuard, VRFs, VLAN interfaces, or GRE tunnels, aren’t available. Userspace alternatives, such as
wireguard-go, work.
What’s next
- To set environment variables and use ConfigMaps and Secrets, see Configure a workload.
- To choose where to run and how many Instances to run, see Placement and scaling.
- To serve the workload on a public URL, see Publish a workload.