Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Using DeploymentV1.Update() #50

Closed
brobichaud opened this issue Dec 13, 2018 · 5 comments
Closed

Question: Using DeploymentV1.Update() #50

brobichaud opened this issue Dec 13, 2018 · 5 comments

Comments

@brobichaud
Copy link
Collaborator

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...

@tintoy
Copy link
Owner

tintoy commented Dec 13, 2018

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.

@brobichaud
Copy link
Collaborator Author

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);

@tintoy
Copy link
Owner

tintoy commented Dec 13, 2018

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);
});

@brobichaud
Copy link
Collaborator Author

Perfect, exactly what I needed. Thanks!

@tintoy
Copy link
Owner

tintoy commented Jan 14, 2019

Hi - I'm going to close this issue, but feel free to reopen it if you need to :)

@tintoy tintoy closed this as completed Jan 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants