-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Here’s a simplified example that scales down the inference-system Deployment in the point-robinson namespace:
using System;
using System.Threading.Tasks;
using k8s;
using k8s.Models;
class Program
{
static async Task Main(string[] args)
{
// Load kubeconfig (default: ~/.kube/config)
var config = KubernetesClientConfiguration.BuildConfigFromConfigFile();
IKubernetes client = new Kubernetes(config);
string namespaceName = "point-robinson";
string deploymentName = "inference-system";
// Get the Deployment
var deployment = await client.ReadNamespacedDeploymentAsync(deploymentName, namespaceName);
// Set replicas to 0
deployment.Spec.Replicas = 0;
// Update the Deployment
await client.ReplaceNamespacedDeploymentAsync(deployment, deploymentName, namespaceName);
Console.WriteLine($"Scaled down {deploymentName} in {namespaceName} to 0 replicas.");
}
}- This only affects the Deployment in that namespace — other namespaces remain untouched.
- Once replicas = 0, the ReplicaSet won’t recreate pods, so CPU usage drops to zero for that workload.
- You can later set deployment.Spec.Replicas = 1 (or more) to bring it back.
Metadata
Metadata
Assignees
Labels
No labels