Skip to main content

Local Path

  • rancher/local-path-provisioner
  • storageClassName: local-path
  • 自动创建目录 - /var/lib/rancher/k3s/storage
    • pvc-<UUID>
  • 注意
    • 异常后 PVC 丢失,StatefulSet 无法启动
      • 删除 Pod 从新部署可恢复

k3s 默认配置

{  "nodePathMap": [    {      "node": "DEFAULT_PATH_FOR_NON_LISTED_NODES",      "paths": ["/var/lib/rancher/k3s/storage"]    }  ]}

配置#

kind: ConfigMapapiVersion: v1metadata:  name: local-path-config  namespace: local-path-storagedata:  # paths 设置为空数组则会拒绝  # paths 设置多个会随机选择  config.json: |-    {      "nodePathMap":[        {          "node":"DEFAULT_PATH_FOR_NON_LISTED_NODES",          "paths":["/opt/local-path-provisioner"]        },        {          "node":"yasker-lp-dev1",          "paths":["/opt/local-path-provisioner", "/data1"]        },        {          "node":"yasker-lp-dev3",          "paths":[]        }      ]    }  setup: |-    #!/bin/sh    path=$1    mkdir -m 0777 -p ${path}  teardown: |-    #!/bin/sh    path=$1    rm -rf ${path}