<p>I have 2 kubernetes descriptor files (yml): one for prod and one for test.
The only difference between them is the fact that in production I want up to 4 replicas to grant horizontal scaling, while in test I'm fine.
So the production yaml has the following more:</p>

<pre><code>apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
  name: prodAutoScaling
spec:
  maxReplicas: 4
 minReplicas: 1
 scaleTargetRef:
  apiVersion: extensions/v1beta1
kind: Deployment
name: myapp
 targetCPUUtilizationPercentage: 80
</code></pre>

<p>If it was possible to put this configuration inside a config map I could have two identical descriptors and avoid maintaining both.
Is this possible?</p>

Phate
<p>It is incredibly straight-forward (6 lines total) to do this with <a href="https://get-ytt.io" rel="nofollow noreferrer"><code>ytt</code></a></p>
<p><code>./config/autoscaler.yml</code></p>
<pre class="lang-yaml prettyprint-override"><code>#@ load(&quot;@ytt:data&quot;, &quot;data&quot;)
---
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
  name: prodAutoScaling
spec:
  maxReplicas: #@ data.values.replicas
 minReplicas: 1
 scaleTargetRef:
   apiVersion: extensions/v1beta1
   kind: Deployment
   name: myapp
   targetCPUUtilizationPercentage: 80
</code></pre>
<p><code>./config/values.yml</code></p>
<pre><code>#@data/values
replicas: 1
</code></pre>
<p><code>./prod/values.yml</code></p>
<pre><code>#@data/values
replicas: 4
</code></pre>
<p>To deploy to test:</p>
<pre><code>$ ytt -f config/
</code></pre>
<p>To deploy to prod:</p>
<pre><code>$ ytt -f config/ -f prod/
</code></pre>
