内容来源于官方 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
公众号:黑客下午茶
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐