Skip to the content.

mk8s — Managed Service for Kubernetes

Module: services/mk8s · Image: nebius-mocker-mk8s · NEBIUS_MOCKER_SERVICES=mk8s M1 tier: T2 (mock backend) · T3: k3s backend (real Kubernetes in Docker) · Endpoint: mk8s.api.nebius.cloud

Implementation status

Piece Status
nebius.mk8s.v1.ClusterService: Create, Get, GetByName, List (paged), Update (reset mask, resource_version), Delete, ListControlPlaneVersions ✅ T2
nebius.mk8s.v1.NodeGroupService: Create, Get, GetByName, List (paged), Update (reset mask, resource_version), Delete, Upgrade, PreflightCheck, GetCompatibilityMatrix ✅ T2
nebius.mk8s.v1alpha1.ClusterService and NodeGroupService (deprecated): every RPC, as a second view of the same stored v1 resources (same IDs; common.v1alpha1 operations) ✅ T2
Node instances: every node of a node group is an ordinary compute instance (RUNNING, boot disk named <node>-boot), visible in InstanceService.Get/List; user updates, start, stop and delete are refused with FAILED_PRECONDITION ✅
Backend port (domain.Backend in services/mk8s/domain/ports.go); mock is the default ✅
Control-plane version catalog, node group version skew, node image compatibility matrix ✅
NodeGroupService.PreflightCheck (create, update, recreate, delete; unknown_paths; paths_require_recreate) ✅
Defaults filled like the service (control-plane subnet, etcd size, node boot disk, network interface subnet, deployment strategy) ✅
Status counts (node_count, ready_node_count, target_node_count, outdated_node_count), not-ready nodes reported honestly ✅
Cluster delete cascades: node groups and their node instances, Applications releases, the VPC network binding ✅
nebius mk8s cluster get-credentials kubeconfig and the get-token exec plugin ✅ e2e: test/cli/mk8s (with the mock backend nothing serves the Kubernetes API)
Authorization: rules for every RPC (mk8s.clusters.*, mk8s.nodeGroups.*); viewers read clusters, node groups and node instances ✅
nebius_mk8s_v1_{cluster,node_group} and nebius_mk8s_v1alpha1_{cluster,node_group} resources and data sources with the official provider ✅ e2e: test/terraform/mk8s
A working Kubernetes API: k3s backend (a k3s server per cluster, a k3s agent per node, bounded by the Docker host), Nebius IAM tokens through a TokenReview webhook mapped to nebius:viewer/editor/admin, GPU capacity ✅ e2e: test/mk8s (make e2e-mk8s), see k3s backend
Rolling node replacement in batches that honour strategy (max_surge, max_unavailable), progress in status ✅
template.max_pods (8–256, default 110): stored and echoed, a change rolls the nodes out; the k3s backend runs each kubelet with it ✅ e2e: test/terraform/mk8s, make e2e-mk8s
Quotas: mk8s.cluster.count on cluster Create; node group Create and scale-up are checked against the compute quotas of the nodes they add (instances, vCPUs or GPUs, boot disks), synchronously; each node is then charged by compute (quotas.md) ✅ contract: test/contract/quotas_compute_test.go
Audit logs, Karpenter, OIDC, NVLink, reservations, local disks, spot, auto-repair conditions, container runtime Not yet (see Not yet)

Verified against: nebius/api@4522189, terraform-provider-nebius v0.6.91, gosdk v0.2.100, nebius CLI 0.12.312.

Covered by unit tests (services/mk8s/{domain,dal,api,backend/mock}, services/compute/domain/nodes_test.go), gosdk contract tests (test/contract/mk8s_*), the Terraform e2e suite (test/terraform/mk8s) and the CLI e2e suite (test/cli/mk8s), all run by make e2e; the k3s backend by its unit tests (services/mk8s/backend/k3s, pkg/dockerhost, services/iam/{domain,api}/k8swebhook_test.go) and make e2e-mk8s.

Resource kind Message NID prefix Parent States
Cluster mk8s.v1.Cluster mk8scluster project PROVISIONING, RUNNING, DELETING (+ reconciling)
Node group mk8s.v1.NodeGroup mk8snodegroup cluster PROVISIONING, RUNNING, DELETING (+ reconciling)

Behavior notes

These follow docs.nebius.com/kubernetes and the protos. Where neither says what happens, the mock’s choice is marked (mock).

Clusters

Node groups

Node instances

Each node is a compute instance named <node group name>-<5 characters>, in the cluster’s project, created RUNNING without a visible operation, with a managed boot disk. Labels (mock names: the real label keys are undocumented):

Label Value
mk8s.nebius.ai/cluster-id cluster ID
mk8s.nebius.ai/node-group-id node group ID
mk8s.nebius.ai/node-group-name node group name

They win over template.instance_metadata.labels. The same three labels go on the Kubernetes Nodes, with template.metadata.labels (keys containing kubernetes.io or k8s.io are dropped, per the proto). Users cannot Update, Start, Stop or Delete a node instance: those fail with FAILED_PRECONDITION, “… is a node of mk8s node group …: change the node group instead”.

Credentials

nebius mk8s cluster get-credentials --id <id> --external|--internal writes the kubeconfig Nebius writes: cluster, context and user named nebius-mk8s-<cluster name>-<ID suffix> (the cluster ID without mk8scluster-), server the public (--external) or private (--internal) endpoint verbatim, the CA embedded, and an exec plugin (client.authentication.k8s.io/v1beta1) that runs nebius mk8s v1 cluster get-token --profile <profile> --format json. get-token returns an IAM token from the mock. With the k3s backend that kubeconfig works with kubectl as is (how); with the mock backend kubectl cannot connect: the endpoint resolves to loopback and nothing listens. test/cli/mk8s checks the kubeconfig and runs the exec command as kubectl would.

Backends

domain.Backend (services/mk8s/domain/ports.go) is the Kubernetes data plane: CheckVersion, EnsureCluster, DeleteCluster, EnsureNodes, Close. The control plane (resources, validation, operations, node instances) is the mock’s; a backend only runs Kubernetes. Calls come from operation work, never inside a store transaction, one at a time per cluster; every method is idempotent. EnsureNodes reports each node’s readiness: a node the backend cannot run is not ready, with a reason, instead of an error, so the group honestly shows node_count > ready_node_count, reconciling = true and a WARN event NodesNotReady. A failed reconciliation records an ERROR event (ReconciliationFailed) and fails the operation.

NEBIUS_MOCKER_MK8S_BACKEND Behavior
mock (default) No Kubernetes. Endpoints that resolve to loopback, a self-signed CA, every node ready at once. Operations do their work inside the request
k3s A real k3s cluster per cluster and a k3s agent container per node, in Docker (k3s backend)

Every backend but mock starts containers, so its operations run detached: Create, Update and Delete return the operation at once and the work finishes on its own goroutine (pkg/operations, Detached) while clients poll it.

Preflight check

NodeGroupService.PreflightCheck runs the validation of Create or Update in dry-run mode and returns diagnostics (ERROR, with the field path) instead of failing, whatever the problem (unknown cluster, bad version, unknown platform, unimplemented field, duplicate name). context.action is CREATE, RECREATE, UPDATE or DELETE (nothing to check); unspecified means UPDATE when metadata.id is set, else CREATE. context.unknown_paths (a Nebius mask) skips the checks of values Terraform does not know yet. An UPDATE that changes an immutable path (metadata.parent_id, template.nvlink.nvl_instance_group_id) returns it in paths_require_recreate and is evaluated as a recreate. An update preflight is a patch with the request’s reset mask, like the Update it previews. The provider calls it on every plan.

Fields rejected as not implemented

A field the mock cannot honor is INVALID_ARGUMENT, “… is not implemented in NebiusMocker yet”, naming the path, on Create, Update and PreflightCheck. Nothing is silently ignored:

Operations and errors

Authorization

Every RPC has a rule: mk8s.clusters.{get,list,create,update,delete} on the cluster (or its project) and mk8s.nodeGroups.* on the node group (or its cluster). NodeGroupService.Upgrade needs mk8s.nodeGroups.update. ListControlPlaneVersions and GetCompatibilityMatrix are open to any authenticated principal, and so is a PreflightCheck with neither an ID nor a parent (Terraform planning a node group whose cluster does not exist yet); otherwise it needs mk8s.nodeGroups.get on the node group or its cluster. v1alpha1 uses the same permissions. viewer reads clusters, node groups, the catalog, preflight results and the node instances, and is PERMISSION_DENIED on every write (test/contract/mk8s_authz_test.go).

Not yet

Terraform

All four resources and data sources run against the real provider in test/terraform/mk8s: create, an empty plan, an in-place update, another empty plan, a template change that rolls every node instance out in batches, replacement on immutable attributes, and destroy, plus a viewer that can read but not create.

Kind Terraform type Service RPCs called Tested
Resource nebius_mk8s_v1_cluster nebius.mk8s.v1.ClusterService Get, GetByName, Create, Update, Delete + OperationService.Get ✅
Resource nebius_mk8s_v1_node_group nebius.mk8s.v1.NodeGroupService Get, GetByName, Create, Update, Delete, PreflightCheck + OperationService.Get ✅
Resource nebius_mk8s_v1alpha1_cluster nebius.mk8s.v1alpha1.ClusterService Get, GetByName, Create, Update, Delete + OperationService.Get ✅
Resource nebius_mk8s_v1alpha1_node_group nebius.mk8s.v1alpha1.NodeGroupService Get, GetByName, Create, Update, Delete + OperationService.Get ✅
Data source nebius_mk8s_v1_cluster nebius.mk8s.v1.ClusterService Get, GetByName ✅
Data source nebius_mk8s_v1_node_group nebius.mk8s.v1.NodeGroupService Get, GetByName ✅
Data source nebius_mk8s_v1alpha1_cluster nebius.mk8s.v1alpha1.ClusterService Get, GetByName ✅
Data source nebius_mk8s_v1alpha1_node_group nebius.mk8s.v1alpha1.NodeGroupService Get, GetByName ✅

The provider has no kubeconfig resource: build a kubeconfig from status.control_plane.endpoints and auth.cluster_ca_certificate, or run nebius mk8s cluster get-credentials.

CLI

test/cli/mk8s runs the official nebius CLI through the flows of docs.nebius.com/kubernetes: mk8s cluster list-control-plane-versions, create (public endpoint), get-by-name, get-credentials and the get-token exec command; mk8s node-group create (fixed node count, platform and preset), get-compatibility-matrix, update, upgrade, list and delete; the node instances in compute instance list, with compute instance delete and stop refused (FailedPrecondition); a viewer that reads but cannot delete (PermissionDenied); and the Applications release commands (see applications.md).

Configuration

Env Default Description
NEBIUS_MOCKER_MK8S_BACKEND mock mock | k3s (needs Docker; fails at startup, naming the setting, without it)
NEBIUS_MOCKER_MK8S_ROLLOUT_STEP 0 Pause between the batches of a node group rollout, on the mocker’s clock
NEBIUS_MOCKER_MK8S_K3S_*   k3s backend: Docker host, images per version, endpoint host, webhook URL, capacity estimates and limits, start timeout (configuration)
NEBIUS_MOCKER_MK8S_VERSIONS 1.34,1.35,1.36 Control-plane version catalog, <major>.<minor>, comma-separated; the newest is the default for new clusters

k3s backend: real Kubernetes

NEBIUS_MOCKER_MK8S_BACKEND=k3s gives every mk8s cluster a real Kubernetes API, the way LocalStack runs EKS (MANAGED_K8S_PROVIDER, one k3s container per cluster). The mock still owns the control plane (resources, validation, operations, nodes as compute instances); services/mk8s/backend/k3s runs Kubernetes on the local Docker host through the Docker Engine API (pkg/dockerhost, no k3d binary):

mk8s Docker Kubernetes
Cluster rancher/k3s:<tag> server container nebius-mocker-<cluster id>-server (+ network and data volume of the same name) API server, no kubelet (--disable-agent: like Nebius, the control plane is not a node)
Node group node k3s agent container nebius-mocker-<cluster id>-<node name> Node named after the node’s compute instance, with the group’s labels and taints

Authentication: Nebius IAM tokens, documented groups

The kubeconfig from get-credentials runs nebius mk8s v1 cluster get-token --profile <p> --format json, which prints the profile’s IAM access token. Each k3s API server is started with webhook token authentication pointing at the mocker (POST /mk8s/v1/clusters/<id>/tokenreview on the edge port, NEBIUS_MOCKER_MK8S_K3S_WEBHOOK_URL). The webhook accepts every token the gRPC edge accepts (dev tokens, tokens exchanged for service-account keys or federated credentials) and answers with:

Nebius documents these groups (OIDC providers: “users who access the cluster with Nebius AI Cloud credentials … are in groups such as nebius:viewer, nebius:editor, and nebius:admin, and these groups already have permissions in the cluster”). The exact bindings are not documented; the mock installs ClusterRoleBindings nebius:viewer → view, nebius:editor → edit, nebius:admin → cluster-admin, plus nebius:node-reader (get, list, watch Nodes, which view and edit do not cover) for viewers and editors. So a viewer service account can list pods but not create them. Bind your own roles to these groups, or to the user names, for anything finer. Under NEBIUS_MOCKER_AUTHZ=off and audit (the default) every valid token gets nebius:admin (audit logs the group it would get), as the gRPC edge never blocks in those modes.

Nodes: bounded by the machine

Each node of a node group is one agent container, admitted while the Docker host fits it: at most NCPU / NEBIUS_MOCKER_MK8S_K3S_AGENT_CPU agents, free memory (docker info MemTotal minus what running containers use, this backend’s containers counted at least at their estimate) above _MEMORY_RESERVE plus _AGENT_MEMORY, and _MAX_AGENTS if set. A node that does not fit is never faked: it stays not ready, ready_node_count < node_count, and the node group status names the limit (for example “Docker host capacity: 3 of 3 k3s agents are running (NEBIUS_MOCKER_MK8S_K3S_MAX_AGENTS)”). Agents that exit or do not join within _START_TIMEOUT are reported the same way, with their last log lines.

GPU presets: there are no GPUs, but each node of a GPU preset advertises the preset’s GPU count as the extended resource nvidia.com/gpu (what the NVIDIA device plugin reports), so pods requesting GPUs and GPU DaemonSets schedule on them. Nothing runs on a GPU.

Lifecycle

Every container, network and volume carries nebius-mocker.backend=k3s, nebius-mocker.cluster=<id>, nebius-mocker.owner=<webhook URL> (the mocker that made it) and, for agents, nebius-mocker.node-group, nebius-mocker.node and nebius-mocker.instance. They are removed when their cluster, node group or node goes, when the mocker shuts down, and at startup (leftovers of a killed mocker on the same port: LocalStack’s orphan problem). A mocker only reaps its own owner’s objects, so two mockers can share a Docker host; deploy/k3s/reap.sh removes objects whose owner port no longer answers. A cluster stays PROVISIONING until its API server answers /readyz; a server that exits or does not get ready within _START_TIMEOUT fails the operation with FAILED_PRECONDITION and the server’s last log lines. With the k3s backend and no reachable Docker daemon the mocker refuses to start and names the setting.

Using it from your machine

The kubeconfig’s exec plugin runs the nebius CLI without --insecure, and a profile cannot store that flag, so the mocker must serve TLS from a CA your machine trusts (as for the registry credential helper):

  1. A certificate for api.nebius.cloud, *.api.nebius.cloud and *.iam.api.nebius.cloud (plus localhost), issued by a local CA (mkcert works). Trust the CA: macOS Keychain (security add-trusted-cert, or mkcert -install); Linux /usr/local/share/ca-certificates + update-ca-certificates.
  2. Resolve the API names to the mocker: /etc/hosts lines 127.0.0.1 api.nebius.cloud cpl.iam.api.nebius.cloud tokens.iam.api.nebius.cloud mk8s.api.nebius.cloud compute.api.nebius.cloud vpc.api.nebius.cloud.
  3. Start the mocker:
    NEBIUS_MOCKER_MK8S_BACKEND=k3s NEBIUS_MOCKER_AUTHZ=enforce \
    NEBIUS_MOCKER_TLS_CERT_FILE=tls.crt NEBIUS_MOCKER_TLS_KEY_FILE=tls.key make run
    
  4. nebius profile create mocker --endpoint api.nebius.cloud:4566 --token-file token --parent-id <project>, create the cluster and a node group (Terraform: address_options = { "*" = { no_tls_verify = true } } or trust the CA), then nebius mk8s cluster get-credentials --id <cluster> --external and use kubectl.

Terraform’s provider can use no_tls_verify = true instead of trusting the CA.

Tested by make e2e-mk8s (test/mk8s): Terraform creates a network, a cluster, a CPU node group (labels, a taint) and a GPU node group; get-credentials and kubectl in a Linux user-machine container see the nodes (named after their compute instances, labels, taints, nvidia.com/gpu); a Deployment rolls out, a DaemonSet lands on every node and a GPU pod schedules on the GPU node; host kubectl with the editor token can create Deployments but not ClusterRoleBindings; a viewer service account (key exchange from a CLI profile) is nebius:viewer, lists pods and cannot create; scaling past NEBIUS_MOCKER_MK8S_K3S_MAX_AGENTS leaves nodes not ready with the reason, scaling down removes agents, nodes and instances; a template label and taint change updates the node in place (a user’s own label stays); a preset change rolls the group onto a new node, and the Deployment’s pods, under a PodDisruptionBudget, are evicted by their own kubelet (drained) and rescheduled there before the old agent goes; terraform destroy leaves no container.

API surface

nebius.mk8s.v1.ClusterService

Endpoint: mk8s.api.nebius.cloud:443 · Proto: nebius/mk8s/v1/cluster_service.proto · used by Terraform

RPC Request Response TF
Get GetClusterRequest Cluster ✅
GetByName common.v1.GetByNameRequest Cluster ✅
List ListClustersRequest ListClustersResponse  
Create CreateClusterRequest common.v1.Operation ✅
Update UpdateClusterRequest common.v1.Operation ✅
Delete DeleteClusterRequest common.v1.Operation ✅
ListControlPlaneVersions ListClusterControlPlaneVersionsRequest ListClusterControlPlaneVersionsResponse  

nebius.mk8s.v1.NodeGroupService

Endpoint: mk8s.api.nebius.cloud:443 · Proto: nebius/mk8s/v1/node_group_service.proto · used by Terraform

RPC Request Response TF
Get GetNodeGroupRequest NodeGroup ✅
GetByName common.v1.GetByNameRequest NodeGroup ✅
List ListNodeGroupsRequest ListNodeGroupsResponse  
Create CreateNodeGroupRequest common.v1.Operation ✅
Update UpdateNodeGroupRequest common.v1.Operation ✅
Delete DeleteNodeGroupRequest common.v1.Operation ✅
Upgrade UpgradeNodeGroupRequest common.v1.Operation  
PreflightCheck PreflightCheckNodeGroupRequest PreflightCheckNodeGroupResponse ✅
GetCompatibilityMatrix GetNodeGroupCompatibilityMatrixRequest NodeGroupCompatibilityMatrix  

nebius.mk8s.v1alpha1.ClusterService (deprecated)

Endpoint: mk8s.api.nebius.cloud:443 · Proto: nebius/mk8s/v1alpha1/cluster_service.proto · used by Terraform

RPC Request Response TF
Get GetClusterRequest Cluster ✅
GetByName GetClusterByNameRequest Cluster ✅
List ListClustersRequest ListClustersResponse  
Create CreateClusterRequest common.v1alpha1.Operation ✅
Update UpdateClusterRequest common.v1alpha1.Operation ✅
Delete DeleteClusterRequest common.v1alpha1.Operation ✅
ListControlPlaneVersions ListClusterControlPlaneVersionsRequest ListClusterControlPlaneVersionsResponse  

nebius.mk8s.v1alpha1.NodeGroupService (deprecated)

Endpoint: mk8s.api.nebius.cloud:443 · Proto: nebius/mk8s/v1alpha1/node_group_service.proto · used by Terraform

RPC Request Response TF
Get GetNodeGroupRequest NodeGroup ✅
GetByName GetNodeGroupByNameRequest NodeGroup ✅
List ListNodeGroupsRequest ListNodeGroupsResponse  
Create CreateNodeGroupRequest common.v1alpha1.Operation ✅
Update UpdateNodeGroupRequest common.v1alpha1.Operation ✅
Delete DeleteNodeGroupRequest common.v1alpha1.Operation ✅
Upgrade UpgradeNodeGroupRequest common.v1alpha1.Operation