### What happened?

Some third party controllers may report the Container Status for containers that are not defined in a pod spec. This may lead to inconsistencies in codebase and ideally needs to be blocked.

We see this with the https://github.com/admiraltyio/admiralty/pull/206, but there may be more examples like this since k8s never checked for consistency of statuses to specs.

### What did you expect to happen?

As mentioned: https://github.com/kubernetes/kubernetes/pull/124906#pullrequestreview-2061200945 usages of container statuses needs to be reviewed and in most places we should start ignoring statuses for non-existing containers.

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

Update the Pod Status with the container status for the container that doesn't exist:

```json
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
            .....
},
"spec": {
  "containers": [],
  "initContainers": [
    {
      ....
      "name": "tester",
      ....
    },
    {
        ....
      "name": "init-proxy",
      ....
    }
  ],
  "nodeName": "foo",
},
"status": {
  "containerStatuses": [
    ....
  ],
  "initContainerStatuses": [
    {
      ....
      "imageID": "",
      "lastState": {},
      "name": "not-existing-container",
      "ready": false,
      "restartCount": 0,
      "state": {
        "waiting": {
          "reason": "PodInitializing"
        }
      }
    },
    {
        ......
      "imageID": "",
      "lastState": {},
      "name": "tester",
      "ready": false,
      "restartCount": 0,
      "state": {
        "waiting": {
          "reason": "PodInitializing"
        }
      }
    },
    {
      ....
      "imageID": "",
      "lastState": {},
      "name": "init-proxy",
      "ready": false,
      "restartCount": 0,
      "state": {
        "waiting": {
          "reason": "PodInitializing"
        }
      }
    }
  ],
  "phase": "Pending",
  "qosClass": "Burstable",
  "startTime": "2024-05-07T23:55:23Z"
}
```

### Anything else we need to know?

/sig node

### Kubernetes version

<details>

```console
$ kubectl version
# paste output here
```

</details>


### Cloud provider

<details>
N/A
</details>


### OS version

<details>
N/A
</details>


### Install tools

<details>
N/A
</details>


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

<details>
Any
</details>


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

<details>
N/A
</details>

Ignore and potentially prevent reporting container status for not-existing containers
This is a GitHub Issue
repo:kubernetes
owner:kubernetes
Title : Ignore and potentially prevent reporting container status for not-existing containers
Issue date:

--- start body ---
### What happened?

Some third party controllers may report the Container Status for containers that are not defined in a pod spec. This may lead to inconsistencies in codebase and ideally needs to be blocked.

We see this with the https://github.com/admiraltyio/admiralty/pull/206, but there may be more examples like this since k8s never checked for consistency of statuses to specs.

### What did you expect to happen?

As mentioned: https://github.com/kubernetes/kubernetes/pull/124906#pullrequestreview-2061200945 usages of container statuses needs to be reviewed and in most places we should start ignoring statuses for non-existing containers.

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

Update the Pod Status with the container status for the container that doesn't exist:

```json
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
            .....
},
"spec": {
  "containers": [],
  "initContainers": [
    {
      ....
      "name": "tester",
      ....
    },
    {
        ....
      "name": "init-proxy",
      ....
    }
  ],
  "nodeName": "foo",
},
"status": {
  "containerStatuses": [
    ....
  ],
  "initContainerStatuses": [
    {
      ....
      "imageID": "",
      "lastState": {},
      "name": "not-existing-container",
      "ready": false,
      "restartCount": 0,
      "state": {
        "waiting": {
          "reason": "PodInitializing"
        }
      }
    },
    {
        ......
      "imageID": "",
      "lastState": {},
      "name": "tester",
      "ready": false,
      "restartCount": 0,
      "state": {
        "waiting": {
          "reason": "PodInitializing"
        }
      }
    },
    {
      ....
      "imageID": "",
      "lastState": {},
      "name": "init-proxy",
      "ready": false,
      "restartCount": 0,
      "state": {
        "waiting": {
          "reason": "PodInitializing"
        }
      }
    }
  ],
  "phase": "Pending",
  "qosClass": "Burstable",
  "startTime": "2024-05-07T23:55:23Z"
}
```

### Anything else we need to know?

/sig node

### Kubernetes version

<details>

```console
$ kubectl version
# paste output here
```

</details>


### Cloud provider

<details>
N/A
</details>


### OS version

<details>
N/A
</details>


### Install tools

<details>
N/A
</details>


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

<details>
Any
</details>


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

<details>
N/A
</details>

--- end body ---
