diff --git a/cluster/nfs-storage/class.yaml b/cluster/nfs-storage/class.yaml new file mode 100644 index 0000000..d02695c --- /dev/null +++ b/cluster/nfs-storage/class.yaml @@ -0,0 +1,7 @@ +apiVersion: storage.k8s.io/v1 +kind: StorageClass +metadata: + name: synology-nfs +provisioner: storage.io/nfs +parameters: + archiveOnDelete: "false" diff --git a/cluster/nfs-storage/deployment.yaml b/cluster/nfs-storage/deployment.yaml new file mode 100644 index 0000000..74ba40e --- /dev/null +++ b/cluster/nfs-storage/deployment.yaml @@ -0,0 +1,38 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nfs-client-provisioner + labels: + app: nfs-client-provisioner + namespace: openshift-nfs-storage +spec: + replicas: 1 + strategy: + type: Recreate + selector: + matchLabels: + app: nfs-client-provisioner + template: + metadata: + labels: + app: nfs-client-provisioner + spec: + serviceAccountName: nfs-client-provisioner + containers: + - name: nfs-client-provisioner + image: gcr.io/k8s-staging-sig-storage/nfs-subdir-external-provisioner:v4.0.0 + volumeMounts: + - name: nfs-client-root + mountPath: /persistentvolumes + env: + - name: PROVISIONER_NAME + value: storage.io/nfs + - name: NFS_SERVER + value: 10.10.121.35 + - name: NFS_PATH + value: /volume1/nfs-ocp + volumes: + - name: nfs-client-root + nfs: + server: 10.10.121.35 + path: /volume1/nfs-ocp diff --git a/cluster/nfs-storage/kustomization.yaml b/cluster/nfs-storage/kustomization.yaml new file mode 100644 index 0000000..531c63e --- /dev/null +++ b/cluster/nfs-storage/kustomization.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: +- namespace.yaml +- rbac.yaml +- class.yaml +- deployment.yaml \ No newline at end of file diff --git a/cluster/nfs-storage/namespace.yaml b/cluster/nfs-storage/namespace.yaml new file mode 100644 index 0000000..1333019 --- /dev/null +++ b/cluster/nfs-storage/namespace.yaml @@ -0,0 +1,13 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + labels: + kubernetes.io/metadata.name: openshift-nfs-storage + name: oopenshift-nfs-storage + argocd.argoproj.io/managed-by: openshift-gitops-operator +# openshift.io/cluster-monitoring: true + name: openshift-nfs-storage +spec: + finalizers: + - kubernetes diff --git a/cluster/nfs-storage/nfs-storage.yaml b/cluster/nfs-storage/nfs-storage.yaml new file mode 100644 index 0000000..59aa1d7 --- /dev/null +++ b/cluster/nfs-storage/nfs-storage.yaml @@ -0,0 +1,33 @@ +--- +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: nfs-storage + finalizers: + - resources-finalizer.argocd.argoproj.io + annotations: + argocd.argoproj.io/sync-wave: "2" +spec: + destination: + name: in-cluster + namespace: openshift-nfs-storage + project: default + source: + path: cluster-applications/nfs-storage + repoURL: git@github.com:rblundon/MK-Labs.git + targetRevision: HEAD + syncPolicy: + automated: + prune: true + selfHeal: true + syncOptions: + - RespectIgnoreDifferences=true + - CreateNamespace=true + managedNamespaceMetadata: + labels: + argocd.argoproj.io/managed-by: openshift-gitops + ignoreDifferences: + - group: apps + kind: Deployment + jsonPointers: + - /spec/replicas \ No newline at end of file diff --git a/cluster/nfs-storage/rbac.yaml b/cluster/nfs-storage/rbac.yaml new file mode 100644 index 0000000..739d05b --- /dev/null +++ b/cluster/nfs-storage/rbac.yaml @@ -0,0 +1,80 @@ +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: nfs-client-provisioner + namespace: openshift-nfs-storage + +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +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: ["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: openshift-nfs-storage +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 + namespace: openshift-nfs-storage +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 + namespace: openshift-nfs-storage +subjects: + - kind: ServiceAccount + name: nfs-client-provisioner + namespace: openshift-nfs-storage +roleRef: + kind: Role + name: leader-locking-nfs-client-provisioner + apiGroup: rbac.authorization.k8s.io + +--- +apiVersion: authorization.openshift.io/v1 +kind: RoleBinding +metadata: + name: nfs-client-provisioner-scc + namespace: openshift-nfs-storage +roleRef: +# apiGroup: rbac.authorization.k8s.io +# kind: ClusterRole + name: system:openshift:scc:hostmount-anyuid +subjects: +- kind: ServiceAccount + name: nfs-client-provisioner + namespace: openshift-nfs-storage \ No newline at end of file diff --git a/cluster/nfs-storage/sa.yaml b/cluster/nfs-storage/sa.yaml new file mode 100644 index 0000000..456a7d1 --- /dev/null +++ b/cluster/nfs-storage/sa.yaml @@ -0,0 +1,15 @@ +--- +apiVersion: authorization.openshift.io/v1 +kind: RoleBinding +metadata: + name: nfs-client-provisioner-scc + namespace: openshift-nfs-storage +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: system:openshift:scc:hostmount-anyuid + #name: system:openshift:$NAMESPACE:hostmount-anyuid +subjects: +- kind: ServiceAccount + name: nfs-client-provisioner + namespace: openshift-nfs-storage diff --git a/cluster/nfs-storage/test-claim.yaml b/cluster/nfs-storage/test-claim.yaml new file mode 100644 index 0000000..3879ee3 --- /dev/null +++ b/cluster/nfs-storage/test-claim.yaml @@ -0,0 +1,11 @@ +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: test-claim +spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 1Mi + storageClassName: synology-nfs diff --git a/cluster/nfs-storage/test-pod.yaml b/cluster/nfs-storage/test-pod.yaml new file mode 100644 index 0000000..e5e7b7f --- /dev/null +++ b/cluster/nfs-storage/test-pod.yaml @@ -0,0 +1,21 @@ +kind: Pod +apiVersion: v1 +metadata: + name: test-pod +spec: + containers: + - name: test-pod + image: gcr.io/google_containers/busybox:1.24 + 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-claim diff --git a/cluster/synology-storageclass/storage-class.yaml b/cluster/synology-storageclass/storage-class.yaml index 011a477..b43bd80 100644 --- a/cluster/synology-storageclass/storage-class.yaml +++ b/cluster/synology-storageclass/storage-class.yaml @@ -15,18 +15,18 @@ parameters: reclaimPolicy: Delete #Retain allowVolumeExpansion: true ---- -apiVersion: storage.k8s.io/v1 -kind: StorageClass -metadata: - name: synology-nfs-storage -provisioner: csi.san.synology.com -parameters: - protocol: "nfs" - dsm: '10.10.121.35' - location: '/volume1' - mountPermissions: '0777' -mountOptions: - - nfsvers=4 -reclaimPolicy: Delete -allowVolumeExpansion: true \ No newline at end of file +# --- +# apiVersion: storage.k8s.io/v1 +# kind: StorageClass +# metadata: +# name: synology-nfs-storage +# provisioner: csi.san.synology.com +# parameters: +# protocol: "nfs" +# dsm: '10.10.121.35' +# location: '/volume1' +# mountPermissions: '0777' +# mountOptions: +# - nfsvers=4 +# reclaimPolicy: Delete +# allowVolumeExpansion: true \ No newline at end of file