From c07e6a48a1e25d8448a0c31eff75864cd468ccb4 Mon Sep 17 00:00:00 2001 From: yangchuanhu Date: Mon, 23 Jul 2018 10:32:43 +0800 Subject: [PATCH] add storage class yaml file --- storageclassdemo/class.yaml | 7 +++++ storageclassdemo/deployment.yaml | 32 ++++++++++++++++++++++ storageclassdemo/rbac.yaml | 37 ++++++++++++++++++++++++++ storageclassdemo/test-pod.yaml | 22 +++++++++++++++ storageclassdemo/test-pvc.yaml | 12 +++++++++ storageclassdemo/test-statefulset.yaml | 32 ++++++++++++++++++++++ 6 files changed, 142 insertions(+) create mode 100644 storageclassdemo/class.yaml create mode 100644 storageclassdemo/deployment.yaml create mode 100644 storageclassdemo/rbac.yaml create mode 100644 storageclassdemo/test-pod.yaml create mode 100644 storageclassdemo/test-pvc.yaml create mode 100644 storageclassdemo/test-statefulset.yaml diff --git a/storageclassdemo/class.yaml b/storageclassdemo/class.yaml new file mode 100644 index 0000000..0497ff8 --- /dev/null +++ b/storageclassdemo/class.yaml @@ -0,0 +1,7 @@ +apiVersion: storage.k8s.io/v1 +kind: StorageClass +metadata: + name: course-nfs-storage + annotations: + storageclass.kubernetes.io/is-default-class: true +provisioner: fuseim.pri/ifs diff --git a/storageclassdemo/deployment.yaml b/storageclassdemo/deployment.yaml new file mode 100644 index 0000000..eec02eb --- /dev/null +++ b/storageclassdemo/deployment.yaml @@ -0,0 +1,32 @@ +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: 10.151.30.57 + - name: NFS_PATH + value: /data/k8s + volumes: + - name: nfs-client-root + nfs: + server: 10.151.30.57 + path: /data/k8s \ No newline at end of file diff --git a/storageclassdemo/rbac.yaml b/storageclassdemo/rbac.yaml new file mode 100644 index 0000000..7ef0098 --- /dev/null +++ b/storageclassdemo/rbac.yaml @@ -0,0 +1,37 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: nfs-client-provisioner + +--- +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: nfs-client-provisioner-runner +rules: + - apiGroups: [""] + resources: ["persistentvolumes"] + verbs: ["get", "list", "watch", "create", "delete"] + - apiGroups: [""] + resources: ["persistentvolumeclaims"] + verbs: ["get", "list", "watch", "update"] + - apiGroups: ["storage.k8s.io"] + resources: ["storageclasses"] + verbs: ["get", "list", "watch"] + - apiGroups: [""] + resources: ["events"] + verbs: ["list", "watch", "create", "update", "patch"] + +--- +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: run-nfs-client-provisioner +subjects: + - kind: ServiceAccount + name: nfs-client-provisioner + namespace: default +roleRef: + kind: ClusterRole + name: nfs-client-provisioner-runner + apiGroup: rbac.authorization.k8s.io diff --git a/storageclassdemo/test-pod.yaml b/storageclassdemo/test-pod.yaml new file mode 100644 index 0000000..56fa3d2 --- /dev/null +++ b/storageclassdemo/test-pod.yaml @@ -0,0 +1,22 @@ +kind: Pod +apiVersion: v1 +metadata: + name: test-pod +spec: + containers: + - name: test-pod + image: busybox + imagePullPolicy: IfNotPresent + command: + - "/bin/sh" + args: + - "-c" + - "touch /mnt/SUCCESS && exit 0 || exit 1" + volumeMounts: + - name: nfs-pvc + mountPath: "/mnt" + restartPolicy: "Never" + volumes: + - name: nfs-pvc + persistentVolumeClaim: + claimName: test-pvc diff --git a/storageclassdemo/test-pvc.yaml b/storageclassdemo/test-pvc.yaml new file mode 100644 index 0000000..fa5a5d6 --- /dev/null +++ b/storageclassdemo/test-pvc.yaml @@ -0,0 +1,12 @@ +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: test-pvc + annotations: + volume.beta.kubernetes.io/storage-class: "course-nfs-storage" +spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 1Mi diff --git a/storageclassdemo/test-statefulset.yaml b/storageclassdemo/test-statefulset.yaml new file mode 100644 index 0000000..91679bd --- /dev/null +++ b/storageclassdemo/test-statefulset.yaml @@ -0,0 +1,32 @@ +apiVersion: apps/v1beta1 +kind: StatefulSet +metadata: + name: sc-demo +spec: + replicas: 3 + serviceName: "nginx" + template: + metadata: + labels: + app: sc-web + spec: + containers: + - name: nginx + image: nginx:1.7.9 + imagePullPolicy: IfNotPresent + ports: + - containerPort: 80 + volumeMounts: + - name: www + mountPath: /usr/share/nginx/html + volumeClaimTemplates: + - metadata: + name: www + annotations: + volume.beta.kubernetes.io/storage-class: "course-nfs-storage" + spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 1Mi \ No newline at end of file -- GitLab