You may customize Longhorn’s default settings when deploying it. You may specify, for example, Create Default Disk With Node Labeled and Default Data Path before starting Longhorn.

This default setting is only for a Longhorn system that hasn’t been deployed. It has no impact on an existing Longhorn system. The settings for any existing Longhorn system should be modified using the Longhorn UI.

The default settings can be customized in the following ways:

Using the Rancher UI

From the project view in Rancher, go to Apps > Launch > Longhorn and edit the settings before launching 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. For example:

    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. create-default-disk-labeled-nodes: true
    12. default-data-path: /var/lib/longhorn-example/
    13. replica-soft-anti-affinity: false
    14. storage-over-provisioning-percentage: 600
    15. storage-minimal-available-percentage: 15
    16. upgrade-checker: false
    17. default-replica-count: 2
    18. default-data-locality: disabled
    19. guaranteed-engine-cpu: 0.25
    20. default-longhorn-static-storage-class: longhorn-static-example
    21. backupstore-poll-interval: 500
    22. taint-toleration: key1=value1:NoSchedule; key2:NoExecute
    23. registry-secret: registry-secret
    24. auto-salvage: false
    25. disable-scheduling-on-cordoned-node: false
    26. replica-zone-soft-anti-affinity: false
    27. volume-attachment-recovery-policy: never
    28. node-down-pod-deletion-policy: do-nothing
    29. mkfs-ext4-parameters: -O ^64bit,^metadata_csum
    30. ---

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:

    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. guaranteedEngineCPU: 0.25
    13. defaultLonghornStaticStorageClass: longhorn-static-example
    14. backupstorePollInterval: 500
    15. taintToleration: key1=value1:NoSchedule; key2:NoExecute
    16. registrySecret: registry-secret
    17. autoSalvage: false
    18. disableSchedulingOnCordonedNode: false
    19. replicaZoneSoftAntiAffinity: false
    20. volumeAttachmentRecoveryPolicy: never
    21. nodeDownPodDeletionPolicy: do-nothing
    22. mkfsExt4Parameters: -O ^64bit,^metadata_csum
  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

History

Original feature request

Available since v0.6.0