diff --git a/talos/talhelper/iscsi-multipath-init.yaml b/talos/talhelper/iscsi-multipath-init.yaml index 834b3e0..cdded37 100644 --- a/talos/talhelper/iscsi-multipath-init.yaml +++ b/talos/talhelper/iscsi-multipath-init.yaml @@ -2,12 +2,10 @@ # iSCSI Multipath Initialization DaemonSet # # Configures multipath.conf for Pure Storage FlashArray on Talos worker nodes. -# Runs as a DaemonSet with an initContainer that writes configuration, then -# sleeps indefinitely to mark the node as configured. +# Runs as a DaemonSet with an initContainer that writes configuration. # -# This approach avoids Talos boot-time file writing issues while ensuring -# multipath is properly configured before Portworx CSI driver starts using -# iSCSI volumes. +# IMPORTANT: On Talos, /etc is an overlayfs with writable upper layer in /system/etc +# We write directly to /system/etc which then appears in /etc apiVersion: apps/v1 kind: DaemonSet @@ -43,6 +41,9 @@ spec: image: alpine:3.19 securityContext: privileged: true + volumeMounts: + - name: system-etc + mountPath: /system-etc command: - sh - -c @@ -51,9 +52,8 @@ spec: echo "Configuring multipath for Pure Storage FlashArray..." - # Write multipath.conf using nsenter to access host's writable filesystem - # Talos mounts /etc as read-only in containers, but writable in host namespace - nsenter -t 1 -m -u -i -n -- sh -c 'cat > /etc/multipath.conf' <<'MPCONF' + # Write to /system/etc + cat > /system-etc/multipath.conf <<'MPCONF' # Multipath configuration for Pure Storage FlashArray # Managed by iscsi-multipath-init DaemonSet @@ -87,20 +87,24 @@ spec: } MPCONF - echo "✓ Multipath configuration written to /etc/multipath.conf" + echo "✓ Multipath configuration written to /system/etc/multipath.conf" - # Reload multipathd if running (Talos manages the service) + # Copy file to /etc using direct file copy (no ln/cp command needed) + # Mount PID 1's /etc as writable and copy the file + cat /system-etc/multipath.conf > /proc/1/root/etc/multipath.conf || \ + echo "Warning: Could not copy to /etc directly, file available at /system/etc/multipath.conf" + + echo "✓ Configuration deployed to /etc/multipath.conf" + + # Reload multipathd if running if nsenter -t 1 -m -u -i -n -- multipathd show status >/dev/null 2>&1; then echo "Reloading multipathd..." nsenter -t 1 -m -u -i -n -- multipathd reconfigure || true fi - echo "✓ Multipath configuration complete" - echo "Current multipath devices:" - nsenter -t 1 -m -u -i -n -- multipath -ll || echo " (no multipath devices yet)" + echo "✓ Configuration complete" containers: - # Pause container keeps the pod running to indicate configuration is applied - name: pause image: registry.k8s.io/pause:3.9 resources: @@ -110,3 +114,9 @@ spec: limits: cpu: 10m memory: 16Mi + + volumes: + - name: system-etc + hostPath: + path: /system/etc + type: DirectoryOrCreate