This article explores configuring resource requests and limits for the CartsDB deployment in the Socks Shop application to ensure efficient resource usage.
In this article, we explore how to configure resource requests and limits for the CartsDB deployment—an essential component of the Socks Shop application. By setting specific CPU and memory values, you ensure efficient resource usage and guarantee that your application performs reliably under different workloads.
The following YAML configuration sets the resource requests and limits for the CartsDB deployment. In this example, the container is allocated 64Mi of memory and 250m of CPU as requests, with a memory limit of 128Mi:
All other configuration details remain unchanged except for the resource definitions. Additional settings such as environment variables, volume mounts, and node selectors are specified as shown below:
To update the deployment, open your OpenShift platform, navigate to Workloads > Deployments, and click on “Create New Deployment.” Switch to the YAML view and paste the configuration above.
Extended Configuration with Additional Environment Variables
For a more detailed configuration, include additional environment variables as demonstrated in the snippet below. This enhanced setup improves the management of login credentials and database settings:
After clicking “Create,” allow a few moments for the deployment to initialize. Once your pod is running, you can verify the applied resource settings by examining the pod’s YAML.
Scroll down in the pod YAML to locate the container resources section. It should include settings that confirm the memory limits and CPU/memory requests, similar to the snippet below:
Managing Resource Allocation in Larger Environments
In environments with many deployments, adjusting resource values individually for each deployment can become time-consuming. Resource quotas provide an efficient way to manage resource allocation across multiple deployments. In our next section, we will dive into how resource quotas can simplify this process.For further reading, consider exploring additional resources on Kubernetes Documentation and OpenShift.