Skip to content

Instantly share code, notes, and snippets.

@bcdurden
Last active September 22, 2022 19:27
Show Gist options
  • Select an option

  • Save bcdurden/2897c60c59bfd3305820589617defcb6 to your computer and use it in GitHub Desktop.

Select an option

Save bcdurden/2897c60c59bfd3305820589617defcb6 to your computer and use it in GitHub Desktop.
Remove CPU reservation in base Harvester

Removing the CPU reservtion in the Harvester/Longhorn default configuration

The values to change are guaranteed-engine-manager-cpu and guaranteed-replica-manager-cpu within the longhorn-default-setting ConfigMap in the longhorn-system namespace.

Manually Editing this is annoying because the value is an embedded yaml string within a ConfigMap. This can be done with a two-command copy-pasta. Ensure your kube-context is pointed at your harvester cluster. This may not work within the kubectl shell in the Harvester UI as I don't know if it has jq installed.

VALUES=$(kubectl get cm longhorn-default-setting -n longhorn-system -o jsonpath="{.data['default-setting\.yaml']}" | while read key value; do
if [ $key = "guaranteed-engine-manager-cpu:" ]; then 
    printf "$key 0\n" 
else 
    printf "$key $value\n"
fi
done; printf "guaranteed-replica-manager-cpu: 0\n")

jq --arg key "default-setting.yaml" --arg value "$VALUES" '.["data"][$key]=$value' <<< {} | kubectl patch cm longhorn-default-setting -n longhorn-system --patch-file=/dev/stdin

Rebooting

To make this change take, follow these instructions: TBD

This change will not survive a reboot of the Harvester Cluster as it is not permanent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment