Optimizing Kubernetes Resource Requests and Limits Using Goldilocks
Reference: https://goldilocks.docs.fairwinds.com/#how-can-this-help-with-my-resource-settings
Step 1: Launch an EC2 instance with Amazon Linux 2 AMI.This instance will act as a command center :).
Connect to it and Install kubectl,eksctl,helm,docker and git using following command:
sudo yum install -y git docker
sudo service docker start
sudo curl --silent --location -o /usr/local/bin/kubectl \
https://s3.us-west-2.amazonaws.com/amazon-eks/1.28.5/2024-01-04/bin/linux/amd64/kubectl
sudo chmod +x /usr/local/bin/kubectl
curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
sudo mv -v /tmp/eksctl /usr/local/bin
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
Follow https://edwinsiby.medium.com/installing-golang-on-an-aws-instance-97089f3be2de to install go.
Step 2: Follow https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html#getting-started-install-instructions to upgrade AWS CLI to v2.
Step 3: Now create a file named eks-cluster-config.yaml with following content:
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
name: my-cluster
region: us-east-1
version: '1.31'
iam:
withOIDC: true
availabilityZones: ['us-east-1a','us-east-1b','us-east-1c']
fargateProfiles:
- name: defaultfp
selectors:
- namespace: default
- namespace: kube-system
- namespace: goldilocks
cloudWatch:
clusterLogging:
enableTypes: ["*"]
and execute following command to create our EKS cluster:
eksctl create cluster -f eks-cluster-config.yaml
It will take around 20 minutes before cluster is ready.
Step 4: Verify you can connect to your cluster using following commands:
aws eks update-kubeconfig --region us-east-1 --name my-cluster
kubectl get nodes
Step 5: Install metric server using following command:
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.5.0/components.yaml
Step 6: Download helm chart using following command
git clone https://github.com/FairwindsOps/charts.git
cd ./charts/stable/vpa
Open Chart.yaml and remove dependency block.In values.yaml, set enabled: false for updater and admissionController
Install VPA using helm install vpa . command
Step 7: Install goldilocks using following command
helm repo add fairwinds-stable https://charts.fairwinds.com/stable
kubectl create namespace goldilocks
helm install goldilocks --namespace goldilocks fairwinds-stable/goldilocks
kubectl label ns goldilocks goldilocks.fairwinds.com/enabled=true
kubectl label ns default goldilocks.fairwinds.com/enabled=true
This will enable goldilocks for default and goldilocks namespace. Now port-forward the service using
kubectl -n goldilocks port-forward svc/goldilocks-dashboard 8080:80
and access http://127.0.0.1:8080/dashboard/goldilocks.
Select a namespace and a deployment and you can see the recommended settings