Skip to content

Instantly share code, notes, and snippets.

@dmc5179
Last active December 8, 2019 16:30
Show Gist options
  • Save dmc5179/b5d06b8149581e12374284fb3b9c3866 to your computer and use it in GitHub Desktop.
Save dmc5179/b5d06b8149581e12374284fb3b9c3866 to your computer and use it in GitHub Desktop.
OpenShift Local Storage Class

OpenShift 3.11 Local Storage Class

ConfigMap and Storage Class YAML to create a local SSD Storage Class

Getting Started

These instructions will configure and enable a local storage class in OpenShift 3.11. This allows for an SSD EBS volume to be attached to the node and mounted directly by pods on that node

Prerequisites

  • OpenShift Cluster
  • OC command line tool

Ensure EBS Volume is mounted in the correct location

Make sure the EBS volume is mounted to the host in the right path

/mnt/local-storage/ssd/disk#

SELinux

Change the SELinux labels so OCP can see the new EBS volume

chcon -R unconfined_u:object_r:svirt_sandbox_file_t:s0 /mnt/local-storage/

Create local storage project and configure

oc new-project local-storage
oc create serviceaccount local-storage-admin
oc adm policy add-scc-to-user privileged -z local-storage-admin
oc create -f https://raw.githubusercontent.com/openshift/origin/release-3.11/examples/storage-examples/local-examples/local-storage-provisioner-template.yaml
oc create -f https://gist.githubusercontent.com/dmc5179/b5d06b8149581e12374284fb3b9c3866/raw/eca531d06334510e0364c8014d94d7b466bfc9a5/local_volume_configmap.yaml
oc new-app -p CONFIGMAP=local-volume-config -p SERVICE_ACCOUNT=local-storage-admin -p NAMESPACE=local-storage -p PROVISIONER_IMAGE=registry.redhat.io/openshift3/local-storage-provisioner:v3.11   local-storage-provisioner

oc create -f https://gist.githubusercontent.com/dmc5179/b5d06b8149581e12374284fb3b9c3866/raw/eca531d06334510e0364c8014d94d7b466bfc9a5/storage-class-ssd.yaml

apiVersion: v1
kind: ConfigMap
metadata:
name: local-volume-config
data:
storageClassMap: |
local-ssd:
hostDir: /mnt/local-storage/ssd
mountDir: /mnt/local-storage/ssd
local-hdd:
hostDir: /mnt/local-storage/hdd
mountDir: /mnt/local-storage/hdd
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: local-ssd
provisioner: kubernetes.io/no-provisioner
reclaimPolicy: Delete
volumeBindingMode: Immediate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment