Last active
February 2, 2022 16:45
-
-
Save j-griffith/f82bd567dc963ff953adcc44d0ebd96e to your computer and use it in GitHub Desktop.
Docker iscsi in container run cmd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This will use the hosts iscsid | |
docker run -it --net=host --privileged -v /etc/localtime:/etc/localtime:ro \ | |
-v /lib/modules:/lib/modules:ro \ | |
-v /run:/run:shared -v /dev:/dev \ | |
-v /etc/iscsi:/etc/iscsi \ | |
-v /home/jgriffith/vol:/Mount:shared ubuntu bash | |
# shared declaration on Mount matters! | |
# You can also put iscsid in another container, share the socket | |
# BUT make sure you do NOT run the iscsid on the host node |
@princerachit, I have success with that:
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: iscsi
spec:
updateStrategy:
type: OnDelete
selector:
matchLabels:
app: iscsi
template:
metadata:
labels:
app: iscsi
spec:
hostNetwork: true
initContainers:
- name: install
image: "kvaps/iscsi"
command:
- cp
args:
- -f
- /usr/bin/iscsiadm
- /usr/sbin/tgtadm
- /host-bin
volumeMounts:
- name: bin
mountPath: /host-bin
containers:
- name: tgtd
imagePullPolicy: Always
image: "kvaps/iscsi"
command: [ "tgtd", "-f" ]
securityContext:
privileged: true
volumeMounts:
- name: run
mountPath: "/run"
- name: iscsid
imagePullPolicy: Always
image: "kvaps/iscsi"
command: [ "iscsid", "-f" ]
securityContext:
privileged: true
volumeMounts:
- name: modules
mountPath: "/lib/modules"
- name: dev
mountPath: "/dev"
- name: run
mountPath: "/run"
volumes:
- name: modules
hostPath:
path: "/lib/modules"
- name: run
hostPath:
path: "/run"
- name: dev
hostPath:
path: "/dev"
- name: bin
hostPath:
path: "/usr/local/bin"
Nice, thanks for adding that @kvaps ! I'm afraid I never noticed the comments on this gist
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is it possible to run iscsid in a k8s' pod's container? What flags do I need to pass in that case (assuming that the container runs in privileged mode)?