Stop sorting the fields in alphabetical order in generated yaml file
See original GitHub issueDescription of the feature or enhancement:
Hi, I don’t know whether this feature already exist or not, Can someone please help me with this issue.
When I run cdk8s synth
yaml files are getting generated in dist folder. List or directory declared in .ts file is getting sorted alphabetically in generated yaml file, is there a way to not sort these fields…?
Use Case: Avoiding alphabetical sort of dictionary or list resolves some pods to be not stuck in Creating Container
let tenant = new Tenant(this, 'tenant', {
metadata: {
name: 'minio',
creationTimestamp: null,
labels: {
app: 'minio'
},
scheduler: {
name: ""
}
},
spec: {
console: {
consoleSecret: {
name: 'minio-console-secret'
},
image: 'minio/console:v0.4.6',
replicas: 2,
resources: {},
},
credsSecret: {
name: 'minio-creds-secret'
},
image: 'minio/minio:RELEASE.2020-12-23T02-24-12Z',
mountPath: '/export',
requestAutoCert: true,
zones: [
{
resources: {},
servers: 4,
volumeClaimTemplate: {
apiVersion: 'v1',
kind: 'persistentvolumeclaims',
spec: {
storageClassName: 'provisioner',
accessModes: ['ReadWriteOnce'],
resources: {
requests: {
storage: '1G'
}
}
}
},
volumesPerServer: 1,
affinity: {
podAntiAffinity: {
preferredDuringSchedulingIgnoredDuringExecution: [
{
weight: 1,
podAffinityTerm: {
labelSelector: {
matchExpressions: [
{
key: 'app',
operator: 'In',
values: ['minio']
}
]
},
topologyKey: 'kubernetes.io/hostname'
}
}
]
}
}
}]
}
});
The generated yaml file from above .ts file is
kind: "Tenant"
metadata:
labels:
app: "minio"
name: "minio"
namespace: "minio"
scheduler:
name: ""
spec:
console:
consoleSecret:
name: "minio-console-secret"
image: "minio/console:v0.4.6"
replicas: 2
resources: {}
credsSecret:
name: "minio-creds-secret"
image: "minio/minio:RELEASE.2020-12-23T02-24-12Z"
mountPath: "/export"
requestAutoCert: true
zones:
- affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: "app"
operator: "In"
values:
- "minio"
topologyKey: "kubernetes.io/hostname"
weight: 1
resources: {}
servers: 4
volumeClaimTemplate:
apiVersion: "v1"
kind: "persistentvolumeclaims"
spec:
accessModes:
- "ReadWriteOnce"
resources:
requests:
storage: "1G"
storageClassName: "provisioner"
volumesPerServer:
Proposed Solution: Generate YAML file without alphabetical sort
kind: "Tenant"
metadata:
labels:
app: "minio"
name: "minio"
namespace: "minio"
scheduler:
name: ""
spec:
console:
consoleSecret:
name: "minio-console-secret"
image: "minio/console:v0.4.6"
replicas: 2
resources: {}
credsSecret:
name: "minio-creds-secret"
image: "minio/minio:RELEASE.2020-12-23T02-24-12Z"
mountPath: "/export"
requestAutoCert: true
zones:
- resources: {}
servers: 4
volumeClaimTemplate:
apiVersion: "v1"
kind: "persistentvolumeclaims"
spec:
accessModes:
- "ReadWriteOnce"
resources:
requests:
storage: "1G"
storageClassName: "provisioner"
volumesPerServer: 1
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
podAffinityTerm:
labelSelector:
matchExpressions:
- key: "app"
operator: In
values:
- minio
topologyKey: "kubernetes.io/hostname"
Issue Analytics
- State:
- Created 3 years ago
- Comments:18 (8 by maintainers)
Top Results From Across the Web
Stop sorting the fields in alphabetical order in generated yaml ...
When I run cdk8s synth yaml files are getting generated in dist folder. List or directory declared in .ts file is getting sorted...
Read more >How do I avoid Python I/O operation from auto-sorting the ...
When I change the value of the keys, the code sorts the keys in the file alphabetically. I want to avoid sorting. Below...
Read more >Sorting and ordering issue lists - GitLab Docs
Issues created most recently are first. ... When you sort by Title, the issue order changes to sort alphabetically by the issue title...
Read more >Code completion | IntelliJ IDEA Documentation - JetBrains
Select if you want to sort items in the suggestions list in the alphabetical order instead of sorting them by relevance. You can...
Read more >Search experience - OpenSearch documentation
You get back results sorted by the play_name field in alphabetic order. Use sort with search_after parameter for more efficient scrolling. You get...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Either export it in your shell before you synth or set it in-process using something like:
Before you create the
App
object.Let me know if everything works as expected.
Stay tuned for https://github.com/awslabs/cdk8s/pull/534