<p>I need to run powershell as an container in kubernetes</p>
<p>I am using following deployment file <code>sample.yaml</code></p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: powershell
spec:
  containers:
  - name: powershell
    image: mcr.microsoft.com/powershell:latest
</code></pre>
<p>When I run <code>kubectl apply -f sample.yaml</code></p>
<p>I get the following error on <code>kubectl get pods</code></p>
<pre><code>powershell        0/1     CrashLoopBackOff   3 (50s ago)   92s
</code></pre>
<p>I did check the log <code>kubectl logs powershell</code></p>
<pre><code>PowerShell 7.2.6
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

PS /&gt; ←[?1h
</code></pre>
<p>But when i run same image as a docker container with following command its working</p>
<pre><code>docker run --rm -it mcr.microsoft.com/powershell:latest
</code></pre>

NRaj
<p>If you want to keep a container for running, you should write like this yaml..</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: powershell
spec:
  containers:
  - name: powershell
    image: mcr.microsoft.com/powershell:latest
    command: [&quot;pwsh&quot;]
    args: [&quot;-Command&quot;, &quot;Start-Sleep&quot;, &quot;3600&quot;]
</code></pre>
<pre><code>
[root@master1 ~]# kubectl get pod powershell
NAME         READY   STATUS    RESTARTS   AGE
powershell   1/1     Running   0          3m32s
[root@master1 ~]# kubectl exec -it powershell -- pwsh
PowerShell 7.2.6
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

PS /&gt; date
Thu Oct 13 12:50:24 PM UTC 2022
PS /&gt;

</code></pre>
