### Install Goldilocks Project Source: https://github.com/fairwindsops/goldilocks/blob/master/docs/contributing/guide.md Use 'go get' to install the Goldilocks project. Ensure you have a Go environment set up. ```bash go get github.com/fairwindsops/goldilocks ``` -------------------------------- ### Setup Kind Development Environment Source: https://github.com/fairwindsops/goldilocks/blob/master/docs/contributing/guide.md Execute this script to set up a Kind cluster, deploy a demo application, install VPA, and deploy Goldilocks. This is useful for local development. ```bash ./setup.sh ``` -------------------------------- ### Install Pre-commit Hooks Source: https://github.com/fairwindsops/goldilocks/blob/master/docs/contributing/guide.md Run this command to install pre-commit hooks for the repository. This helps ensure code quality before commits. ```bash pre-commit install ``` -------------------------------- ### Install Goldilocks using Helm Source: https://github.com/fairwindsops/goldilocks/blob/master/docs/installation.md This is the preferred method for installing Goldilocks. It involves adding the Fairwinds Helm repository, creating a namespace, and then installing the Goldilocks chart. ```bash helm repo add fairwinds-stable https://charts.fairwinds.com/stable kubectl create namespace goldilocks Helm v2: helm install --name goldilocks --namespace goldilocks fairwinds-stable/goldilocks Helm v3: helm install goldilocks --namespace goldilocks fairwinds-stable/goldilocks ``` -------------------------------- ### Install Goldilocks using Manifests Source: https://github.com/fairwindsops/goldilocks/blob/master/docs/installation.md This method involves cloning the Goldilocks repository, creating a namespace, and applying the controller and dashboard manifests. ```bash git clone https://github.com/FairwindsOps/goldilocks.git cd goldilocks kubectl create namespace goldilocks kubectl -n goldilocks apply -f hack/manifests/controller kubectl -n goldilocks apply -f hack/manifests/dashboard ``` -------------------------------- ### Install Goldilocks CLI Source: https://github.com/fairwindsops/goldilocks/blob/master/docs/advanced.md Installs the Goldilocks CLI on Linux by downloading a release archive and moving the binary to the system's PATH. ```bash curl -L "https://github.com/FairwindsOps/goldilocks/releases/download/v4.0.0/goldilocks_4.0.0_linux_amd64.tar.gz" > goldilocks.tar.gz tar -xvf goldilocks.tar.gz sudo mv goldilocks /usr/local/bin/ ``` -------------------------------- ### Run Goldilocks Dashboard Locally Source: https://github.com/fairwindsops/goldilocks/blob/master/docs/contributing/guide.md Start the Goldilocks dashboard locally. This requires a working KUBECONFIG and access to a Kubernetes cluster. ```bash go run main.go dashboard ``` -------------------------------- ### Tidy and Build Dependencies Source: https://github.com/fairwindsops/goldilocks/blob/master/docs/contributing/guide.md Run 'make tidy' or 'make build' in the Goldilocks directory to download dependencies and build the project. ```bash make tidy ``` ```bash make build ``` -------------------------------- ### Goldilocks CLI Help Source: https://github.com/fairwindsops/goldilocks/blob/master/docs/advanced.md Displays the available commands and flags for the Goldilocks CLI. This tool is not recommended for general use. ```bash A tool for analysis of kubernetes workload resource usage. Usage: goldilocks [flags] goldilocks [command] Available Commands: completion generate the autocompletion script for the specified shell controller Run goldilocks as a controller inside a kubernetes cluster. create-vpas Create VPAs dashboard Run the goldilocks dashboard that will show recommendations. delete-vpas Delete VPAs help Help about any command summary Generate a summary of vpa recommendations. version Prints the current version of the tool. Flags: -h, --help help for goldilocks --kubeconfig string Kubeconfig location. [KUBECONFIG] (default "$HOME/.kube/config") -v, --v Level number for the log level verbosity Use "goldilocks [command] --help" for more information about a command. ``` -------------------------------- ### VPA Recommendation Structure Source: https://github.com/fairwindsops/goldilocks/blob/master/docs/faq.md This YAML structure shows the recommendation output from the VPA, including container name and calculated bounds for CPU and memory. ```yaml recommendation: containerRecommendations: - containerName: basic-demo lowerBound: cpu: 10m memory: "26214400" target: cpu: 11m memory: "26214400" uncappedTarget: cpu: 11m memory: "26214400" upperBound: cpu: 12m memory: "26214400" ``` -------------------------------- ### Enable Goldilocks Namespace Label Source: https://github.com/fairwindsops/goldilocks/blob/master/docs/installation.md Apply this label to a namespace to enable Goldilocks to monitor workloads within it. This allows VPA objects to be created for the namespace. ```bash kubectl label ns goldilocks goldilocks.fairwinds.com/enabled=true ``` -------------------------------- ### Use Full Version Tags Source: https://github.com/fairwindsops/goldilocks/blob/master/README.md When deploying Goldilocks, use full version tags (e.g., v..) instead of floating tags like 'v4', 'v4.14', or 'latest' to ensure predictable deployments. ```dockerfile us-docker.pkg.dev/fairwinds-ops/oss/goldilocks:v.. ``` -------------------------------- ### VPA Resource Policy Configuration Source: https://github.com/fairwindsops/goldilocks/blob/master/docs/advanced.md Defines minimum and maximum allowed CPU and memory for specific containers within a VPA. Use this to enforce resource constraints per container. ```yaml apiVersion: autoscaling.k8s.io/v1 kind: VerticalPodAutoscaler metadata: name: nginx-vpa spec: targetRef: apiVersion: "apps/v1" kind: Deployment name: nginx updatePolicy: updateMode: "On" resourcePolicy: containerPolicies: - containerName: "nginx" minAllowed: cpu: "250m" memory: "100Mi" maxAllowed: cpu: "2000m" memory: "2048Mi" - containerName: "istio-proxy" mode: "Off" ``` -------------------------------- ### Run End-to-End Tests Source: https://github.com/fairwindsops/goldilocks/blob/master/docs/contributing/guide.md Execute the end-to-end tests for Goldilocks. This requires Venom and a Kind cluster. ```bash make e2e-test ``` -------------------------------- ### Enable VPA on GKE Standard Clusters Source: https://github.com/fairwindsops/goldilocks/blob/master/docs/installation.md Use this command to enable Vertical Pod Autoscaler on GKE Standard clusters. Note that this method does not support Prometheus as a data backend. ```bash gcloud container clusters update [CLUSTER-NAME] --enable-vertical-pod-autoscaling {--region [REGION-NAME] | --zone [ZONE-NAME]} ``` -------------------------------- ### VPA Recommender Actions Source: https://github.com/fairwindsops/goldilocks/blob/master/docs/faq.md The VPA recommender performs a loop of actions to update its model and generate recommendations. This process involves reading historical usage from Prometheus and updating VPA resources. ```text update model with recent information on resources (using listers based on watch), update model with fresh usage samples from Metrics API, compute new recommendation for each VPA, put any changed recommendations into the VPA resources. ``` -------------------------------- ### Label Namespace for Goldilocks Source: https://github.com/fairwindsops/goldilocks/blob/master/docs/faq.md To enable Goldilocks for a specific namespace, apply this label using kubectl. ```bash kubectl label ns goldilocks.fairwinds.com/enabled=true ``` -------------------------------- ### Check Metrics API Service Availability (Issue) Source: https://github.com/fairwindsops/goldilocks/blob/master/docs/faq.md This `kubectl` command output indicates an issue with the metrics API service, showing 'False (MissingEndpoints)' for availability. ```bash ▶ kubectl get apiservice v1beta1.metrics.k8s.io NAME SERVICE AVAILABLE AGE v1beta1.metrics.k8s.io metrics-server/metrics-server False (MissingEndpoints) 7s ``` -------------------------------- ### VPA Resource Policy Annotation Source: https://github.com/fairwindsops/goldilocks/blob/master/docs/advanced.md Applies a JSON-formatted resource policy to a namespace via an annotation. This allows for dynamic configuration without modifying VPA objects directly. ```yaml annotations: goldilocks.fairwinds.com/vpa-resource-policy: > { "containerPolicies": [ { "containerName": "nginx", "minAllowed": { "cpu": "250m", "memory": "100Mi" }, "maxAllowed": { "cpu": "2000m", "memory": "2048Mi" } }, { "containerName": "istio-proxy", "mode": "Off" } ] } ``` -------------------------------- ### Pin Image by Digest Source: https://github.com/fairwindsops/goldilocks/blob/master/README.md For immutable image deployment, pin your Goldilocks deployment to a specific image digest. This ensures that you are always running the exact same image version. ```dockerfile us-docker.pkg.dev/fairwinds-ops/oss/goldilocks@sha256: ``` -------------------------------- ### Check Metrics API Service Availability (Healthy) Source: https://github.com/fairwindsops/goldilocks/blob/master/docs/faq.md This `kubectl` command output shows a healthy metrics API service, with 'True' for availability. ```bash ▶ kubectl get apiservice v1beta1.metrics.k8s.io NAME SERVICE AVAILABLE AGE v1beta1.metrics.k8s.io metrics-server/metrics-server True 36s ``` -------------------------------- ### Exclude Containers from Recommendations Source: https://github.com/fairwindsops/goldilocks/blob/master/docs/advanced.md Applies a label to a workload to exclude specific containers from Goldilocks recommendations. Useful for sidecars like Linkerd or Istio. ```bash kubectl label deployment myapp goldilocks.fairwinds.com/exclude-containers=linkerd-proxy,istio-proxy ``` -------------------------------- ### Control VPA Update Mode via Annotation Source: https://github.com/fairwindsops/goldilocks/blob/master/docs/advanced.md Sets a specific VPA update mode for a workload using a namespace annotation. This overrides any default or namespace-level settings. ```yaml goldilocks.fairwinds.com/vpa-update-mode= ``` -------------------------------- ### Update Image Registry Source: https://github.com/fairwindsops/goldilocks/blob/master/README.md When migrating to a new registry, update your image references from the old quay.io path to the new us-docker.pkg.dev path. Ensure you use the correct tag or digest for immutable images. ```diff - quay.io/fairwinds/goldilocks: + us-docker.pkg.dev/fairwinds-ops/oss/goldilocks: ``` -------------------------------- ### Set Goldilocks VPA Update Mode Source: https://github.com/fairwindsops/goldilocks/blob/master/docs/advanced.md Labels a Kubernetes namespace to set the VPA update mode to 'auto'. This enables automatic scaling for workloads managed by Goldilocks in that namespace. Use with caution as it's an advanced feature. ```bash kubectl label ns goldilocks goldilocks.fairwinds.com/vpa-update-mode="auto" ``` -------------------------------- ### Port Forward Goldilocks Dashboard Source: https://github.com/fairwindsops/goldilocks/blob/master/docs/installation.md Access the Goldilocks dashboard by port-forwarding the service. After running this command, open your browser to http://localhost:8080. ```bash kubectl -n goldilocks port-forward svc/goldilocks-dashboard 8080:80 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.