for i in `seq 0 49`
do
dd if=/dev/zero of=/var/lib/origin/loop/loop$i.img bs=100M count=10
losetup -fP /var/lib/origin/loop/loop$i.img
mkfs.ext4 -F /var/lib/origin/loop/loop$i.img
mkdir -p /mnt/local-storage/loop/disk$i
echo "/dev/loop$i /mnt/local-storage/loop/disk$i ext4 defaults 1 2" >> /etc/fstab
done
mount -a
chcon -R unconfined_u:object_r:svirt_sandbox_file_t:s0 /mnt/local-storage/
kubernetesMasterConfig:
apiServerArguments:
feature-gates:
- PersistentLocalVolumes=true
- VolumeScheduling=true
:
controllerArguments:
:
feature-gates:
- PersistentLocalVolumes=true
- VolumeScheduling=true
kubeletArguments:
:
feature-gates:
- PersistentLocalVolumes=true
- VolumeScheduling=true
{
"apiVersion": "v1",
"kind": "Policy",
"predicates": [
{
"name": "CheckVolumeBinding"
},
:
]
}
systemctl restart origin-master-api origin-master-controllers
systemctl restart origin-node
oc new-project local-storage
oc create serviceaccount local-storage-admin
oc adm policy add-scc-to-user privileged -z local-storage-admin
kind: ConfigMap
metadata:
name: local-volume-config
data:
"local-loop": |
{
"hostDir": "/mnt/local-storage/loop",
"mountDir": "/mnt/local-storage/loop"
}
oc create -f config.yaml
``
oc create -f https://raw.githubusercontent.com/openshift/origin/master/examples/storage-examples/local-examples/local-storage-provisioner-template.yaml
oc new-app -p CONFIGMAP=local-volume-config \
-p SERVICE_ACCOUNT=local-storage-admin \
-p NAMESPACE=local-storage \
-p PROVISIONER_IMAGE=quay.io/external_storage/local-volume-provisioner:v1.0.1 \
local-storage-provisioner
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: local-loop
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
oc create -f storage.yaml
oc patch storageclass local-loop -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
oc get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
local-pv-108b59fd 923928Ki RWO Delete Available local-loop 17h
local-pv-1097a6b3 923928Ki RWO Delete Available local-loop 17h
local-pv-1608a587 923928Ki RWO Delete Available local-loop 17h
local-pv-172068c5 923928Ki RWO Delete Available local-loop 17h
local-pv-17e07158 923928Ki RWO Delete Available local-loop 17h