<p>I'm trying to run an interactive Pod (container) in Kubernetes that does not create a Job or Deployment and deletes itself after completing. </p>

<p>The purpose of the container is to give our developers an easy way to access our database, which doesn't have a public IP address.</p>

<p>Currently, we are using this command:</p>

<pre><code>kubectl run -i --tty proxy-pgclient --image=private-registry.com/pgclient --restart=Never --env="PGPASSWORD=foobar" -- psql -h dbhost.local -p 5432 -U pg_admin -W postgres
</code></pre>

<p>which works the first time you run it, however, after exiting the session if you try to run the above again to connect to the database again, we get:</p>

<pre><code>Error from server: jobs.extensions "proxy-pgclient" already exists
</code></pre>

<p>Forcing the developer to delete the job with:</p>

<pre><code>kubectl delete job proxy-pgclient
</code></pre>

<p>before they can run the command and connect again.</p>

<p>Is there any way of starting up an interactive container (Pod) in Kubernetes without creating a Job or Deployment object and having that container be deleted when the interactive session is closed?</p>

<p>Adding the "--rm" flag to the original command resulted in the Job (and Pod) being deleted at the completion of the interactive session, which is what I was after. The command then becomes:</p>

<pre><code>kubectl run -i --tty --rm proxy-pgclient --image=private-registry.com/pgclient --restart=Never --env="PGPASSWORD=foobar" -- psql -h dbhost.local -p 5432 -U pg_admin -W postgres
</code></pre>
