Ensure the admission control plugin NamespaceLifecycle is set

Error: The admission control plugin NamespaceLifecycle is not set

Bridgecrew Policy ID: BC_K8S_60
Checkov Check ID: CKV_K8S_83
Severity: LOW

The admission control plugin NamespaceLifecycle is not set

Description

Reject creating objects in a namespace that is undergoing termination.
Setting admission control policy to NamespaceLifecycle ensures that objects cannot be created in non-existent namespaces, and that namespaces undergoing termination are not used for creating the new objects. This is recommended to enforce the integrity of the namespace termination process and also for the availability of the newer objects.

Fix - Buildtime

Kubernetes

  • Kind: Pod
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    component: kube-apiserver
    tier: control-plane
  name: kube-apiserver
  namespace: kube-system
spec:
  containers:
  - command:
+   - kube-apiserver
+   - --enable-admission-plugins=NamespaceLifecycle
    image: gcr.io/google_containers/kube-apiserver-amd64:v1.6.0
    ...