Skip to content

Serialization order of ConfigMap properties #1715

@htbmw

Description

@htbmw

Describe the bug
Not sure if this is a bug or if it can be optimized or if it is by design (expected) and should be left as is.
Please advise.

When creating a configmap using V1ConfigMap, the resulting file looks like this with this particular ordering:

apiVersion: apps/v1
data:
  array.json: '[]'
kind: ConfigMap
metadata:
  name: my-configmap
  namespace: my-namespace

I expect data to appear at the end after the common shared properties like apiVersion, kind and metadata.

Kubernetes C# SDK Client Version
17.0.14

Server Kubernetes Version
1.33.6

Dotnet Runtime Version
.net8

To Reproduce
Steps to reproduce the behavior:

Create a new configmap instance using the following and write it to a file:

new V1ConfigMap() {
        ApiVersion = "apps/v1",
        Kind = "ConfigMap",
        Metadata = new V1ObjectMeta { Name = "my-configmap", NamespaceProperty = "my-namespace" },
        Data = new Dictionary<string, string>()
        {
          { "array.json", "[]" }
        }
      };

Expected behavior
I would like to see the following order of properties in the yaml file:

apiVersion: apps/v1
kind: ConfigMap
metadata:
  name: my-configmap
  namespace: my-namespace
data:
  array.json: '[]'

Where do you run your app with Kubernetes SDK (please complete the following information):

  • Linux
  • Pod
  • Azure AKS

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions