<p>I am new to Kuberentes and am trying to deploying a simple webapp in it, currently I am building an image with all the dependencies and my application bundled in , uploading the image to repo and then deploying it in the pod, but the issue with this approach is that if I just want to edit my application code (let's say to add a print statement) I would need again build the image , upload it to repo and deploy it in K8.</p>
<p>Can I use the PVC to host my application code and refer it in my init container , is this a standard practice ?</p>

av abhishiek
<p>Technically, you can. Practically, as far as I know, it is never a standard practice.</p>
<ul>
<li><p>Majority of PVC solutions are <code>ReadWriteOnce</code>. So it would mean that you can't use scaling feature - <code>replicas</code>. You can't duplicate code easily across pods.</p>
</li>
<li><p>PVC is usually used for dynamic data: files or database - you separate code and configuration from data using PVC</p>
</li>
<li><p>Some images detect when there is nothing in PVC so app can be reinitialised from scratch, for example: prometheus, mysql and so on</p>
</li>
<li><p>PVC could be slower than data in Docker image (clustering mechanisms behind PVC)</p>
</li>
<li><p>If you have your code in PVC, you can't use anything app code related in Docker build phase (some testing, libraries resolution, etc.)</p>
</li>
<li><p>Pipeline may move away from standards (apps are usually built and deployed in a pipeline in Kubernetes)</p>
</li>
<li><p>and other consistency issues could occur</p>
</li>
</ul>
<p>In case you need to edit code in development environment, other methods are used:</p>
<ul>
<li><p>Locally, you can mount your local app folder to folder on Docker container, for instance it's <code>volumes</code> feature in Docker</p>
</li>
<li><p>Use minikube to recreate all containers locally for convenient development</p>
</li>
<li><p>Use tools to attach to containers such as <a href="https://code.visualstudio.com/docs/remote/attach-container" rel="nofollow noreferrer">https://code.visualstudio.com/docs/remote/attach-container</a></p>
</li>
</ul>
<p>There should be a lot more methods, but you haven't mentioned the reason why building image with code is an issue.</p>
