SAP-archive / karydia

Kubernetes Security Walnut
Other
77 stars 10 forks source link

[BUGFIX] Allow Deletion of Not Mutated Pods #252

Closed Neumann-Nils closed 4 years ago

Neumann-Nils commented 4 years ago

Description

If a pod is running in your cluster that has not been mutated yet (e.g. the security context is not set) and you want to delete it, it get stuck in the state Terminating. This due to Karydia trying to change the pod definition and denying the UPDATE event (which is created with the DELETE event).

Thus, this PR introduces a check that ignores pods that are in the state Terminating in the admission controller. I introduced a function from the Kubernetes internals to "calculate" the correct state of the pod, as the phase of the pod is still ´Terminating`, even though it is actually starting to terminate.

This function reliable detects a terminating pod. However, this internal state change (depending on the containers in the pod) may take a few seconds and one can experience a delay in the deletion process. However, the deletion will always

[Fixes #250]

Checklist

Before submitting this PR, please make sure: