<p>Is there a way to find the history of commands applied to the kubernetes cluster by kubectl?
For example, I want to know the last applied command was</p>
<pre><code>kubectl apply -f x.yaml
</code></pre>
<p>or</p>
<pre><code>kubectl apply -f y.yaml
</code></pre>

<p>You can use <code>kubectl apply view-last-applied</code> command to find the last applied configuration:</p>
<pre><code>➜  ~ kubectl apply view-last-applied --help

View the latest last-applied-configuration annotations by type/name or file.

 The default output will be printed to stdout in YAML format. One can use -o option to change output format.

Examples:
  # View the last-applied-configuration annotations by type/name in YAML.
  kubectl apply view-last-applied deployment/nginx
  
  # View the last-applied-configuration annotations by file in JSON
  kubectl apply view-last-applied -f deploy.yaml -o json

[...]    
</code></pre>
<p>To get the full history from the beginning of a cluster creation you should use <a href="https://kubernetes.io/docs/tasks/debug-application-cluster/audit/" rel="nofollow noreferrer">audit logs</a> as already mentioned in comments by @Jonas.</p>
<p>additionally, if you adopt gitops you could have all your cluster state under version control. It will allow you to trace back all the changes made to your cluster.</p>
