<p>I have the following Parameters in a shell script</p>

<pre><code>#!/bin/bash
DOCKER_REGISTRY=gcr.io
GCP_PROJECT=sample
ELASTICSEARCH_VERSION=:7.3.1
</code></pre>

<p>When i run this command the parameters are all replaced correctly </p>

<pre><code>ELASTICSEARCH_IMAGE=$DOCKER_REGISTRY/$GCP_PROJECT/elasticsearch$ELASTICSEARCH_VERSION
echo $ELASTICSEARCH_IMAGE
gcr.io/sample/elasticsearch:7.3.1
</code></pre>

<p>I need to replace the ELASTICSEARCH_IMAGE on a kubernetes deployment file</p>

<blockquote>
<pre><code>  containers:
    - image: {{ELASTICSEARCH}}                                                
      name: elasticsearch
</code></pre>
</blockquote>

<p>So when i run the below command it is not replaced. The issue is because of "/". I tried various sed command but not able to resolve it </p>

<p>YAML_CONTENT=<code>cat "app-search-application.yaml.template" | sed "s/{{ELASTICSEARCH_IMAGE}}/$ELASTICSEARCH_IMAGE/g"</code></p>

<p>My intension is to dynamically change the image on kubernetes yaml file with the sed command.</p>

klee
<p>The <code>s</code> command in <code>sed</code> can have different delimiters, if your pattern has <code>/</code> use something else in <code>s</code> command</p>

<pre><code>ELASTICSEARCH_IMAGE='gcr.io/sample/elasticsearch:7.3.1'
$ echo "

      containers:
        - image: {{ELASTICSEARCH}}                                                
          name: elasticsearch

" | sed "s|{{ELASTICSEARCH}}|$ELASTICSEARCH_IMAGE|"


      containers:
        - image: gcr.io/sample/elasticsearch:7.3.1                                                
          name: elasticsearch
</code></pre>
