Closed brobichaud closed 5 years ago
Hi. It's unfortunate, but the K8s API makes it painful to do updates that aren't JSON-PATCH-based (which is why the update API looks like it does).
I don't think we have a specific example, but I'll see if I can write one up.
That would be great @tintoy. Below is some pseudo code of where I am headed currently. I have no idea what to do in the Action delegate...
var depClient = GetDeploymentClient();
var dep = await depClient.Get("my-deployment-name");
var patchDoc = new JsonPatchDocument<DeploymentV1>();
patchDoc.Replace(e => e.Spec.Replicas, 2);
Action<JsonPatchDocument<DeploymentV1>> act = (JsonPatchDocument<DeploymentV1> p) => Console.WriteLine(p.Operations.Count);
await depClient.Update(dep.Metadata.Name, act);
Ah, I think I see the source of the confusion :)
The idea is that you call Update
with a callback delegate, and it passes your delegate a patch document in the delegate (makes it easier to use inline):
await depClient.Update("my-deployment-name", patch =>
{
patch.Replace(deployment => deployment.Spec.Replicas, 2);
});
Perfect, exactly what I needed. Thanks!
Hi - I'm going to close this issue, but feel free to reopen it if you need to :)
Are there any sample snippets on how to update a deployment? Specifically I'm struggling to figure out how to start a pod scale-out by increasing the Replicas count. The syntax of the api is tripping me up quite thoroughly...