local-path-csi.yaml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. {{ $cluster := .Values.cluster }}
  2. {{ $mysql := $cluster.mysql }}
  3. {{ $mysqlSs := $mysql.statefulset }}
  4. {{ $mysqlSsEnabled := $mysqlSs.enabled }}
  5. {{ $mysqlStorageClass := $mysqlSs.persistence.storageClass }}
  6. {{ $clusterStorageClass := $cluster.storageClass }}
  7. {{- if (or (and $mysqlSsEnabled (eq $mysqlStorageClass "")) (eq $clusterStorageClass "")) -}}
  8. ---
  9. # deploy local path storage CSI component
  10. apiVersion: v1
  11. kind: Namespace
  12. metadata:
  13. name: local-path-storage
  14. ---
  15. apiVersion: v1
  16. kind: ServiceAccount
  17. metadata:
  18. name: local-path-provisioner-service-account
  19. namespace: local-path-storage
  20. ---
  21. apiVersion: rbac.authorization.k8s.io/v1
  22. kind: ClusterRole
  23. metadata:
  24. name: local-path-provisioner-role
  25. rules:
  26. - apiGroups: [""]
  27. resources: ["nodes", "persistentvolumeclaims", "configmaps"]
  28. verbs: ["get", "list", "watch"]
  29. - apiGroups: [""]
  30. resources: ["endpoints", "persistentvolumes", "pods"]
  31. verbs: ["*"]
  32. - apiGroups: [""]
  33. resources: ["events"]
  34. verbs: ["create", "patch"]
  35. - apiGroups: ["storage.k8s.io"]
  36. resources: ["storageclasses"]
  37. verbs: ["get", "list", "watch"]
  38. ---
  39. apiVersion: rbac.authorization.k8s.io/v1
  40. kind: ClusterRoleBinding
  41. metadata:
  42. name: local-path-provisioner-bind
  43. roleRef:
  44. apiGroup: rbac.authorization.k8s.io
  45. kind: ClusterRole
  46. name: local-path-provisioner-role
  47. subjects:
  48. - kind: ServiceAccount
  49. name: local-path-provisioner-service-account
  50. namespace: local-path-storage
  51. ---
  52. apiVersion: apps/v1
  53. kind: Deployment
  54. metadata:
  55. name: local-path-provisioner
  56. namespace: local-path-storage
  57. spec:
  58. replicas: 1
  59. selector:
  60. matchLabels:
  61. app: local-path-provisioner
  62. template:
  63. metadata:
  64. labels:
  65. app: local-path-provisioner
  66. spec:
  67. serviceAccountName: local-path-provisioner-service-account
  68. tolerations:
  69. - key: node-role.kubernetes.io/master
  70. effect: NoSchedule
  71. - key: node-role.kubernetes.io/controlplane
  72. effect: NoSchedule
  73. containers:
  74. - name: local-path-provisioner
  75. image: {{ template "cloudpods.localPathCSI.image" . }}
  76. imagePullPolicy: IfNotPresent
  77. command:
  78. - local-path-provisioner
  79. - --debug
  80. - start
  81. - --config
  82. - /etc/config/config.json
  83. volumeMounts:
  84. - name: config-volume
  85. mountPath: /etc/config/
  86. env:
  87. - name: POD_NAMESPACE
  88. valueFrom:
  89. fieldRef:
  90. fieldPath: metadata.namespace
  91. volumes:
  92. - name: config-volume
  93. configMap:
  94. name: local-path-config
  95. ---
  96. apiVersion: storage.k8s.io/v1
  97. kind: StorageClass
  98. metadata:
  99. name: local-path
  100. provisioner: rancher.io/local-path
  101. volumeBindingMode: WaitForFirstConsumer
  102. reclaimPolicy: Delete
  103. ---
  104. kind: ConfigMap
  105. apiVersion: v1
  106. metadata:
  107. name: local-path-config
  108. namespace: local-path-storage
  109. data:
  110. config.json: |-
  111. {
  112. "nodePathMap":[
  113. {
  114. "node":"DEFAULT_PATH_FOR_NON_LISTED_NODES",
  115. "paths":["/opt/local-path-provisioner"]
  116. }
  117. ]
  118. }
  119. setup: |-
  120. #!/bin/sh
  121. set -eu
  122. mkdir -m 0777 -p "$VOL_DIR"
  123. teardown: |-
  124. #!/bin/sh
  125. set -eu
  126. rm -rf "$VOL_DIR"
  127. helperPod.yaml: |-
  128. apiVersion: v1
  129. kind: Pod
  130. metadata:
  131. name: helper-pod
  132. spec:
  133. containers:
  134. - name: helper-pod
  135. image: {{ .Values.localPathCSI.helperPod.image }}
  136. imagePullPolicy: {{ .Values.localPathCSI.helperPod.pullPolicy }}
  137. {{- end -}}