<p>I am trying to add if great than condition in Helm chart. it is throwing error.</p>

<p>I have defined value in values.yaml and using that value in deployment.yaml for condition.</p>

<p><strong>values.yaml</strong></p>

<pre><code>replicaCount: 2
</code></pre>

<p><strong>deployment.yaml</strong></p>

<pre><code>rollingUpdate:
  maxSurge: 1
  {{ if gt .Values.replicaCount 2}}
  maxUnavailable: 0
  {{ else }}
  maxUnavailable: 1
  {{ end }}
</code></pre>

<p>I am using helm dry run option to check result. getting error</p>

<pre><code>Error: render error in "hello-world/templates/deployment.yaml": template: hello-world/templates/deployment.yaml:16:12: executing "hello-world/templates/deployment.yaml" at &lt;gt .Values.replicaCo...&gt;: error calling gt: incompatible types for comparison
</code></pre>

<p>how to fix this ?</p>

<p>Try using float number in comparison instead:</p>

<p><strong>deployment.yaml</strong></p>

<pre><code>rollingUpdate:
  maxSurge: 1
  {{ if gt .Values.replicaCount 2.0}}
  maxUnavailable: 0
  {{ else }}
  maxUnavailable: 1
  {{ end }}
</code></pre>

<p>Helm (along with underlying Golang templates and Yaml) can be weird sometimes. </p>

<hr>

<p>Also, note that sometimes you need to typecast values in your yaml configs (e.g. port numbers).</p>

<p>Example:</p>

<pre><code>...
ports:
- containerPort: !!int {{ .Values.containers.app.port }}
...
</code></pre>

<p>More about Yaml type casting: <a href="https://github.com/yaml/YAML2/wiki/Type-casting" rel="noreferrer">https://github.com/yaml/YAML2/wiki/Type-casting</a></p>
