<p>I'm working on composing yaml file for installing Elasticsearch via the ECK operator (CRD).</p>

<p>Its documented here - <a href="https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-elasticsearch-specification.html" rel="nofollow noreferrer">https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-elasticsearch-specification.html</a></p>

<p>As one goes through the sub-links, you will discover there are various pieces through which we can define the configuration of Elasticsearch.</p>

<p>The description of the CRD is contained here, but <strong>this is not easy to read</strong> -
<a href="https://download.elastic.co/downloads/eck/1.0.0-beta1/all-in-one.yaml" rel="nofollow noreferrer">https://download.elastic.co/downloads/eck/1.0.0-beta1/all-in-one.yaml</a></p>

<p>I'm curious how do Kubernetes developers understand various constructs of yaml file for a given kubernetes resource ?</p>

Aravind
<p><strong>Docs</strong></p>

<p>In general, if it's a standard resource, the best way is to consult the official documentation for all the fields of the resource.</p>

<p>You can do this with <code>kubectl explain</code>. For example:</p>

<pre><code>kubectl explain deploy
kubectl explain deploy.spec
kubectl explain deploy.spec.template
</code></pre>

<p>You can find the same information in the web-based <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.15/" rel="nofollow noreferrer">API reference</a>.</p>

<p><strong>Boilerplate</strong></p>

<p>For <em>some</em> resources, you can use <code>kubectl create</code> to generate the YAML for a basic version of the resource, which you can then use as a starting point for your own customisations.</p>

<p>For example:</p>

<pre><code>kubectl create deployment --image=nginx mydep -o yaml --dry-run &gt;mydep.yaml
</code></pre>

<p>This generates the YAML for a Deployment resource and saves it in a local file. You can then customise the resource from there.</p>

<p>The <code>--dry-run</code> option causes the generated resource definition to <strong>not</strong> be submitted to the API server (so it won't be created) and the <code>-o yaml</code> option outputs the generated definition of the resource in YAML format.</p>

<p>Other common resources for which this is possible include:</p>

<ul>
<li>(Cluster)Role</li>
<li>(Cluster)RoleBinding</li>
<li>ConfigMap</li>
<li>Deployment</li>
<li>Job</li>
<li>PodDisruptionBudget</li>
<li>Secret</li>
<li>Service</li>
</ul>

<p>See <code>kubectl create -h</code>.</p>
