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