-
Notifications
You must be signed in to change notification settings - Fork 308
Description
Describe the bug
KubernetesYaml.Serialize() currently converts byte[] fields into plain strings. This causes issues for Secret manifests, since the data field ends up containing string content instead of base64. As a result, the generated manifests can’t be applied directly with kubectl — they only round-trip cleanly if you deserialize them back through KubernetesYaml.Deserialize() first.
var cfg = KubernetesClientConfiguration.BuildDefaultConfig();
var client = new Kubernetes(cfg);
var secret = client.ReadNamespacedSecret("default-token-gvs7k", "default");
var yaml = KubernetesYaml.Serialize(secret);
File.WriteAllText("secret.yaml", yaml);
kubectl apply -f .\secret.yaml
Error from server (BadRequest): error when creating ".\\secret.yaml": Secret in version "v1" cannot be handled as a Secret: illegal base64 data at input byte 0
Kubernetes C# SDK Client Version
17.0.4
Dotnet Runtime Version
e.g. net9
To Reproduce
Serialize Secret with KuberntesYaml.Serialize and apply with Kubectl
Expected behavior
KuberntesYaml.Serialize should output a valid Yaml that can be applied with other Kubernetes tools.
If the strings are moved from the data
field to stringData
then it would be a valid Secret.