Customizing Default Settings

You may customize Longhorn’s default settings while installing or upgrading. You may specify, for example, Create Default Disk With Node Labeled and Default Data Path before starting Longhorn.

The default settings can be customized in the following ways:

NOTE: When using Longhorn Deployment YAML file or Helm for installation, updating or upgrading, if the value of a default setting is an empty string and valid, the default setting will be cleaned up in Longhorn. If not, Longhorn will ignore the invalid values and will not update the default values.

Installation

Using the Rancher UI

From the project view in Rancher, go to Apps && Marketplace > Longhorn > Install > Next > Edit Options > Longhorn Default Settings > Customize Default Settings and edit the settings before installing the app.

Using the Longhorn Deployment YAML File

  1. Download the longhorn repo:

    1. git clone https://github.com/longhorn/longhorn.git
  2. Modify the config map named longhorn-default-setting in the yaml file longhorn/deploy/longhorn.yaml.

    In the below example, users customize the default settings, backup-target, backup-target-credential-secret, and default-data-path. When the setting is absent or has a leading # symbol, the default setting will use the default value in Longhorn or the customized values previously configured.

    1. ---
    2. apiVersion: v1
    3. kind: ConfigMap
    4. metadata:
    5. name: longhorn-default-setting
    6. namespace: longhorn-system
    7. data:
    8. default-setting.yaml: |-
    9. backup-target: s3://backupbucket@us-east-1/backupstore
    10. backup-target-credential-secret: minio-secret
    11. #allow-recurring-job-while-volume-detached:
    12. #create-default-disk-labeled-nodes:
    13. default-data-path: /var/lib/longhorn-example/
    14. #replica-soft-anti-affinity:
    15. #replica-auto-balance:
    16. #storage-over-provisioning-percentage:
    17. #storage-minimal-available-percentage:
    18. #upgrade-checker:
    19. #default-replica-count:
    20. #default-data-locality:
    21. #default-longhorn-static-storage-class:
    22. #backupstore-poll-interval:
    23. #taint-toleration:
    24. #system-managed-components-node-selector:
    25. #priority-class:
    26. #auto-salvage:
    27. #auto-delete-pod-when-volume-detached-unexpectedly:
    28. #disable-scheduling-on-cordoned-node:
    29. #replica-zone-soft-anti-affinity:
    30. #node-down-pod-deletion-policy:
    31. #allow-node-drain-with-last-healthy-replica:
    32. #mkfs-ext4-parameters:
    33. #disable-replica-rebuild:
    34. #replica-replenishment-wait-interval:
    35. #concurrent-replica-rebuild-per-node-limit:
    36. #disable-revision-counter:
    37. #system-managed-pods-image-pull-policy:
    38. #allow-volume-creation-with-degraded-availability:
    39. #auto-cleanup-system-generated-snapshot:
    40. #concurrent-automatic-engine-upgrade-per-node-limit:
    41. #backing-image-cleanup-wait-interval:
    42. #backing-image-recovery-wait-interval:
    43. #guaranteed-engine-manager-cpu:
    44. #guaranteed-replica-manager-cpu:
    45. #kubernetes-cluster-autoscaler-enabled:
    46. #orphan-auto-deletion:
    47. #storage-network:
    48. #recurring-successful-jobs-history-limit:
    49. #recurring-failed-jobs-history-limit:
    50. ---

Using Helm

Use the Helm command with the --set flag to modify the default settings. For example:

  • Helm 2

    1. helm install longhorn/longhorn \
    2. --name longhorn \
    3. --namespace longhorn-system \
    4. --set defaultSettings.taintToleration="key1=value1:NoSchedule; key2:NoExecute"
  • Helm 3

    1. helm install longhorn longhorn/longhorn \
    2. --namespace longhorn-system \
    3. --create-namespace \
    4. --set defaultSettings.taintToleration="key1=value1:NoSchedule; key2:NoExecute"

You can also provide a copy of the values.yaml file with the default settings modified to the --values flag when running the Helm command:

  1. Obtain a copy of the values.yaml file from GitHub:

    1. curl -Lo values.yaml https://raw.githubusercontent.com/longhorn/charts/master/charts/longhorn/values.yaml
  2. Modify the default settings in the YAML file. The following is an example snippet of values.yaml:

    When the setting is absent or has a leading # symbol, the default setting will use the default value in Longhorn or the customized values previously configured.

    1. defaultSettings:
    2. backupTarget: s3://backupbucket@us-east-1/backupstore
    3. backupTargetCredentialSecret: minio-secret
    4. createDefaultDiskLabeledNodes: true
    5. defaultDataPath: /var/lib/longhorn-example/
    6. replicaSoftAntiAffinity: false
    7. storageOverProvisioningPercentage: 600
    8. storageMinimalAvailablePercentage: 15
    9. upgradeChecker: false
    10. defaultReplicaCount: 2
    11. defaultDataLocality: disabled
    12. defaultLonghornStaticStorageClass: longhorn-static-example
    13. backupstorePollInterval: 500
    14. taintToleration: key1=value1:NoSchedule; key2:NoExecute
    15. systemManagedComponentsNodeSelector: "label-key1:label-value1"
    16. priorityClass: high-priority
    17. autoSalvage: false
    18. disableSchedulingOnCordonedNode: false
    19. replicaZoneSoftAntiAffinity: false
    20. volumeAttachmentRecoveryPolicy: never
    21. nodeDownPodDeletionPolicy: do-nothing
    22. mkfsExt4Parameters: -O ^64bit,^metadata_csum
    23. guaranteedEngineManagerCpu: 15
    24. guaranteedReplicaManagerCpu: 15
    25. orphanAutoDeletion: false
  3. Run Helm with values.yaml:

  • Helm 2

    1. helm install longhorn/longhorn \
    2. --name longhorn \
    3. --namespace longhorn-system \
    4. --values values.yaml
  • Helm 3

    1. helm install longhorn longhorn/longhorn \
    2. --namespace longhorn-system \
    3. --create-namespace \
    4. --values values.yaml

For more info about using helm, see the section about installing Longhorn with Helm

Update Settings

Using the Longhorn UI

We recommend using the Longhorn UI to change Longhorn setting on the existing cluster. It would make the setting persistent.

Using the Rancher UI

From the project view in Rancher, go to Apps && Marketplace > Longhorn > Upgrade > Next > Edit Options > Longhorn Default Settings > Customize Default Settings and edit the settings before upgrading the app to the current Longhorn version.

Using Kubectl

If you prefer to use the command line to update the setting, you could use kubectl.

  1. kubectl edit settings <SETTING-NAME> -n longhorn-system

Using Helm

Modify the default settings in the YAML file as described in Fresh Installation > Using Helm and then update the settings using

  1. helm upgrade longhorn longhorn/longhorn --namespace longhorn-system --values ./values.yaml --version `helm list -n longhorn-system -o json | jq -r .'[0].app_version'`

Upgrade

Using the Rancher UI

From the project view in Rancher, go to Apps && Marketplace > Longhorn > Upgrade > Next > Edit Options > Longhorn Default Settings > Customize Default Settings and edit the settings before upgrading the app.

Using the Longhorn Deployment YAML File

Modify the config map named longhorn-default-setting in the yaml file longhorn/deploy/longhorn.yaml as described in Fresh Installation > Using the Longhorn Deployment YAML File and then upgrade the Longhorn system using kubectl.

Using Helm

Modify the default settings in the YAML file as described in Fresh Installation > Using Helm and then upgrade the Longhorn system using helm upgrade.

History

Available since v1.3.0 (Reference)


© 2019-2023 Longhorn Authors | Documentation Distributed under CC-BY-4.0

© 2023 The Linux Foundation. All rights reserved. The Linux Foundation has registered trademarks and uses trademarks. For a list of trademarks of The Linux Foundation, please see our Trademark Usage page.