<p>I want to edit a Kubernetes Ingress configuration and add/replace some data inside the file using a linux command, as i am writing a shell script.</p>
<p>The command i have to use is :</p>
<pre><code>kubectl edit svc -n istio-system istio-ingressgateway
</code></pre>
<p>The command opens up a VI editor and i need to replace some lines to achieve my setup, and i want to write a shell command that opens up, appends and saves into it.</p>

Rohan Bansal
<p>you can use the <a href="https://kubernetes.io/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch/" rel="nofollow noreferrer">kubectl patch</a>.</p>
<p>if there is a simple change, for example, change patching <code>loadBalancerIP</code></p>
<pre><code>kubectl patch services itom-cdf-ingress-frontend-svc -p '{&quot;spec&quot;:{&quot;type&quot;:&quot;LoadBalancer&quot;,&quot;loadBalancerIP&quot;: &quot;EXTERNAL-IP&quot;}}' -n core
</code></pre>
<p>if there are some nested or complex changes, you can use also <code>JSON</code> file as well.</p>
<p><a href="https://jamesdefabia.github.io/docs/user-guide/kubectl/kubectl_patch/" rel="nofollow noreferrer">kubectl_patch-json</a></p>
