prerequisite: add nvme-cli installation manifest

Longhorn 5738

Signed-off-by: Derek Su <derek.su@suse.com>
This commit is contained in:
Derek Su 2023-05-06 14:01:00 +08:00 committed by David Ko
parent 3f16363ff1
commit dec0d4c11d

View File

@ -0,0 +1,36 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: longhorn-nvme-cli-installation
labels:
app: longhorn-nvme-cli-installation
annotations:
command: &cmd OS=$(grep -E "^ID_LIKE=" /etc/os-release | cut -d '=' -f 2); if [[ -z "${OS}" ]]; then OS=$(grep -E "^ID=" /etc/os-release | cut -d '=' -f 2); fi; if [[ "${OS}" == *"debian"* ]]; then sudo apt-get update -q -y && sudo apt-get install -q -y nvme-cli && sudo modprobe nvme-tcp; elif [[ "${OS}" == *"suse"* ]]; then sudo zypper --gpg-auto-import-keys -q refresh && sudo zypper --gpg-auto-import-keys -q install -y nvme-cli && sudo modprobe nvme-tcp; else sudo yum makecache -q -y && sudo yum --setopt=tsflags=noscripts install -q -y nvme-cli && sudo modprobe nvme-tcp; fi && if [ $? -eq 0 ]; then echo "nvme-cli install successfully"; else echo "nvme-cli install failed error code $?"; fi
spec:
selector:
matchLabels:
app: longhorn-nvme-cli-installation
template:
metadata:
labels:
app: longhorn-nvme-cli-installation
spec:
hostNetwork: true
hostPID: true
initContainers:
- name: nvme-cli-installation
command:
- nsenter
- --mount=/proc/1/ns/mnt
- --
- bash
- -c
- *cmd
image: alpine:3.12
securityContext:
privileged: true
containers:
- name: sleep
image: registry.k8s.io/pause:3.1
updateStrategy:
type: RollingUpdate