openshift 使用 NFS StorageClass

原来一直使用ceph 的 storageclass,但是openshift 不支持cephfs的 storageclass,只支持rbd方式的storageclass,这样就带来了一个问题就是,无法创建支持 RWM 方式的pv,因此在各种数据库,各种pod里,重建pod的时候,基本会卡住,等待umount,或者是无法创建多pod副本,因此就改了一个nfs storageclass 来用

老外的文档在这里

https://github.com/kubernetes-incubator/external-storage/tree/master/nfs-client

但是实际使用 应该

git clone https://github.com/kubernetes-incubator/external-storage

然后按文档来吧

OpenShift:

On some installations of OpenShift the default admin user does not have cluster-admin permissions. If these commands fail refer to the OpenShift documentation for User and Role Management or contact your OpenShift provider to help you grant the right permissions to your admin user.

Set the subject of the RBAC objects to the current namespace where the provisioner is being deployed

sed -i'' "s/namespace:.*/namespace: oc create -f deploy/rbac.yaml
NAMESPACE:nfs-client-provisioner
Step 4: Configure the NFS-Client provisioner

Note: To deploy to an ARM-based environment, use: deploy/deployment-arm.yaml instead, otherwise use deploy/deployment.yaml.

Next you must edit the provisioner's deployment file to add connection information for your NFS server. Edit deploy/deployment.yaml and replace the two occurences of with your server's hostname.

kind: Deployment
apiVersion: extensions/v1beta1
metadata:
name: nfs-client-provisioner
spec:
replicas: 1
strategy:
type: Recreate
template:
metadata:
labels:
app: nfs-client-provisioner
spec:
serviceAccountName: nfs-client-provisioner
containers:
- name: nfs-client-provisioner
image: quay.io/external_storage/nfs-client-provisioner:latest
volumeMounts:
- name: nfs-client-root
mountPath: /persistentvolumes
env:
- name: PROVISIONER_NAME
value: fuseim.pri/ifs
- name: NFS_SERVER
value:
- name: NFS_PATH
value: /var/nfs
volumes:
- name: nfs-client-root
nfs:
server:
path: /var/nfs
You may also want to change the PROVISIONER_NAME above from fuseim.pri/ifs to something more descriptive like nfs-storage, but if you do remember to also change the PROVISIONER_NAME in the storage class definition below:

This is deploy/class.yaml which defines the NFS-Client's Kubernetes Storage Class:

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: managed-nfs-storage
provisioner: fuseim.pri/ifs # or choose another name, must match deployment's env PROVISIONER_NAME'
parameters:
archiveOnDelete: "false" # When set to "false" your PVs will not be archived
# by the provisioner upon deletion of the PVC.
Step 5: Finally, test your environment!

Now we'll test your NFS provisioner.

Deploy:

$ kubectl create -f deploy/test-claim.yaml -f deploy/test-pod.yaml
Now check your NFS Server for the file SUCCESS.

kubectl delete -f deploy/test-pod.yaml -f deploy/test-claim.yaml
Now check the folder has been deleted.

Step 6: Deploying your own PersistentVolumeClaims. To deploy your own PVC, make sure that you have the correct storage-class as indicated by your deploy/class.yaml file.

For example:

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: test-claim
annotations:
volume.beta.kubernetes.io/storage-class: "managed-nfs-storage"
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Mi

你可能感兴趣的:(openshift 使用 NFS StorageClass)