How to configure resource requests and limits for Sitecore Kubernetes solution


Description

Container-based Sitecore XP solution introduces requests and limits for CPU and memory (RAM) for each container. This article contains instructions on how to configure resource requests and limits for Sitecore XP Kubernetes (K8s) solutions.

Note that default requests and limits are set for a vanilla Sitecore XP solution so any customization may require an increase of limits and requests.

Solution

In order to check the existing Pod CPU and Memory load, execute the command:
kubectl top pods -n <namespace>

In order to check the existing requests and limits, execute the command:
kubectl get pods -o jsonpath="{range @.items[*]}{range @.spec.containers[*]}{@.name} - CPU:{@.resources.limits.cpu} Memory:{@.resources.limits.memory}{'\n'}{end}{end}" -n <namespace>

In order to update requests and (or) limits, update a value for CPU and (or) Memory in an appropriate yaml-file and apply changes. For example:
 	resources:
          requests:
            memory: 800Mi
            cpu: 1000m
          limits:
            memory: 3Gi
            cpu: 2000m