<p>So I already have a replicaset up and running and I want to add a deployment that'll manage that replicaset. I expect to go through this process repeatedly, so a programmatic solution is desired.</p>

<p>Right now my best solution is to run </p>

<pre><code>JSON=kubectl get replicasets myreplicaset -o json
IMAGE=...
REPLICAS=...
LABELS=...
kubectl run --image=$IMAGE --replicas=$REPLICAS --labels=$LABELS
</code></pre>

<p>where <code>...</code> is json-chopping code.</p>

<p>I'm worried about the reliability of this code. Perhaps I am forgetting important parameters in the replicaset. I definitely want to avoid accidentally altering the replicaset (or having the deployment scale it down and launch a new one). Is there a simpler way to achieve the same effect?</p>

Sebastian Oberhoff
<p>You can try it with this command: </p>

<p><code>sed  's/ReplicaSet/Deployment/g' /tmp/replicaset.yaml | sed -n '/status:/q;p'&gt; Deployment.yaml</code></p>

<p>it worked for me. but i would always recommend to apply deployments in the first place and not replicasets.</p>
