<p>I tried to create the POD using command
<code> kubectl  run  --generator=run-pod/v1 mypod--image=myimage:1 -it bash</code> and after successful pod creation it prompts for bash command in side container.</p>
<p>Is there anyway to achieve above command using YML file? I tried below YML but it does not go to bash directly after successful creation of POD. I had to manually write command <code>kubectl exec -it POD_NAME bash</code>. But want to avoid using exec command to bash my container. I want my YML to take me to my container after creation of POD. is there anyway to achieve this?</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: mypod
  namespace: mynamespcae
  labels:
    app: mypod
spec:
  containers:
  - args:
    - bash
    name: mypod
    image: myimage:1
    stdin: true
    stdinOnce: true
    tty: true
</code></pre>

<p>This is a community wiki answer. Feel free to expand it.</p>
<p>As already mentioned by David, it is not possible to go to bash directly after a Pod is created by only using the YAML syntax. You have to use a proper <code>kubectl</code> command like <code>kubectl exec</code> in order to <a href="https://kubernetes.io/docs/tasks/debug-application-cluster/get-shell-running-container/" rel="nofollow noreferrer">Get a Shell to a Running Container</a>.</p>
