<p>In Kubernetes how to get events from from a pod and deployment redirected to a file? is this can be done by jsonpath or will have to use linux/unix commands?
<a href="https://i.stack.imgur.com/s8qiY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/s8qiY.png" alt="enter image description here" /></a></p>

user190245
<p>To get the events you can use <code>kubectl get events</code> and <code>grep</code> for the resource type.</p>
<pre><code>kubectl get events |grep 'pod/&lt;pod-name&gt;'
</code></pre>
<p>Or (complex to me)</p>
<p>if you want to use <code>jsonpath</code>, I have just build the two columns, you can built as much you need.</p>
<pre><code> kubectl get events -o jsonpath='{range .items[*]}{.firstTimestamp}{&quot;\t&quot;}{.reason}{&quot;\n&quot;}{end}'
&lt;nil&gt;   Scheduled
2021-06-16T21:47:44Z    Pulling
2021-06-16T21:47:45Z    Pulled
2021-06-16T21:47:45Z    Created
2021-06-16T21:47:46Z    Started
2021-06-16T21:47:44Z    MissingClusterDNS
2021-06-16T21:48:46Z    Killing
&lt;nil&gt;   Scheduled
2021-06-16T21:49:02Z    Pulling
2021-06-16T21:49:03Z    Pulled
2021-06-16T21:49:04Z    Created
2021-06-16T21:49:04Z    Started
2021-06-08T20:27:17Z    MissingClusterDNS
2021-06-08T20:27:22Z    MissingClusterDNS
2021-06-08T20:27:17Z    MissingClusterDNS
2021-06-16T21:49:02Z    MissingClusterDNS
2021-06-08T20:27:20Z    MissingClusterDNS
</code></pre>
<p>Example, I have added 3rd column <code>message</code> in below command:</p>
<pre><code>kubectl get events -o jsonpath='{range .items[*]}{.firstTimestamp}{&quot;\t&quot;}{.reason}{&quot;\t&quot;}{.message}{&quot;\n&quot;}{end}'
</code></pre>
<p>But if you are in <code>shell</code> environement, <code>grep</code>-ing is simpler.</p>
