| Matthias Andreas Benkard | 05e482e | 2026-11-04 11:05:51 +0100 | [diff] [blame] | 1 | --- |
| 2 | apiVersion: apps/v1 |
| 3 | kind: Deployment |
| 4 | metadata: |
| 5 | annotations: |
| 6 | kubectl.kubernetes.io/last-applied-configuration: | |
| 7 | {"apiVersion":"apps/v1beta2","kind":"Deployment","metadata":{"annotations":{},"name":"local-path-provisioner","namespace":"local-path-storage"},"spec":{"replicas":1,"selector":{"matchLabels":{"app":"local-path-provisioner"}},"template":{"metadata":{"labels":{"app":"local-path-provisioner"}},"spec":{"containers":[{"command":["local-path-provisioner","--debug","start","--config","/etc/config/config.json"],"env":[{"name":"POD_NAMESPACE","valueFrom":{"fieldRef":{"fieldPath":"metadata.namespace"}}}],"image":"rancher/local-path-provisioner:v0.0.2","imagePullPolicy":"Always","name":"local-path-provisioner","volumeMounts":[{"mountPath":"/etc/config/","name":"config-volume"}]}],"serviceAccountName":"local-path-provisioner-service-account","volumes":[{"configMap":{"name":"local-path-config"},"name":"config-volume"}]}}}} |
| 8 | labels: |
| 9 | app: local-path-provisioner |
| 10 | name: local-path-provisioner |
| 11 | namespace: local-path-storage |
| 12 | spec: |
| 13 | progressDeadlineSeconds: 600 |
| 14 | replicas: 1 |
| 15 | revisionHistoryLimit: 10 |
| 16 | selector: |
| 17 | matchLabels: |
| 18 | app: local-path-provisioner |
| 19 | strategy: |
| 20 | rollingUpdate: |
| 21 | maxSurge: 25% |
| 22 | maxUnavailable: 25% |
| 23 | type: RollingUpdate |
| 24 | template: |
| 25 | metadata: |
| 26 | labels: |
| 27 | app: local-path-provisioner |
| 28 | spec: |
| 29 | containers: |
| 30 | - command: |
| 31 | - local-path-provisioner |
| 32 | - --debug |
| 33 | - start |
| 34 | - --config |
| 35 | - /etc/config/config.json |
| 36 | env: |
| 37 | - name: POD_NAMESPACE |
| 38 | valueFrom: |
| 39 | fieldRef: |
| 40 | apiVersion: v1 |
| 41 | fieldPath: metadata.namespace |
| 42 | image: rancher/local-path-provisioner:v0.0.19 |
| 43 | imagePullPolicy: Always |
| 44 | name: local-path-provisioner |
| 45 | resources: {} |
| 46 | terminationMessagePath: /dev/termination-log |
| 47 | terminationMessagePolicy: File |
| 48 | volumeMounts: |
| 49 | - mountPath: /etc/config/ |
| 50 | name: config-volume |
| 51 | dnsPolicy: ClusterFirst |
| 52 | restartPolicy: Always |
| 53 | schedulerName: default-scheduler |
| 54 | securityContext: {} |
| 55 | serviceAccount: local-path-provisioner-service-account |
| 56 | serviceAccountName: local-path-provisioner-service-account |
| 57 | terminationGracePeriodSeconds: 30 |
| 58 | volumes: |
| 59 | - configMap: |
| 60 | defaultMode: 420 |
| 61 | name: local-path-config |
| 62 | name: config-volume |
| 63 | --- |
| 64 | apiVersion: v1 |
| 65 | data: |
| 66 | config.json: |- |
| 67 | { |
| 68 | "nodePathMap":[ |
| 69 | { |
| 70 | "node":"DEFAULT_PATH_FOR_NON_LISTED_NODES", |
| 71 | "paths":["/var/k8s"] |
| 72 | } |
| 73 | ] |
| 74 | } |
| 75 | helperPod.yaml: "apiVersion: v1\nkind: Pod\nmetadata:\n name: helper-pod\nspec:\n hostPID: true\n containers:\n - name: helper-pod\n image: alpine:3.20\n securityContext:\n privileged: true\n" |
| 76 | setup: "#!/bin/sh\n# Creates a ZFS dataset per PV. The helper pod runs with hostPID, and all\n# ZFS and filesystem operations are performed in the host's mount namespace\n# (nsenter -t 1 -m). Running zfs directly inside the helper container would\n# mount the dataset only inside the container's own mount namespace; the\n# workload would then write into the parent dataset, and the child dataset\n# would shadow that data after the next host reboot.\nset -eu\n\nwhile getopts \"m:s:p:\" opt\ndo\n case $opt in\n p)\n absolutePath=$OPTARG\n ;;\n s)\n sizeInBytes=$OPTARG\n ;;\n m)\n volMode=$OPTARG\n ;;\n esac\ndone\n\nhost() { nsenter -t 1 -m -- \"$@\"; }\n\nhost zfs create \"rpool${absolutePath}\"\nhost zfs mount \"rpool${absolutePath}\" 2>/dev/null || :\nhost findmnt -n -o SOURCE \"${absolutePath}\" | grep -qx \"rpool${absolutePath}\"\nhost chmod 0777 \"${absolutePath}\"\n" |
| 77 | teardown: | |
| 78 | #!/bin/sh |
| 79 | # Unmounts (but keeps) the PV's ZFS dataset. Runs in the host's mount |
| 80 | # namespace; see setup.sh. |
| 81 | set -eu |
| 82 | |
| 83 | while getopts "m:s:p:" opt |
| 84 | do |
| 85 | case $opt in |
| 86 | p) |
| 87 | absolutePath=$OPTARG |
| 88 | ;; |
| 89 | s) |
| 90 | sizeInBytes=$OPTARG |
| 91 | ;; |
| 92 | m) |
| 93 | volMode=$OPTARG |
| 94 | ;; |
| 95 | esac |
| 96 | done |
| 97 | |
| 98 | nsenter -t 1 -m -- zfs set mountpoint=none "rpool${absolutePath}" |
| 99 | kind: ConfigMap |
| 100 | metadata: |
| 101 | annotations: |
| 102 | kubectl.kubernetes.io/last-applied-configuration: | |
| 103 | {"apiVersion":"v1","data":{"config.json":"{\n \"nodePathMap\":[\n {\n \"node\":\"DEFAULT_PATH_FOR_NON_LISTED_NODES\",\n \"paths\":[\"/var/k8s\"]\n }\n ]\n}"},"kind":"ConfigMap","metadata":{"annotations":{},"name":"local-path-config","namespace":"local-path-storage"}} |
| 104 | name: local-path-config |
| 105 | namespace: local-path-storage |
| 106 | --- |
| 107 | apiVersion: v1 |
| 108 | kind: ServiceAccount |
| 109 | metadata: |
| 110 | annotations: |
| 111 | kubectl.kubernetes.io/last-applied-configuration: | |
| 112 | {"apiVersion":"v1","kind":"ServiceAccount","metadata":{"annotations":{},"name":"local-path-provisioner-service-account","namespace":"local-path-storage"}} |
| 113 | name: local-path-provisioner-service-account |
| 114 | namespace: local-path-storage |
| 115 | --- |
| 116 | apiVersion: rbac.authorization.k8s.io/v1 |
| 117 | kind: RoleBinding |
| 118 | metadata: |
| 119 | name: local-path-provisioner:psp:default |
| 120 | namespace: local-path-storage |
| 121 | roleRef: |
| 122 | apiGroup: rbac.authorization.k8s.io |
| 123 | kind: ClusterRole |
| 124 | name: psp:default |
| 125 | subjects: |
| 126 | - kind: ServiceAccount |
| 127 | name: local-path-provisioner-service-account |
| 128 | namespace: local-path-storage |
| 129 | --- |
| 130 | apiVersion: rbac.authorization.k8s.io/v1 |
| 131 | kind: ClusterRole |
| 132 | metadata: |
| 133 | annotations: |
| 134 | kubectl.kubernetes.io/last-applied-configuration: | |
| 135 | {"apiVersion":"rbac.authorization.k8s.io/v1beta1","kind":"ClusterRole","metadata":{"annotations":{},"name":"local-path-provisioner-role"},"rules":[{"apiGroups":[""],"resources":["nodes","persistentvolumeclaims"],"verbs":["get","list","watch"]},{"apiGroups":[""],"resources":["endpoints","persistentvolumes","pods"],"verbs":["*"]},{"apiGroups":[""],"resources":["events"],"verbs":["create","patch"]},{"apiGroups":["storage.k8s.io"],"resources":["storageclasses"],"verbs":["get","list","watch"]}]} |
| 136 | name: local-path-provisioner-role |
| 137 | rules: |
| 138 | - apiGroups: |
| 139 | - "" |
| 140 | resources: |
| 141 | - nodes |
| 142 | - persistentvolumeclaims |
| 143 | - configmaps |
| 144 | verbs: |
| 145 | - get |
| 146 | - list |
| 147 | - watch |
| 148 | - apiGroups: |
| 149 | - "" |
| 150 | resources: |
| 151 | - endpoints |
| 152 | - persistentvolumes |
| 153 | - pods |
| 154 | verbs: |
| 155 | - '*' |
| 156 | - apiGroups: |
| 157 | - "" |
| 158 | resources: |
| 159 | - events |
| 160 | verbs: |
| 161 | - create |
| 162 | - patch |
| 163 | - apiGroups: |
| 164 | - storage.k8s.io |
| 165 | resources: |
| 166 | - storageclasses |
| 167 | verbs: |
| 168 | - get |
| 169 | - list |
| 170 | - watch |
| 171 | --- |
| 172 | apiVersion: rbac.authorization.k8s.io/v1 |
| 173 | kind: ClusterRoleBinding |
| 174 | metadata: |
| 175 | annotations: |
| 176 | kubectl.kubernetes.io/last-applied-configuration: | |
| 177 | {"apiVersion":"rbac.authorization.k8s.io/v1beta1","kind":"ClusterRoleBinding","metadata":{"annotations":{},"name":"local-path-provisioner-bind"},"roleRef":{"apiGroup":"rbac.authorization.k8s.io","kind":"ClusterRole","name":"local-path-provisioner-role"},"subjects":[{"kind":"ServiceAccount","name":"local-path-provisioner-service-account","namespace":"local-path-storage"}]} |
| 178 | name: local-path-provisioner-bind |
| 179 | roleRef: |
| 180 | apiGroup: rbac.authorization.k8s.io |
| 181 | kind: ClusterRole |
| 182 | name: local-path-provisioner-role |
| 183 | subjects: |
| 184 | - kind: ServiceAccount |
| 185 | name: local-path-provisioner-service-account |
| 186 | namespace: local-path-storage |
| 187 | --- |
| 188 | apiVersion: storage.k8s.io/v1 |
| 189 | kind: StorageClass |
| 190 | metadata: |
| 191 | annotations: |
| 192 | kubectl.kubernetes.io/last-applied-configuration: | |
| 193 | {"apiVersion":"storage.k8s.io/v1","kind":"StorageClass","metadata":{"annotations":{},"name":"local-path"},"provisioner":"rancher.io/local-path","reclaimPolicy":"Delete","volumeBindingMode":"WaitForFirstConsumer"} |
| 194 | name: local-path |
| 195 | provisioner: rancher.io/local-path |
| 196 | reclaimPolicy: Delete |
| 197 | volumeBindingMode: WaitForFirstConsumer |