Error: "OOMKilled" causes vMop pods to enter CrashLoopBackOff state in vSphere Kubernetes Service
search cancel

Error: "OOMKilled" causes vMop pods to enter CrashLoopBackOff state in vSphere Kubernetes Service

book

Article ID: 423941

calendar_today

Updated On:

Products

VMware vSphere Kubernetes Service

Issue/Introduction

The vmware-system-vmop-controller-manager (vmop) pods enter a CrashLoopBackOff state. Running kubectl describe on the affected vMop pod displays the last state as Terminated with Reason: OOMKilled.

kubectl describe pod vmware-system-vmop-controller-manager-######-#### -n vmware-system-vmop

Name:             vmware-system-vmop-controller-manager-######-#####
Namespace:        vmware-system-vmop
Priority:         0
Service Account:  default
Node:             <Node_ID>/##.##.##.98
Start Time:       <Date><Time>
Labels:           control-plane=controller-manager
                  controller-tools.k8s.io=1.0
                  name=vmoperator-controller-manager
                  pod-template-hash=########
Annotations:      prometheus.io/port: 9848
                  prometheus.io/scheme: https
                  prometheus.io/scrape: true
Status:           Running
IP:               ##.##.##.98
IPs:
  IP:           ##.##.##.98
Controlled By:  ReplicaSet/vmware-system-vmop-controller-manager-##########
Containers:
  manager:
    Container ID:  containerd://#########################################################
    Image:         localhost:5000/vmware/vmop:0.1.0-8ceb511-1.8.6-010e27a-24571392
    Image ID:      localhost:5000/vmware/vmop@sha256:####################################
    Ports:         9878/TCP, 9445/TCP
    Host Ports:    9878/TCP, 9445/TCP
    Command:
      /manager
    Args:
      --metrics-addr=127.0.0.1:8083
    State:          Running
      Started:      <Date><Time>
    Last State:     Terminated
      Reason:       OOMKilled
      Exit Code:    137
      Started:      <Date><Time>
      Finished:     <Date><Time>
    Ready:          True
    Restart Count:  4
    Limits:
      cpu:     750m
      memory:  550Mi
    Requests:
      cpu:      100m
      memory:   75Mi

Environment

VMware vSphere Kubernetes Service

Cause

This issue occurs when manually associating the Kubernetes Service Content Library with individual vSphere Namespaces via the "VM Service" card, while the same library already exists configured at the Supervisor Cluster level.

When a Content Library associates directly with a namespace, the VM Operator (vMop) attempts to create VirtualMachineImage (VMI) Custom Resources for every image in that library within every namespace. The accumulation of metadata from these redundant Custom Resources across numerous namespaces exceeds the memory limits of the vmware-system-vmop-controller-manager pod, resulting in an OOMKilled (Out of Memory) crash.

Notes:

  • The Kubernetes Service ClusterContentLibrary set at the Supervisor level will automatically propagate to all namespaces.
  • The VM Service card must only contain content libraries for custom/standalone VM images. If the namespace only uses standard VKS images, it requires 0 associated libraries.

Validation

  1. Confirm the redundant association by listing content libraries across namespaces.

    kubectl get contentlibraries -A

    NAMESPACE      NAME VSPHERENAME       VSPHERENAME                          TYPE         WRITABLE   ALLOWIMPORT   STORAGETYPE   AGE
    namespace-01   cl-[library-id]        Kubernetes Service Content Library   Subscribed   false      false         Datastore     25h
    namespace-02   cl-[library-id]        Kubernetes Service Content Library   Subscribed   false      false         Datastore     369d
    namespace-03   cl-[library-id]        Kubernetes Service Content Library   Subscribed   false      false         Datastore     370d


    namespace-09   cl-[library-id]        Kubernetes Service Content Library   Subscribed   false      false         Datastore     17d
    namespace-10   cl-[library-id]        Kubernetes Service Content Library   Subscribed   false      false         Datastore     17d
    namespace-11   cl-[library-id]        Kubernetes Service Content Library   Subscribed   false      false         Datastore     62d
    namespace-12   cl-[library-id]        Kubernetes Service Content Library   Subscribed   false      false         Datastore     152d
    namespace-13   cl-[library-id]        Kubernetes Service Content Library   Subscribed   false      false         Datastore     152d

  2. The same cl-[library-id] library typically appears associated with multiple namespaces (namespace-01 to namespace-13). Because each namespace associates a ContentLibrary to it, this results in several virtualMachineImages (vmi) being created in each namespace.

  3. These Custom Resources contain a large amount of metadata that causes the vMop pod to experience OOMKilled.

    kubectl get vmi -A  | wc -l

    3000

  4. Additionally, check the VM Service tile in the vCenter UI (Workload Management > Namespace > VM Service) to confirm if the "Kubernetes Service Content Library" associates manually with each namespace.

Resolution

Remove the redundant Content Library associations from the individual vSphere Namespaces. The Supervisor-level library continues to provide the necessary images.

Notes:

  • If the namespace is not used for standalone VMs and lacks custom images, the VM Service card requires 0 Associated Content Libraries.
  • The vSphere Kubernetes Service Content Library operates to create VKS cluster nodes in all namespaces. Adding the Content Library on the VM Service card for all Cluster namespaces is unnecessary. See Associate the TKR Content Library with the TKG Service.

Phase 1: Confirm VirtualMachineImages

Confirm that the VirtualMachineImages (vmi) used to create the VKS cluster VirtualMachine (VM) exist on clustercontentlibraries (ccl). If not, the cluster nodes recreate.

  1. Run the following command to retrieve the vmi used to create each VirtualMachine (VM) in the namespace.

    kubectl get vm -n <namespace> -o custom-columns="NAMESPACE:.metadata.namespace,VM_NAME:.metadata.name,IMAGE_NAME:.spec.imageName"

    Example:

    kubectl get vm -n cluster-ns -o custom-columns="NAMESPACE:.metadata.namespace,VM_NAME:.metadata.name,IMAGE_NAME:.spec.imageName"

    NAMESPACE    VM_NAME                                 IMAGE_NAME
    <namespace>  cluster-node-pool-########              vmi-Id
    <namespace>  cluster-#####-####                      vmi-Id

  2. Run the following command to confirm the VirtualMachineImages (vmi) ID retrieved from step 1 exists as clustervirtualmachineimages (cvmi).

    kubectl get cvmi <vmi-Id>

    Example:

    kubectl get cvmi vmi-Id

    NAME                    DISPLAY NAME                                                       IMAGE VERSION                 OS NAME               OS VERSION   HARDWARE VERSION
    vmi-Id                  ob-########-photon-5-amd64-vmi-k8s-v1.30.1---vmware.1-fips-tkg.5   v1.30.1+vmware.1-fips-tkg.5   vmwarePhoton64Guest                17

  3. Confirm the vmi object exists in the namespace.

kubectl get vmi vmi-Id -n <namespace>

NAME                    DISPLAY NAME                                                       IMAGE VERSION                 OS NAME               OS VERSION   HARDWARE VERSION   CAPABILITIES
vmi-Id                  ob-########-photon-5-amd64-vmi-k8s-v1.30.1---vmware.1-fips-tkg.5   v1.30.1+vmware.1-fips-tkg.5   vmwarePhoton64Guest                17

Phase 2: Confirm Content Library Name Match

Confirm that the Content Library name associated with the "VM Service" card for each VKS Cluster Namespace matches the ClusterContentLibrary.

  1. To check the ClusterContentLibrary: Log in to vCenter Server > Workload Management > Supervisors > Click the Supervisor Cluster Name > Configure > General > Kubernetes Service > Content Library.

  2. To check the Content Library name on the Namespaces "VM Service" card: From the vSphere Client home menu, select Workload Management > Click the Namespaces tab > Select the namespace > Summary > Click Manage Content Libraries.

Phase 3: Remove Content Library Association

Remove the content library from the Namespaces under the "VM service" card.

  1. From the vSphere Client home menu, select Workload Management > Click the Namespaces tab > Select the namespace > Summary > Click Manage Content Libraries.

  2. Uncheck the box corresponding to the Content Library Name (e.g., Kubernetes Service Content Library) and click OK to save changes.

Phase 4: Confirm vMop Pod Status

Confirm that the vmware-system-vmop-controller-manager (vmop) pods operate in a running state. The VirtualMachineImages (vmi) objects under the Namespaces fail to remove if the vMop pods are not running.

  1. Increase vmop memory (if needed): How to increase the memory in the VM Operator pod when it is crashing due to insufficient resources at scale

  2. If the vMop pods still enter CrashLoopBackOff status with an OOMKilled error after increasing the vmop container memory, it indicates the number of VirtualMachineImages (vmi) under all Namespaces remains extremely high. Perform the following to resolve:

    1. Remove the content library from other Namespaces under the VM service card (Phase 3).

    2. Manually delete VirtualMachineImages (vmi) objects under the Namespaces disconnected from the Content Library:

      kubectl delete vmi --all -n <cluster-namespaces>

    3. Once the total count of VirtualMachineImages (vmi) lowers, the vmop pods enter a running state and handle the deletion of the remaining VirtualMachineImages (vmi) objects.
  3. Run the following command to confirm no more VirtualMachineImages (vmi) objects exist under the cluster namespace:

    kubectl get vmi -n <cluster-namespace>

    Example:

    kubectl get vmi -n <namespace>
    No resources found in <namespace> namespace.

  4. Confirm no cluster scaling operations exist on the cluster node by checking the cluster kubeadmcontrolplane and machinedeployment objects:

    kubectl get kcp,md -n <cluster-namespace>

Additional Information

For additional technical context, review the following knowledge base articles: