You may customize Longhorn’s default settings while installing or upgrading. You may specify, for example, and Default Data Path
before starting Longhorn.
The default settings can be customized in the following ways:
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
Download the longhorn repo:
Modify the config map named
longhorn-default-setting
in the yaml filelonghorn/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.---
apiVersion: v1
kind: ConfigMap
metadata:
name: longhorn-default-setting
namespace: longhorn-system
data:
default-setting.yaml: |-
backup-target: s3://backupbucket@us-east-1/backupstore
backup-target-credential-secret: minio-secret
#create-default-disk-labeled-nodes:
default-data-path: /var/lib/longhorn-example/
#replica-soft-anti-affinity:
#replica-auto-balance:
#storage-over-provisioning-percentage:
#storage-minimal-available-percentage:
#upgrade-checker:
#default-replica-count:
#default-data-locality:
#default-longhorn-static-storage-class:
#backupstore-poll-interval:
#taint-toleration:
#system-managed-components-node-selector:
#priority-class:
#auto-salvage:
#auto-delete-pod-when-volume-detached-unexpectedly:
#disable-scheduling-on-cordoned-node:
#replica-zone-soft-anti-affinity:
#allow-node-drain-with-last-healthy-replica:
#mkfs-ext4-parameters:
#disable-replica-rebuild:
#replica-replenishment-wait-interval:
#concurrent-replica-rebuild-per-node-limit:
#disable-revision-counter:
#system-managed-pods-image-pull-policy:
#allow-volume-creation-with-degraded-availability:
#auto-cleanup-system-generated-snapshot:
#concurrent-automatic-engine-upgrade-per-node-limit:
#backing-image-cleanup-wait-interval:
#backing-image-recovery-wait-interval:
#guaranteed-engine-manager-cpu:
#guaranteed-replica-manager-cpu:
#kubernetes-cluster-autoscaler-enabled:
#orphan-auto-deletion:
#storage-network:
#recurring-successful-jobs-history-limit:
#recurring-failed-jobs-history-limit:
---
Using Helm
Use the Helm command with the --set
flag to modify the default settings. For example:
Helm 3
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:
Obtain a copy of the
values.yaml
file from GitHub:curl -Lo values.yaml https://raw.githubusercontent.com/longhorn/charts/master/charts/longhorn/values.yaml
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.defaultSettings:
backupTarget: s3://backupbucket@us-east-1/backupstore
createDefaultDiskLabeledNodes: true
defaultDataPath: /var/lib/longhorn-example/
replicaSoftAntiAffinity: false
storageOverProvisioningPercentage: 600
storageMinimalAvailablePercentage: 15
upgradeChecker: false
defaultReplicaCount: 2
defaultDataLocality: disabled
defaultLonghornStaticStorageClass: longhorn-static-example
backupstorePollInterval: 500
taintToleration: key1=value1:NoSchedule; key2:NoExecute
systemManagedComponentsNodeSelector: "label-key1:label-value1"
priorityClass: high-priority
autoSalvage: false
disableSchedulingOnCordonedNode: false
replicaZoneSoftAntiAffinity: false
volumeAttachmentRecoveryPolicy: never
nodeDownPodDeletionPolicy: do-nothing
mkfsExt4Parameters: -O ^64bit,^metadata_csum
guaranteedEngineManagerCpu: 15
guaranteedReplicaManagerCpu: 15
orphanAutoDeletion: false
Run Helm with
values.yaml
:
Helm 2
Helm 3
helm install longhorn longhorn/longhorn \
--namespace longhorn-system \
--create-namespace \
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
.
kubectl edit settings <SETTING-NAME> -n longhorn-system
Modify the default settings in the YAML file as described in Fresh Installation > Using Helm and then update the settings using
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
.
Modify the default settings in the YAML file as described in Fresh Installation > Using Helm and then upgrade the Longhorn system using helm upgrade
.
Available since v1.3.0 (Reference)