-
Notifications
You must be signed in to change notification settings - Fork 128
/
ubuntu-vm-local-block-pv.yaml
88 lines (88 loc) · 2.74 KB
/
ubuntu-vm-local-block-pv.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: local-block-pvc
spec:
accessModes:
- ReadWriteOnce
# Set volumeMode to Block so the VM can consume this PVC
# as a block device
volumeMode: Block
storageClassName: local-storage
resources:
requests:
storage: 100Mi
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: local-block-pv
spec:
capacity:
storage: 100Mi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: local-storage
# Set volumeMode to Block so the VM can consume this PV
# as a block device
volumeMode: Block
local:
# Use a path to a file that's visible inside the Virtlet pod.
# When using kubeadm-dind-cluster, set it up with:
# docker exec kube-node-1 dd if=/dev/zero of=/var/lib/virtlet/looptest bs=1M count=1000
# docker exec kube-node-1 mkfs.ext4 /var/lib/virtlet/looptest
path: /var/lib/virtlet/looptest
claimRef:
name: local-block-pvc
namespace: default
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- kube-node-1
---
apiVersion: v1
kind: Pod
metadata:
name: ubuntu-vm-local-block-pv
annotations:
kubernetes.io/target-runtime: virtlet.cloud
VirtletSSHKeys: |
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCaJEcFDXEK2ZbX0ZLS1EIYFZRbDAcRfuVjpstSc0De8+sV1aiu+dePxdkuDRwqFtCyk6dEZkssjOkBXtri00MECLkir6FcH3kKOJtbJ6vy3uaJc9w1ERo+wyl6SkAh/+JTJkp7QRXj8oylW5E20LsbnA/dIwWzAF51PPwF7A7FtNg9DnwPqMkxFo1Th/buOMKbP5ZA1mmNNtmzbMpMfJATvVyiv3ccsSJKOiyQr6UG+j7sc/7jMVz5Xk34Vd0l8GwcB0334MchHckmqDB142h/NCWTr8oLakDNvkfC1YneAfAO41hDkUbxPtVBG5M/o7P4fxoqiHEX+ZLfRxDtHB53 me@localhost
# Here we use Cloud-Init mounts to mount the block device under /mnt
VirtletCloudInitUserData: |
mounts:
- ["/dev/testpvc", "/mnt"]
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: extraRuntime
operator: In
values:
- virtlet
# This is the number of seconds Virtlet gives the VM to shut down cleanly.
# The default value of 30 seconds is ok for containers but probably too
# low for VM, so overriding it here is strongly advised.
terminationGracePeriodSeconds: 120
containers:
- name: ubuntu-vm
image: virtlet.cloud/cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img
imagePullPolicy: IfNotPresent
# tty and stdin required for `kubectl attach -t` to work
tty: true
stdin: true
volumeDevices:
- devicePath: /dev/testpvc
name: testpvc
volumes:
- name: testpvc
persistentVolumeClaim:
claimName: local-block-pvc