Mounting Volumes on Privileged Pods
You are viewing documentation for a release that is no longer supported. The latest supported version of version 3 is [3.11]. For the most recent version 4, see
Persistent volumes can be mounted to pods with the privileged security context constraint (SCC) attached.
Prerequisites
An existing Gluster volume.
glusterfs-fuse installed on all hosts.
Definitions for GlusterFS:
: gluster-endpoints-service.yaml and gluster-endpoints.yaml
Persistent volumes: gluster-pv.yaml
: gluster-pvc.yaml
A user with the cluster-admin role binding. For this guide, that user is called .
Creating the PersistentVolume makes the storage accessible to users, regardless of projects.
As the admin, create the service, endpoint object, and persistent volume:
Verify that the objects were created:
$ oc get svc
NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE
gluster-cluster 172.30.151.58 <none> 1/TCP <none> 24s
NAME ENDPOINTS AGE
gluster-cluster 192.168.59.102:1,192.168.59.103:1 2m
$ oc get pv
NAME LABELS CAPACITY ACCESSMODES STATUS CLAIM REASON AGE
gluster-default-volume <none> 2Gi RWX Available 2d
Creating a Regular User
Adding a regular user to the privileged SCC (or to a group given access to the SCC) allows them to run privileged pods:
As the admin, add a user to the SCC:
$ oc adm policy add-scc-to-user privileged <username>
Log in as the regular user:
Then, create a new project:
$ oc new-project <project_name>
As a regular user, create the PersistentVolumeClaim to access the volume:
$ oc create -f gluster-pvc.yaml -n <project_name>
-
Example 1. Pod Definition
id: gluster-S3-pvc
kind: Pod
metadata:
name: gluster-nginx-priv
spec:
containers:
- name: gluster-nginx-priv
volumeMounts:
- mountPath: /mnt/gluster (1)
name: gluster-volume-claim
securityContext:
volumes:
- name: gluster-volume-claim
persistentVolumeClaim:
claimName: gluster-claim (2)
1 Volume mount within the pod. 2 The gluster-claim must reflect the name of the PersistentVolume. Upon pod creation, the mount directory is created and the volume is attached to that mount point.
As regular user, create a pod from the definition:
$ oc create -f gluster-S3-pod.yaml
Verify that the pod created successfully:
It can take several minutes for the pod to create.
Verifying the Setup
Export the pod configuration:
$ oc get -o yaml --export pod <pod_name>
Examine the output. Check that
openshift.io/scc
has the value ofprivileged
:Example 2. Export Snippet
metadata:
annotations:
openshift.io/scc: privileged
Verifying the Mount
Access the pod and check that the volume is mounted:
$ oc rsh <pod_name>