Longhorn,企業級雲原生容器分散式儲存 - 定製預設設定

為少發表於2021-08-28

內容來源於官方 Longhorn 1.1.2 英文技術手冊。

系列

您可以在部署 Longhorn 時自定義它的預設設定。例如,您可以在啟動 Longhorn 之前指定 Create Default Disk With Node Labeled(建立帶有節點標籤的預設磁碟)Default Data Path(預設資料路徑)

此預設設定僅適用於尚未部署的 Longhorn 系統。它對現有的 Longhorn 系統沒有影響。
任何現有 Longhorn 系統的設定都應使用 Longhorn UI 進行修改。

可以通過以下方式自定義預設設定:

  • 使用 Rancher UI
  • 使用 Longhorn Deployment YAML 檔案
  • 使用 Helm

使用 Rancher UI

Rancher 的專案檢視中,轉到 Apps > Launch > Longhorn 並在啟動應用程式之前編輯設定。

使用 Longhorn Deployment YAML 檔案

  1. 下載 longhorn repo:

    git clone https://github.com/longhorn/longhorn.git
    
  2. 修改 yaml 檔案 longhorn/deploy/longhorn.yaml 中名為 longhorn-default-settingconfig map。例如:

    ---
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: longhorn-default-setting
      namespace: longhorn-system
    data:
      default-setting.yaml: |-
        backup-target:
        backup-target-credential-secret:
        allow-recurring-job-while-volume-detached:
        create-default-disk-labeled-nodes:
        default-data-path:
        replica-soft-anti-affinity:
        storage-over-provisioning-percentage:
        storage-minimal-available-percentage:
        upgrade-checker:
        default-replica-count:
        default-data-locality:
        guaranteed-engine-cpu:
        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:
        volume-attachment-recovery-policy:
        node-down-pod-deletion-policy:
        allow-node-drain-with-last-healthy-replica:
        mkfs-ext4-parameters:
        disable-replica-rebuild:
        replica-replenishment-wait-interval:
        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:
        guaranteed-engine-manager-cpu:
        guaranteed-replica-manager-cpu:
    ---
    

使用 Helm

使用帶有 --set 標誌的 Helm 命令來修改預設設定。 例如:

helm install longhorn/longhorn \
--name longhorn \
--namespace longhorn-system \
--set defaultSettings.taintToleration="key1=value1:NoSchedule; key2:NoExecute"

您還可以提供一份 values.yaml 檔案的副本,其中在執行 Helm 命令時將預設設定修改為 --values 標誌:

  1. 從 GitHub 獲取 values.yaml 檔案的副本:

    curl -Lo values.yaml https://raw.githubusercontent.com/longhorn/charts/master/charts/longhorn/values.yaml
    
  2. 修改 YAML 檔案中的預設設定。以下是 values.yaml 的示例片段:

    defaultSettings:
      backupTarget: s3://backupbucket@us-east-1/backupstore
      backupTargetCredentialSecret: minio-secret
      createDefaultDiskLabeledNodes: true
      defaultDataPath: /var/lib/longhorn-example/
      replicaSoftAntiAffinity: false
      storageOverProvisioningPercentage: 600
      storageMinimalAvailablePercentage: 15
      upgradeChecker: false
      defaultReplicaCount: 2
      defaultDataLocality: disabled
      guaranteedEngineCPU:
      defaultLonghornStaticStorageClass: longhorn-static-example
      backupstorePollInterval: 500
      taintToleration: key1=value1:NoSchedule; key2:NoExecute
      systemManagedComponentsNodeSelector: "label-key1:label-value1"
      priority-class: high-priority
      autoSalvage: false
      disableSchedulingOnCordonedNode: false
      replicaZoneSoftAntiAffinity: false
      volumeAttachmentRecoveryPolicy: never
      nodeDownPodDeletionPolicy: do-nothing
      mkfsExt4Parameters: -O ^64bit,^metadata_csum
      guaranteed-engine-manager-cpu: 15
      guaranteed-replica-manager-cpu: 15
    
  3. 使用 values.yaml 執行 Helm:

    helm install longhorn/longhorn --name longhorn --namespace longhorn-system --values values.yaml
    
公眾號:黑客下午茶

相關文章