What is a Goldilocks?
Goldilocks is an Open Source tool by Fairwinds. And Goldilocks provides us a dashboard that gives us recommendations on how to set our resource requests. It is a utility that can help us to identify a starting point for resource requests and limits. It gives us a Right-size to our Kubernetes Deployments by comparing memory and CPU settings against actual usage.
Goldilocks doesn’t recommend resource requests/limits by itself. It utilizes a Kubernetes project called VPA
Vertical Pod Autoscaler(VPA)
Vertical Pod Autoscaler (VPA) is a component you install in your cluster. It increases and decreases container CPU and memory resource configuration to align cluster resource allotment with actual usage.
With VPA, there are two different types of resource configurations that we can manage on each container of a pod:
- Requests
- Limits
Component Of VPA
- The VPA Recommender
- The VPA Updater
- The VPA Admission Controller
We can utilize the VPA recommendation engine by running a controller in the cluster that’s gonna watch for the namespaces that are labeled with goldilocks.
fairwinds.com/enabled=true
. Within those enabled namespaces, we look at the deployments object and then, create an equivalent VPA object. That VPA is set with Mode:OFF
and it doesn’t even update the resource requests and limits. It just gives us a recommendation. This alone is sort of cool, but in order to view these recommendations, you would have to use kubectl to query each and every VPA object. For medium to large deployments, this can get very tedious. That’s where the dashboard comes in.


Goldilocks Dashboard provides us a visualization of VPA recommendations. Now we can see the services in a cluster and it is showing two types of recommendations, depending on the QoS class we desire for our deployments
Prerequisite for Goldilocks
1. Kubectl ( kubectl should be connected to the cluster you want to install VPA)
2. VPA
3. Metrics sever
Installation of Goldilocks
We can install Goldilocks using the Helm chart.
helm repo add fairwinds-stable https://charts.fairwinds.com/stable
helm install --name goldilocks --namespace goldilocks --set
installVPA=true fairwinds-stable/goldilocks
How Goldilocks work
vi vpa_demo.yaml
apiVersion: autoscaling.k8s.io/v1beta2
kind: VerticalPodAutoscaler
metadata:
name: demovpa
namespace: demo
spec:
targetRef:
apiVersion: "apps/v1"
kind: Deployment
name: vpa
updatePolicy:
updateMode: "Auto"
resourcePolicy:
containerPolicies:
- containerName: "vpa"
minAllowed:
cpu: "250m"
memory: "100Mi"
maxAllowed:
cpu: "500m"
memory: "600Mi"
kubectl apply -f vpa_demo.yaml
vi deployment_demo.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: deployment
namespace: demo
spec:
selector:
matchLabels:
app: deployment
replicas: 2
template:
metadata:
labels:
app: deployment
spec:
securityContext:
runAsNonRoot: true
runAsUser: 65534
containers:
- name: devops1
image: ubuntu:latest
resources:
requests:
cpu: 100m
memory: 50Mi
limits:
cpu: 511m
memory: 263Mi
command: ["/bin/sh"]
args:
- "-c"
- "while true; do timeout 0.5s yes >/dev/null; sleep 0.5s; done"
kubectl apply -f deployment_demo.yaml


For more informative blogs do check out our blog site https://blog.knoldus.com/category/devops/