# oc adm policy add-cluster-role-to-user sudoer admin
# oc create sa anyuid
# oc adm policy add-scc-to-user anyuid -z anyuid --as=system:admin
# Don't forget: chcon -Rt svirt_sandbox_file_t /pv/hostpath-example
oc create -f - <<EOF
apiVersion: v1
kind: PersistentVolume
metadata:
creationTimestamp: null
name: hostpath-var-log
spec:
accessModes:
- ReadWriteOnce
capacity:
storage: 100Mi
hostPath:
path: /var/log
persistentVolumeReclaimPolicy: Retain
EOF
oc create -f - <<EOF
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: hostpath
spec:
accessModes: [ "ReadWriteMany" ]
resources:
requests:
storage: 100Mi
EOF
oc create -f - <<EOF
apiVersion: v1
kind: Pod
metadata:
name: busybox-hostpath
spec:
containers:
- name: busybox-hostpath
image: busybox
command: [ "/bin/sh", "-c", "while true ; do date; sleep 1; done;" ]
volumeMounts:
- mountPath: /hostpath
name: hostpath
volumes:
- name: hostpath
persistentVolumeClaim:
claimName: hostpath
restartPolicy: Never
EOF