csi-hostpath-plugin.yaml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. # Service defined here, plus serviceName below in StatefulSet,
  2. # are needed only because of condition explained in
  3. # https://github.com/kubernetes/kubernetes/issues/69608
  4. kind: Service
  5. apiVersion: v1
  6. metadata:
  7. name: csi-hostpathplugin
  8. labels:
  9. app: csi-hostpathplugin
  10. spec:
  11. selector:
  12. app: csi-hostpathplugin
  13. ports:
  14. - name: dummy
  15. port: 12345
  16. ---
  17. kind: StatefulSet
  18. apiVersion: apps/v1
  19. metadata:
  20. name: csi-hostpathplugin
  21. spec:
  22. serviceName: "csi-hostpathplugin"
  23. # One replica only:
  24. # Host path driver only works when everything runs
  25. # on a single node. We achieve that by starting it once and then
  26. # co-locate all other pods via inter-pod affinity
  27. replicas: 1
  28. selector:
  29. matchLabels:
  30. app: csi-hostpathplugin
  31. template:
  32. metadata:
  33. labels:
  34. app: csi-hostpathplugin
  35. spec:
  36. containers:
  37. - name: node-driver-registrar
  38. image: quay.io/k8scsi/csi-node-driver-registrar:v1.2.0
  39. lifecycle:
  40. preStop:
  41. exec:
  42. command: ["/bin/sh", "-c", "rm -rf /registration/csi-hostpath /registration/csi-hostpath-reg.sock"]
  43. args:
  44. - --v=5
  45. - --csi-address=/csi/csi.sock
  46. - --kubelet-registration-path=/var/lib/kubelet/plugins/csi-hostpath/csi.sock
  47. securityContext:
  48. # This is necessary only for systems with SELinux, where
  49. # non-privileged sidecar containers cannot access unix domain socket
  50. # created by privileged CSI driver container.
  51. privileged: true
  52. env:
  53. - name: KUBE_NODE_NAME
  54. valueFrom:
  55. fieldRef:
  56. apiVersion: v1
  57. fieldPath: spec.nodeName
  58. volumeMounts:
  59. - mountPath: /csi
  60. name: socket-dir
  61. - mountPath: /registration
  62. name: registration-dir
  63. - mountPath: /csi-data-dir
  64. name: csi-data-dir
  65. - name: hostpath
  66. image: quay.io/k8scsi/hostpathplugin:v1.3.0-rc1
  67. args:
  68. - "--drivername=hostpath.csi.k8s.io"
  69. - "--v=5"
  70. - "--endpoint=$(CSI_ENDPOINT)"
  71. - "--nodeid=$(KUBE_NODE_NAME)"
  72. - "--maxvolumespernode=10"
  73. env:
  74. - name: CSI_ENDPOINT
  75. value: unix:///csi/csi.sock
  76. - name: KUBE_NODE_NAME
  77. valueFrom:
  78. fieldRef:
  79. apiVersion: v1
  80. fieldPath: spec.nodeName
  81. securityContext:
  82. privileged: true
  83. ports:
  84. - containerPort: 9898
  85. name: healthz
  86. protocol: TCP
  87. livenessProbe:
  88. failureThreshold: 5
  89. httpGet:
  90. path: /healthz
  91. port: healthz
  92. initialDelaySeconds: 10
  93. timeoutSeconds: 3
  94. periodSeconds: 2
  95. volumeMounts:
  96. - mountPath: /csi
  97. name: socket-dir
  98. - mountPath: /var/lib/kubelet/pods
  99. mountPropagation: Bidirectional
  100. name: mountpoint-dir
  101. - mountPath: /var/lib/kubelet/plugins
  102. mountPropagation: Bidirectional
  103. name: plugins-dir
  104. - mountPath: /csi-data-dir
  105. name: csi-data-dir
  106. - mountPath: /dev
  107. name: dev-dir
  108. - name: liveness-probe
  109. volumeMounts:
  110. - mountPath: /csi
  111. name: socket-dir
  112. image: quay.io/k8scsi/livenessprobe:v1.1.0
  113. args:
  114. - --csi-address=/csi/csi.sock
  115. - --connection-timeout=3s
  116. - --health-port=9898
  117. volumes:
  118. - hostPath:
  119. path: /var/lib/kubelet/plugins/csi-hostpath
  120. type: DirectoryOrCreate
  121. name: socket-dir
  122. - hostPath:
  123. path: /var/lib/kubelet/pods
  124. type: DirectoryOrCreate
  125. name: mountpoint-dir
  126. - hostPath:
  127. path: /var/lib/kubelet/plugins_registry
  128. type: Directory
  129. name: registration-dir
  130. - hostPath:
  131. path: /var/lib/kubelet/plugins
  132. type: Directory
  133. name: plugins-dir
  134. - hostPath:
  135. # 'path' is where PV data is persisted on host.
  136. # using /tmp is also possible while the PVs will not available after plugin container recreation or host reboot
  137. path: /var/lib/csi-hostpath-data/
  138. type: DirectoryOrCreate
  139. name: csi-data-dir
  140. - hostPath:
  141. path: /dev
  142. type: Directory
  143. name: dev-dir