Comments (7)
seems PatchNamespacedDeployment
is not working as except, I will have a look at that api.
from csharp.
using Microsoft.AspNetCore.JsonPatch;
var newlables = new Dictionary<string, string>(p.Metadata.Labels)
{
["test"] = "test"
};
var patch = new JsonPatchDocument<V1Pod>();
patch.Replace(e => e.Metadata.Labels, newlables);
client.PatchNamespacedPod(new V1Patch(patch), n, "default");
from csharp.
@tg123 I think this is the same underlying issue as this:
from csharp.
@RouR sorry for the late reply, just another busy week
Your approach is right and there is a tricky thing in generated client:
"will serialize all anonymous into {}"
due to default SerializationSettings
SerializationSettings = new JsonSerializerSettings
{
.........
ContractResolver = new ReadOnlyJsonContractResolver(),
.......
};
workarounds might be:
- change default SerializationSettings
- use https://github.com/aaxelm/JsonPatch.NetStandard to generate the json patch object
here is my tested using JsonPatch which is trying to add another label to pod.
var newlables = new Dictionary<string, string>(p.Metadata.Labels)
{
["test"] = "test"
};
var patch = new JsonPatchDocument<V1Pod>();
patch.Replace(e => e.Metadata.Labels, newlables);
client.PatchNamespacedPod(patch, n, "default");
@brendanburns
We need to support all 3 kinds of PatchType in the client
- JSONPatchType
- MergePatchType
- StrategicMergePatchType
howerver the generated client, like Java client, treat all body object as JSONPatchType.
I will try to find a better way to support Patch calls
from csharp.
Hmm,
As I see Headers is forced to "application/json-patch+json; charset=utf-8", but it`s work (I check in debugger headers)
_httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json-patch+json; charset=utf-8");
I use Microsoft.AspNetCore.JsonPatch instead of https://github.com/aaxelm/JsonPatch.NetStandard
with this code:
var newlables = new Dictionary<string, string>(item.Spec.Template.Metadata.Labels)
{
[ciLabel.Key] = "newData"
};
var patch = new JsonPatchDocument<Appsv1beta1Deployment>();
patch.Replace(e => e.Spec.Template.Metadata.Labels, newlables);
client.PatchNamespacedDeployment(patch, item.Metadata.Name, k8Namespace);
The type Appsv1beta1Deployment is not defined in NuGet-package KubernetesClient 0.3.0-beta
Please, update NuGet
Thank`s for the help!
from csharp.
Hi!
I took the latest version today.
I see breaking changes - PatchNamespacedDeployment require V1Patch object.
Can you explain how to use it? Or provide some example - how to change label in deployment specification?
from csharp.
Thanks!
from csharp.
Related Issues (20)
- [KubernetesClient.Aot] .NET 8 AOT compatibility for Scale functions HOT 15
- Prometheus-net is an unnecessary dependency HOT 8
- SlnGen instructions are potentially incomplete HOT 2
- Json serialization exception in .net8 HOT 2
- KubernetesYaml.Serialize Globalization issue
- How do you open the source code in an IDE without a .sln file? HOT 2
- Internal class IntOrStringJsonConverter doesn't work with System.Text.Json Source Generator HOT 9
- KubernetesClientConfiguration.LoadKubeConfig is not thread-safe due to YamlDotNet Deserializer
- Memory Leak with aot package ListDeployments and ListStatefulSet HOT 13
- KubernetesClientConfiguration.BuildConfigFromConfigFile with ExternalExecution deadlocks waiting for exit HOT 2
- sso aspnet application and kubernetes - token delegation HOT 6
- Remove polyfil package from net 7/8
- Some generated methods lacking ConfigureAwait(false) HOT 4
- Can not access /metrics endpoint using the IKubernetes.HttpClient. Restults in Unauthorized access. RBAC settings are correct HOT 2
- Log event before Kubernetes de-dups them HOT 2
- IdentityModel 5.2.0 nonsupport IdentityServer4.AccessTokenValidation 3.0.1 HOT 1
- nuget central package version management
- Login with client.authentication.k8s.io/v1beta1 fails due to handling of arguments HOT 1
- KubernetesClient.Aot args IList<string> serialization error HOT 3
- Cannot compile using new swagger.json
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from csharp.