apiVersion: v1 kind: Namespace metadata: name: local-path-storage --- apiVersion: v1 kind: ServiceAccount metadata: name: local-path-provisioner-service-account namespace: {{ k8s_local_path_namespace | default('local-path-storage') }} --- apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: name: local-path-provisioner-role namespace: {{ k8s_local_path_namespace | default('local-path-storage') }} rules: - apiGroups: [""] resources: ["pods"] verbs: ["get", "list", "watch", "create", "patch", "update", "delete"] --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: local-path-provisioner-role rules: - apiGroups: [""] resources: ["nodes", "persistentvolumeclaims", "configmaps", "pods", "pods/log"] verbs: ["get", "list", "watch"] - apiGroups: [""] resources: ["persistentvolumes"] verbs: ["get", "list", "watch", "create", "patch", "update", "delete"] - apiGroups: [""] resources: ["events"] verbs: ["create", "patch"] - apiGroups: ["storage.k8s.io"] resources: ["storageclasses"] verbs: ["get", "list", "watch"] --- apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: local-path-provisioner-bind namespace: {{ k8s_local_path_namespace | default('local-path-storage') }} roleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: local-path-provisioner-role subjects: - kind: ServiceAccount name: local-path-provisioner-service-account namespace: {{ k8s_local_path_namespace | default('local-path-storage') }} --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: 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: {{ k8s_local_path_namespace | default('local-path-storage') }} --- apiVersion: apps/v1 kind: Deployment metadata: name: local-path-provisioner namespace: {{ k8s_local_path_namespace | default('local-path-storage') }} spec: replicas: 1 selector: matchLabels: app: local-path-provisioner template: metadata: labels: app: local-path-provisioner spec: serviceAccountName: local-path-provisioner-service-account containers: - name: local-path-provisioner image: {{ k8s_local_path_image | default('rancher/local-path-provisioner:master-head') }} imagePullPolicy: {{ k8s_local_path_image_pull_policy | default(k8s_image_pull_policy) }} command: - local-path-provisioner - --debug - start - --config - /etc/config/config.json volumeMounts: - name: config-volume mountPath: /etc/config/ env: - name: POD_NAMESPACE valueFrom: fieldRef: fieldPath: metadata.namespace volumes: - name: config-volume configMap: name: local-path-config --- apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: local-path annotations: storageclass.kubernetes.io/is-default-class: "{{ k8s_local_path_default_class | default('true') }}" provisioner: rancher.io/local-path volumeBindingMode: {{ k8s_local_path_bind_mode | default('WaitForFirstConsumer') }} reclaimPolicy: {{ k8s_local_path_reclaim_policy | default('Retain') }} --- kind: ConfigMap apiVersion: v1 metadata: name: local-path-config namespace: {{ k8s_local_path_namespace | default('local-path-storage') }} data: config.json: |- { "nodePathMap":[ { "node":"DEFAULT_PATH_FOR_NON_LISTED_NODES", "paths":["{{ k8s_local_path_dir | default('/opt/local-path-provisioner') }}"] } ] } setup: |- #!/bin/sh set -eu mkdir -m 0777 -p "$VOL_DIR" teardown: |- #!/bin/sh set -eu rm -rf "$VOL_DIR" helperPod.yaml: |- apiVersion: v1 kind: Pod metadata: name: helper-pod spec: priorityClassName: {{ k8s_local_path_priority_class | default('system-node-critical') }} tolerations: - key: node.kubernetes.io/disk-pressure operator: Exists effect: NoSchedule containers: - name: helper-pod image: busybox imagePullPolicy: {{ k8s_local_path_image_pull_policy | default(k8s_image_pull_policy) }}