<p>I have a CRD which contains several fields. like:</p>
<pre><code>            properties:
                fieldA:
                    type: boolean
                fieldB:
                    type: string
                    nullable: false
                fieldC:
                    type: integer
                fieldD:
                    type: string
                    nullable: false
</code></pre>
<p>Whenever I create a CR from it</p>
<pre><code>fieldA: true
fieldB: &quot;blabla&quot;
fieldC: 23
fieldD: &quot;blabla2&quot;
</code></pre>
<p>then run <code>kubectl get myCR -o yaml</code>, the field order seems random:</p>
<pre><code>fieldD: &quot;blabla2&quot;
fieldB: &quot;blabla&quot;
fieldC: 23
fieldA: true
</code></pre>
<p>Is there a way to keep the order defined either in CRD or CR?</p>

beatrice
<p>No.</p>
<p>The fields are part of a key-value-map. And a map stores no information about the order.<br />
You can change it to a list (which ensure the correct order), but this will make things really hard (for you and users of your CRD).</p>
