<p>I've an existing deployment in my Kubernetes cluster. I want to read its deployment.yaml file from Kubernetes environment using fabric8 client.Functionality similar to this command - kubectl get deploy deploymentname -o yaml.
Please help me to get its fabric8 Java client equivalent.</p>
<p>Objective : I want to get deployment.yaml for a resource and save it with me , perform some experiments in the Kubernetes environment and after the experiments done,I want to revert back to previous deployment. So I need to have deployment.yaml handy to roll back the operation.
Please help.</p>
<p>Thanks,
Sapna</p>

Sapna Girdhani
<p>You can get the yaml representation of an object with the <a href="https://github.com/fabric8io/kubernetes-client/blob/master/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/Serialization.java#L140" rel="nofollow noreferrer">Serialization#asYaml</a> method.</p>
<p>For example:</p>
<pre><code>System.out.println(Serialization.asYaml(client.apps().deployments().inNamespace(&quot;abc&quot;).withName(&quot;ms1&quot;).get()));
</code></pre>
