Kubectl Export is deprecated . Any alternative
If you want to use YAML input / output, you can use yq.
This did the trick for me, add or remove filters as appropriate for you:
kubectl get secret "my_secret" -n "my_namespace" --context "my_context" -o yaml \
| yq d - 'metadata.resourceVersion' \
| yq d - 'metadata.uid' \
| yq d - 'metadata.annotations' \
| yq d - 'metadata.creationTimestamp' \
| yq d - 'metadata.selfLink'
Using JQ does the trick.
kubectl get secret <secretname> -ojson | jq 'del(.metadata.namespace,.metadata.resourceVersion,.metadata.uid) | .metadata.creationTimestamp=null'
produces exactly the same JSON as
kubectl get secret <secretname> -ojson --export