Repository: kubernetes
Issue: kubectl --server-side --dry-run=server - wrong output for converting client side applied manifest
Labels: kind/bug,sig/api-machinery,triage/accepted

### What happened?

When converting a client-side-applied manifest to a server side applied manifest `--dry-run=server` doesn't show the correct output.
It still shows client-side-applied fields, which will be removed, when running without `--dry-run=server`.

### What did you expect to happen?

running `--server-side` with `--dry-run=server` will generate the same manifest as running without `--dry-run=server`

### How can we reproduce it (as minimally and precisely as possible)?

1. Apply an example configmap with 3 keys with client-side-apply:

`kubectl apply -o yaml --show-managed-fields -f https://raw.githubusercontent.com/SebastianJ91/argocd-server-side-apply/main/3-configmap/configmap-original.yaml`

Output:

<details>

<pre>
apiVersion: v1
data:
  key1: key-original
  key2: key-original
  key3: key-original
kind: ConfigMap
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","data":{"key1":"key-original","key2":"key-original","key3":"key-original"},"kind":"ConfigMap","metadata":{"annotations":{},"name":"configmap","namespace":"default"}}
  creationTimestamp: "2024-06-20T10:55:40Z"
  managedFields:
  - apiVersion: v1
    fieldsType: FieldsV1
    fieldsV1:
      f:data:
        .: {}
        f:key1: {}
        f:key2: {}
        f:key3: {}
      f:metadata:
        f:annotations:
          .: {}
          f:kubectl.kubernetes.io/last-applied-configuration: {}
    manager: kubectl-client-side-apply
    operation: Update
    time: "2024-06-20T10:55:40Z"
  name: configmap
  namespace: default
  resourceVersion: "27130"
  uid: ca98d345-18e8-4fb4-a9a7-526d79756244
</pre>

</details>

2. Do a dry run for a server-side-apply for a diff manifest changing a single key of the configmap:
`kubectl apply -o yaml --server-side --dry-run=server --show-managed-fields --force-conflicts --field-manager=manager -f https://raw.githubusercontent.com/SebastianJ91/argocd-server-side-apply/main/3-configmap/configmap-patch.yaml`

Look at the resulting manifest, which is merged by both the manifests:
<details>

<pre>
apiVersion: v1
data:
  key1: key-original
  key2: key-patch
  key3: key-original
kind: ConfigMap
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","data":{"key1":"key-original","key2":"key-original","key3":"key-original"},"kind":"ConfigMap","metadata":{"annotations":{},"name":"configmap","namespace":"default"}}
  creationTimestamp: "2024-06-20T10:55:40Z"
  managedFields:
  - apiVersion: v1
    fieldsType: FieldsV1
    fieldsV1:
      f:data:
        f:key2: {}
    manager: manager
    operation: Apply
    time: "2024-06-20T10:59:45Z"
  - apiVersion: v1
    fieldsType: FieldsV1
    fieldsV1:
      f:data:
        .: {}
        f:key1: {}
        f:key3: {}
      f:metadata:
        f:annotations:
          .: {}
          f:kubectl.kubernetes.io/last-applied-configuration: {}
    manager: kubectl-client-side-apply
    operation: Update
    time: "2024-06-20T10:55:40Z"
  name: configmap
  namespace: default
  resourceVersion: "27130"
  uid: ca98d345-18e8-4fb4-a9a7-526d79756244

</pre>

</details>

3. Run the server-side-apply:
`kubectl apply -o yaml --server-side --show-managed-fields --force-conflicts --field-manager=manager -f https://raw.githubusercontent.com/SebastianJ91/argocd-server-side-apply/main/3-configmap/configmap-patch.yaml`

Look at the applied manifest, where the fields from client-side-apply are removed:
<details>

<pre>
apiVersion: v1
data:
  key2: key-patch
kind: ConfigMap
metadata:
  creationTimestamp: "2024-06-20T10:55:40Z"
  managedFields:
  - apiVersion: v1
    fieldsType: FieldsV1
    fieldsV1:
      f:data:
        f:key2: {}
    manager: manager
    operation: Apply
    time: "2024-06-20T11:03:56Z"
  name: configmap
  namespace: default
  resourceVersion: "28025"
  uid: ca98d345-18e8-4fb4-a9a7-526d79756244
</pre>

</details>


### Anything else we need to know?

Regarding #125403 kubectl is removing existing client-side-fields which are not part of a manifest for the same resource applied by server-side-apply.
This behavior was introduced since #112905 is fixed.

This should also be reflected, if -dry-run=server is used 

### Kubernetes version

<details>

```console
$ kubectl version
Client Version: v1.30.1
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.29.2
```

</details>


### Cloud provider

<details>
local Podman Desktop v1.10.3 - kind-cluster
</details>


### OS version

<details>

```console
# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here

# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
BuildNumber  Caption                   OSArchitecture  Version
22631        Microsoft Windows 11 Pro  64-bit          10.0.22631
```

</details>


### Install tools

_No response_

### Container runtime (CRI) and version (if applicable)

_No response_

### Related plugins (CNI, CSI, ...) and versions (if applicable)

_No response_