<p>I'm trying to patch ingress when I specify json like below, I'm able to (all below commands have --dry-run enabled, I know):</p>
<pre><code>kubectl patch ing ing-routing '--type=json'  '--patch=[{&quot;op&quot;: &quot;add&quot;,&quot;path&quot;: &quot;/spec/rules/0/http/paths/-&quot;,&quot;value&quot;: {&quot;path&quot;: &quot;/path/to/patch/service&quot;, &quot;backend&quot;: {&quot;serviceName&quot;: &quot;patch-svc-cip&quot;,&quot;servicePort&quot;: 8443}}}]' --dry-run -o yaml -n namespace
</code></pre>
<p>But if I try to do it like:</p>
<pre><code>value=&quot;$(&lt;/tmp/ingress-route-patch.json)&quot;
kubectl patch ing ing-routing '--type=json'  '--patch=$value' --dry-run -o yaml -n namespace
</code></pre>
<p>I get this error: <code>error: json: cannot unmarshal string into Go value of type jsonpatch.Patch</code></p>
<p>I have also tried</p>
<pre><code>ingressRoute=$(cat /tmp/ingress-routing-patch.json)
kubectl patch ing ing-routing '--type=json'  '--patch=$ingressRoute' --dry-run -o yaml -n namespace
</code></pre>
<p>&amp;</p>
<pre><code>kubectl patch ing ing-routing '--type=json'  '--patch=$(cat /tmp/ingress-routing-patch.json)' --dry-run -o yaml -n namespace
</code></pre>
<p>&amp;</p>
<pre><code>kubectl patch ing ing-routing --type='json'  -p='$(cat /tmp/ingress-routing-patch.json)' --dry-run -o yaml -n namespace
</code></pre>
<p>but same error came everytime. I need to patch it from a file since we need to add endpoints dynamically.</p>

<p>You should use <code>&quot;</code> in <code>-p</code> flag instead of <code>'</code>.
Following works for me</p>
<pre><code>kubectl patch ing ing-routine --type='json'  -p=&quot;$(cat /tmp/ingress-routing-patch.json)&quot; --dry-run -o yaml
</code></pre>
