Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add example of hostpath and nfs pv/pvc usage #788

Merged
merged 1 commit into from
Oct 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions examples/ubuntu-vm-hostpath-pv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: hostpath-dir-pvc
spec:
accessModes:
- ReadWriteOnce
# Set volumeMode to Filesystem so the VM can consume this PVC
# as a Filesystem device
volumeMode: Filesystem
storageClassName: local-storage
resources:
requests:
storage: 100Mi
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: hostpath-dir-pv
spec:
capacity:
storage: 100Mi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: local-storage
# Set volumeMode to Filesystem so the VM can consume this PV
# as a Filesystem device
volumeMode: Filesystem
hostPath:
# Use a path that's visible inside the Virtlet pod
# 9p mode must be supported in guest kernel in VM image
path: /var/lib/virtlet/hostpath
claimRef:
name: hostpath-dir-pvc
namespace: default
---
apiVersion: v1
kind: Pod
metadata:
name: ubuntu-vm-hostpath-dir-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
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
volumeMounts:
- mountPath: /home/ubuntu/hostpath
name: hostpathpvc
volumes:
- name: hostpathpvc
persistentVolumeClaim:
claimName: hostpath-dir-pvc
75 changes: 75 additions & 0 deletions examples/ubuntu-vm-nfs-pv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: nfs-dir-pvc
spec:
accessModes:
- ReadWriteOnce
# Set volumeMode to Filesystem so the VM can consume this PVC
# as a Filesystem device
volumeMode: Filesystem
storageClassName: local-storage
resources:
requests:
storage: 100Mi
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: nfs-dir-pv
spec:
capacity:
storage: 100Mi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: local-storage
# Set volumeMode to Filesystem so the VM can consume this PV
# as a Filesystem device
volumeMode: Filesystem
nfs:
# Use a path exposed in nfs server which has a ip 172.21.0.2(command: showmount -e 172.21.0.2)
# 9p mode must be supported in guest kernel in VM image
server: 172.21.0.2
path: /home/ubuntu/nfs/ubuntu-nfs
claimRef:
name: nfs-dir-pvc
namespace: default
---
apiVersion: v1
kind: Pod
metadata:
name: ubuntu-vm-nfs-dir-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
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
volumeMounts:
- mountPath: /home/ubuntu/nfspath
name: nfspvc
volumes:
- name: nfspvc
persistentVolumeClaim:
claimName: nfs-dir-pvc