Skip to content

Commit

Permalink
docs: Add TUN device (#632)
Browse files Browse the repository at this point in the history
  • Loading branch information
kroese authored Dec 1, 2024
1 parent a53c6fa commit b01656a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 36 deletions.
1 change: 1 addition & 0 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ services:
BOOT: "https://dl-cdn.alpinelinux.org/alpine/v3.19/releases/x86_64/alpine-virt-3.19.1-x86_64.iso"
devices:
- /dev/kvm
- /dev/net/tun
cap_add:
- NET_ADMIN
ports:
Expand Down
77 changes: 42 additions & 35 deletions kubernetes.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: qemu-pvc
spec:
accessModes:
- ReadWriteOnce
- ReadWriteOnce
resources:
requests:
storage: 16Gi
Expand All @@ -16,47 +17,53 @@ metadata:
labels:
name: qemu
spec:
terminationGracePeriodSeconds: 120 # the Kubernetes default is 30 seconds and it may be not enough
containers:
- name: qemu
image: qemux/qemu-docker
ports:
- containerPort: 8006
protocol: TCP
securityContext:
privileged: true
env:
- name: BOOT
value: "https://dl-cdn.alpinelinux.org/alpine/v3.19/releases/x86_64/alpine-virt-3.19.1-x86_64.iso"
- name: RAM_SIZE
value: 1G
- name: CPU_CORES
value: "1"
- name: DISK_SIZE
value: "16G"
volumeMounts:
- mountPath: /storage
name: storage
- mountPath: /dev/kvm
name: dev-kvm
- name: qemu
image: qemux/qemu-docker
env:
- name: BOOT
value: "https://dl-cdn.alpinelinux.org/alpine/v3.19/releases/x86_64/alpine-virt-3.19.1-x86_64.iso"
- name: RAM_SIZE
value: "1G"
- name: CPU_CORES
value: "1"
- name: DISK_SIZE
value: "16G"
ports:
- containerPort: 8006
securityContext:
capabilities:
add:
- NET_ADMIN
privileged: true
volumeMounts:
- mountPath: /storage
name: storage
- mountPath: /dev/kvm
name: dev-kvm
- mountPath: /dev/net/tun
name: dev-tun
terminationGracePeriodSeconds: 120
volumes:
- name: storage
persistentVolumeClaim:
claimName: qemu-pvc
- name: dev-kvm
hostPath:
path: /dev/kvm
- name: storage
persistentVolumeClaim:
claimName: qemu-pvc
- hostPath:
path: /dev/kvm
name: dev-kvm
- hostPath:
path: /dev/net/tun
type: CharDevice
name: dev-tun
---
apiVersion: v1
kind: Service
metadata:
name: qemu
spec:
type: NodePort
ports:
- name: tcp-8006
port: 8006
selector:
name: qemu
ports:
- name: tcp-8006
protocol: TCP
port: 8006
targetPort: 8006
type: NodePort
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ services:
BOOT: "https://dl-cdn.alpinelinux.org/alpine/v3.19/releases/x86_64/alpine-virt-3.19.1-x86_64.iso"
devices:
- /dev/kvm
- /dev/net/tun
cap_add:
- NET_ADMIN
ports:
Expand All @@ -44,7 +45,7 @@ services:
Via Docker CLI:
```bash
docker run -it --rm -e "BOOT=http://example.com/image.iso" -p 8006:8006 --device=/dev/kvm --cap-add NET_ADMIN qemux/qemu-docker
docker run -it --rm -e "BOOT=http://example.com/image.iso" -p 8006:8006 --device=/dev/kvm --device=/dev/net/tun --cap-add NET_ADMIN qemux/qemu-docker
```

Via Kubernetes:
Expand Down

0 comments on commit b01656a

Please sign in to comment.