Automount not working
have on earch worker node a disk label: longhorn
wanna the the worke node do a automount this disk to /var/mnt/longhorn
but this did not work
$ oc version
Client Version: 4.16.17
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: 4.16.17
Kubernetes Version: v1.29.8+632b078
Cluster Version: 4.16.17
Steps To Reproduce
storage-mcp.yaml
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfigPool
metadata:
name: storage
spec:
machineConfigSelector:
matchExpressions:
- {key: machineconfiguration.openshift.io/role, operator: In, values: [worker,storage]}
nodeSelector:
matchLabels:
node-role.kubernetes.io/storage: ""
auto-mount-machineconfig.yaml
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
labels:
machineconfiguration.openshift.io/role: storage
name: 71-mount-storage-worker
spec:
config:
ignition:
version: 3.2.0
systemd:
units:
- name: var-mnt-longhorn.mount
enabled: true
contents: |
[Unit]
Before=local-fs.target
[Mount]
# Example mount point, you can change it to where you like for each device.
Where=/var/mnt/longhorn
What=/dev/disk/by-label/longhorn
Options=rw,relatime,discard
[Install]
WantedBy=local-fs.target
$ oc get nodes
NAME STATUS ROLES AGE VERSION
cp1 Ready control-plane,master 17h v1.29.8+632b078
cp2 Ready control-plane,master 17h v1.29.8+632b078
cp3 Ready control-plane,master 17h v1.29.8+632b078
wn1 Ready storage,worker 17h v1.29.8+632b078
wn2 Ready storage,worker 17h v1.29.8+632b078
wn3 Ready storage,worker 17h v1.29.8+632b078
label disk with lonhorn
ls /dev/disk/by-label/longhorn
/dev/disk/by-label/longhorn
oc label node wn1 node-role.kubernetes.io/storage=
oc label node wn2 node-role.kubernetes.io/storage=
oc label node wn3 node-role.kubernetes.io/storage=
oc apply -f storage-mcp.yaml
oc apply -f auto-mount-machineconfig.yaml
oc annotate node wn1 --overwrite node.longhorn.io/default-disks-config='[{"path":"/var/mnt/longhorn","allowScheduling":true}]'
oc label node wn1 --overwrite node.longhorn.io/create-default-disk=config
oc annotate node wn2 --overwrite node.longhorn.io/default-disks-config='[{"path":"/var/mnt/longhorn","allowScheduling":true}]'
oc label node wn2 --overwrite node.longhorn.io/create-default-disk=config
oc annotate node wn3 --overwrite node.longhorn.io/default-disks-config='[{"path":"/var/mnt/longhorn","allowScheduling":true}]'
oc label node wn3 --overwrite node.longhorn.io/create-default-disk=config
login to all worker nodes create dir /var/mnt/longhorn
reboot earch worker node
Current Result
the Disk is not mounted
Expected Result
auto mount this disk
Additional Information
Manual mount works:
sh-5.1# mount /dev/disk/by-label/longhorn /var/mnt/longhorn/
sh-5.1# df -h /var/mnt/longhorn/
Filesystem Size Used Avail Use% Mounted on
/dev/sdb 118G 24K 112G 1% /var/mnt/longhorn
What did I wrong ?
Responses