From f370ae2977e8480da2627d10c5468c68c5c29549 Mon Sep 17 00:00:00 2001 From: pierre Date: Mon, 4 Nov 2024 23:51:32 +0000 Subject: [PATCH] enable storageclass to the synology --- nfs-storage-infrequent-access/class.yaml | 8 +++ nfs-storage-infrequent-access/deployment.yaml | 39 +++++++++++ .../kustomization.yaml | 4 ++ nfs-storage-infrequent-access/namespace.yaml | 5 ++ nfs-storage-infrequent-access/rbac.yaml | 68 +++++++++++++++++++ nfs-storage-infrequent-access/test-claim.yaml | 14 ++++ 6 files changed, 138 insertions(+) create mode 100644 nfs-storage-infrequent-access/class.yaml create mode 100644 nfs-storage-infrequent-access/deployment.yaml create mode 100644 nfs-storage-infrequent-access/kustomization.yaml create mode 100644 nfs-storage-infrequent-access/namespace.yaml create mode 100644 nfs-storage-infrequent-access/rbac.yaml create mode 100644 nfs-storage-infrequent-access/test-claim.yaml diff --git a/nfs-storage-infrequent-access/class.yaml b/nfs-storage-infrequent-access/class.yaml new file mode 100644 index 0000000..1ab6787 --- /dev/null +++ b/nfs-storage-infrequent-access/class.yaml @@ -0,0 +1,8 @@ +apiVersion: storage.k8s.io/v1 +kind: StorageClass +metadata: + name: nfs-storage-infrequentaccess +provisioner: k8s-sigs.io/nfs-subdir-external-provisioner-infrequentaccess # or choose another name, must match deployment's env PROVISIONER_NAME' +parameters: + archiveOnDelete: "false" + pathPattern: "${.PVC.annotations.fileType}/${.PVC.namespace}/${.PVC.name}" diff --git a/nfs-storage-infrequent-access/deployment.yaml b/nfs-storage-infrequent-access/deployment.yaml new file mode 100644 index 0000000..8120f11 --- /dev/null +++ b/nfs-storage-infrequent-access/deployment.yaml @@ -0,0 +1,39 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nfs-client-provisioner + labels: + app: nfs-client-provisioner + # replace with namespace where provisioner is deployed + namespace: nfs-provisioner-synology +spec: + replicas: 1 + strategy: + type: Recreate + selector: + matchLabels: + app: nfs-client-provisioner + template: + metadata: + labels: + app: nfs-client-provisioner + spec: + serviceAccountName: nfs-client-provisioner-infrequentaccess + containers: + - name: nfs-client-provisioner + image: registry.k8s.io/sig-storage/nfs-subdir-external-provisioner:v4.0.2 + volumeMounts: + - name: nfs-client-root + mountPath: /persistentvolumes + env: + - name: PROVISIONER_NAME + value: k8s-sigs.io/nfs-subdir-external-provisioner-infrequentaccess + - name: NFS_SERVER + value: 192.168.88.39 + - name: NFS_PATH + value: /volume2/kubernetes + volumes: + - name: nfs-client-root + nfs: + server: 192.168.88.39 + path: /volume2/kubernetes diff --git a/nfs-storage-infrequent-access/kustomization.yaml b/nfs-storage-infrequent-access/kustomization.yaml new file mode 100644 index 0000000..cb81386 --- /dev/null +++ b/nfs-storage-infrequent-access/kustomization.yaml @@ -0,0 +1,4 @@ +resources: + - class.yaml + - rbac.yaml + - deployment.yaml diff --git a/nfs-storage-infrequent-access/namespace.yaml b/nfs-storage-infrequent-access/namespace.yaml new file mode 100644 index 0000000..0e76e00 --- /dev/null +++ b/nfs-storage-infrequent-access/namespace.yaml @@ -0,0 +1,5 @@ +# namespace.yaml +apiVersion: v1 +kind: Namespace +metadata: + name: nfs-provisioner-synology diff --git a/nfs-storage-infrequent-access/rbac.yaml b/nfs-storage-infrequent-access/rbac.yaml new file mode 100644 index 0000000..44b5f8c --- /dev/null +++ b/nfs-storage-infrequent-access/rbac.yaml @@ -0,0 +1,68 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: nfs-client-provisioner-infrequentaccess + # replace with namespace where provisioner is deployed + namespace: nfs-provisioner-synology +--- +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: nfs-client-provisioner-runner +rules: + - apiGroups: [""] + resources: ["nodes"] + verbs: ["get", "list", "watch"] + - 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: ["create", "update", "patch"] +--- +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: run-nfs-client-provisioner-infrequentaccess +subjects: + - kind: ServiceAccount + name: nfs-client-provisioner-infrequentaccess + # replace with namespace where provisioner is deployed + namespace: nfs-provisioner-synology +roleRef: + kind: ClusterRole + name: nfs-client-provisioner-runner + apiGroup: rbac.authorization.k8s.io +--- +kind: Role +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: leader-locking-nfs-client-provisioner + # replace with namespace where provisioner is deployed + namespace: nfs-provisioner-synology +rules: + - apiGroups: [""] + resources: ["endpoints"] + verbs: ["get", "list", "watch", "create", "update", "patch"] +--- +kind: RoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: leader-locking-nfs-client-provisioner + # replace with namespace where provisioner is deployed + namespace: nfs-provisioner-synology +subjects: + - kind: ServiceAccount + name: nfs-client-provisioner-infrequentaccess + # replace with namespace where provisioner is deployed + namespace: nfs-provisioner-synology +roleRef: + kind: Role + name: leader-locking-nfs-client-provisioner + apiGroup: rbac.authorization.k8s.io diff --git a/nfs-storage-infrequent-access/test-claim.yaml b/nfs-storage-infrequent-access/test-claim.yaml new file mode 100644 index 0000000..c4d8341 --- /dev/null +++ b/nfs-storage-infrequent-access/test-claim.yaml @@ -0,0 +1,14 @@ +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: test-claim + annotations: + fileType : "Backup" +spec: + storageClassName: nfs-storage-infrequentaccess + accessModes: + - ReadWriteMany + resources: + requests: + storage: 1Mi +---