What is the Difference Between kubectl attach and kubectl exec?
<p>Arunning Kubernetes pod may be reached through several different ways. Kubectl provides two methods for interacting with a Pod: <code>kubectl exec</code> and <code>kubectl attach</code></p>
<p><em>Before starting the article, I would like to point out that I created a container image for this article:</em><strong> </strong><a href="https://hub.docker.com/r/ailhan/control/tags" rel="noopener ugc nofollow" target="_blank"><strong>ailhan/control</strong></a></p>
<p><a href="https://gist.github.com/adililhan/aaf7fbb9ae8060f4ba474e0a60ea5fac" rel="noopener ugc nofollow" target="_blank"><em>Here is the source code</em></a></p>
<p>The container image has four different tags:</p>
<pre>
ailhan/control:latest -> Date time is printed every second
ailhan/control:datetime -> Date time is printed every second
ailhan/control:time -> Only time is printed every second
ailhan/control:hostname -> Container hostname is printed every second</pre>
<p>Each container image handles <strong>CTRL+C</strong> and <strong>CTRL+Z</strong> interrupts. It does not kill the container when you press CTRL+C. When you press CTRL+Z, the container will be exited.</p>
<p><a href="https://adil.medium.com/what-is-the-difference-between-kubectl-attach-and-kubectl-exec-148dab1e2aa3"><strong>Website</strong></a></p>