├── .dockerignore ├── .github ├── ISSUE_TEMPLATE │ └── bug_report.md └── workflows │ ├── build.yml │ ├── functests.yml │ ├── linters.yml │ └── vulncheck.yml ├── .gitignore ├── .golangci.yml ├── .goreleaser.yml ├── AlmaLinux.repo ├── CREDITS ├── Dockerfile ├── LICENSE ├── README.md ├── apparmor.profile ├── boilerplate.go.txt ├── build.sh ├── cmd ├── directpv │ ├── controller.go │ ├── grpc.go │ ├── legacy-controller.go │ ├── legacy-node-server.go │ ├── main.go │ ├── node-controller.go │ ├── node-server.go │ ├── ready.go │ └── repair.go └── kubectl-directpv │ ├── clean.go │ ├── cordon.go │ ├── discover.go │ ├── flags.go │ ├── info.go │ ├── init.go │ ├── install.go │ ├── label.go │ ├── label_drives.go │ ├── label_volumes.go │ ├── list.go │ ├── list_drives.go │ ├── list_volumes.go │ ├── main.go │ ├── migrate.go │ ├── move.go │ ├── progress_model.go │ ├── remove.go │ ├── repair.go │ ├── resume.go │ ├── resume_drives.go │ ├── resume_volumes.go │ ├── suspend.go │ ├── suspend_drives.go │ ├── suspend_volumes.go │ ├── uncordon.go │ ├── uninstall.go │ └── utils.go ├── codecov.yaml ├── codegen.sh ├── docs ├── README.md ├── admin.md ├── architecture.md ├── command-reference.md ├── developer.md ├── drive-management.md ├── faq.md ├── images │ ├── architecture.png │ ├── architecture.svg │ ├── directpv_architecture.png │ └── directpv_architecture.svg ├── installation.md ├── issue-reporting.md ├── monitoring.md ├── node-management.md ├── openshift.md ├── specification.md ├── tools │ ├── create-storage-class.sh │ ├── install.sh │ ├── migrate.sh │ ├── push-images.sh │ ├── remove-directcsi.sh │ ├── remove-node.sh │ ├── repair.sh │ └── replace.sh ├── upgrade.md ├── volume-management.md ├── volume-provisioning.md └── volume-scheduling.md ├── functests ├── Dockerfile.sleep ├── common.sh ├── execute.sh ├── migration-tests.sh ├── minio.yaml ├── multi-node-tests.sh ├── run-migration-tests.sh ├── run-multi-node-tests.sh ├── run-tests.sh ├── sleep.yaml └── tests.sh ├── go.mod ├── go.sum ├── package.sh ├── pkg ├── admin │ ├── clean.go │ ├── client.go │ ├── cordon.go │ ├── info.go │ ├── init_config.go │ ├── init_config_v1.go │ ├── install.go │ ├── installer │ │ ├── args.go │ │ ├── consts.go │ │ ├── crd.go │ │ ├── csidriver.go │ │ ├── daemonset.go │ │ ├── deployment.go │ │ ├── directpv.min.io_directpvdrives.yaml │ │ ├── directpv.min.io_directpvinitrequests.yaml │ │ ├── directpv.min.io_directpvnodes.yaml │ │ ├── directpv.min.io_directpvvolumes.yaml │ │ ├── installer.go │ │ ├── installer_test.go │ │ ├── migrate.go │ │ ├── migrate_test.go │ │ ├── namespace.go │ │ ├── progress.go │ │ ├── rbac.go │ │ ├── storageclass.go │ │ ├── utils.go │ │ └── vars.go │ ├── label_drives.go │ ├── label_volumes.go │ ├── logger.go │ ├── migrate.go │ ├── move.go │ ├── refresh.go │ ├── remove.go │ ├── repair.go │ ├── resume_drives.go │ ├── resume_volumes.go │ ├── suspend_drives.go │ ├── suspend_volumes.go │ ├── uncordon.go │ └── uninstall.go ├── apis │ └── directpv.min.io │ │ ├── types │ │ ├── label.go │ │ └── types.go │ │ └── v1beta1 │ │ ├── deepcopy_generated.go │ │ ├── doc.go │ │ ├── drive.go │ │ ├── init_request.go │ │ ├── node.go │ │ ├── openapi_generated.go │ │ ├── register.go │ │ └── volume.go ├── client │ ├── clients.go │ ├── discovery.go │ ├── drive_lister.go │ ├── drive_lister_test.go │ ├── dynamic.go │ ├── dynamic_test.go │ ├── event.go │ ├── fake.go │ ├── init.go │ ├── init_test.go │ ├── initrequest_lister.go │ ├── node_lister.go │ ├── scheme.go │ ├── volume_lister.go │ └── volume_lister_test.go ├── clientset │ ├── clientset.go │ ├── fake │ │ ├── clientset_generated.go │ │ ├── doc.go │ │ └── register.go │ ├── scheme │ │ ├── doc.go │ │ └── register.go │ └── typed │ │ └── directpv.min.io │ │ └── v1beta1 │ │ ├── directpv.min.io_client.go │ │ ├── directpvdrive.go │ │ ├── directpvinitrequest.go │ │ ├── directpvnode.go │ │ ├── directpvvolume.go │ │ ├── doc.go │ │ ├── fake │ │ ├── doc.go │ │ ├── fake_directpv.min.io_client.go │ │ ├── fake_directpvdrive.go │ │ ├── fake_directpvinitrequest.go │ │ ├── fake_directpvnode.go │ │ └── fake_directpvvolume.go │ │ └── generated_expansion.go ├── consts │ ├── consts.go │ └── consts.go.in ├── controller │ ├── controller.go │ └── controller_test.go ├── converter │ ├── converter.go │ ├── converter_test.go │ ├── drive_downgrade.go │ ├── drive_upgrade.go │ ├── init_request_downgrade.go │ ├── init_request_upgrade.go │ ├── node_downgrade.go │ ├── node_upgrade.go │ ├── volume_downgrade.go │ └── volume_upgrade.go ├── csi │ ├── controller │ │ ├── legacy_server.go │ │ ├── server.go │ │ ├── server_test.go │ │ ├── utils.go │ │ └── utils_test.go │ ├── identity │ │ └── identity.go │ └── node │ │ ├── fake.go │ │ ├── legacy_server.go │ │ ├── publish_unpublish.go │ │ ├── publish_unpublish_test.go │ │ ├── server.go │ │ ├── server_test.go │ │ ├── stage_unstage.go │ │ └── stage_unstage_test.go ├── device │ ├── probe.go │ ├── probe_linux.go │ ├── probe_other.go │ ├── probe_test.go │ ├── procfs_linux.go │ ├── sync.go │ ├── sync_test.go │ ├── sysfs_linux.go │ ├── udev_linux.go │ └── utils.go ├── drive │ ├── event.go │ └── repair.go ├── ellipsis │ ├── ellipsis.go │ └── ellipsis_test.go ├── initrequest │ ├── event.go │ ├── reflink_linux.go │ └── reflink_other.go ├── k8s │ ├── client.go │ ├── fake.go │ ├── init.go │ ├── k8s.go │ └── k8s_test.go ├── legacy │ ├── apis │ │ └── direct.csi.min.io │ │ │ ├── v1alpha1 │ │ │ ├── deepcopy_generated.go │ │ │ ├── doc.go │ │ │ ├── openapi_generated.go │ │ │ ├── register.go │ │ │ └── types.go │ │ │ ├── v1beta1 │ │ │ ├── conversion_generated.go │ │ │ ├── deepcopy_generated.go │ │ │ ├── doc.go │ │ │ ├── openapi_generated.go │ │ │ ├── register.go │ │ │ └── types.go │ │ │ ├── v1beta2 │ │ │ ├── conversion_generated.go │ │ │ ├── deepcopy_generated.go │ │ │ ├── doc.go │ │ │ ├── openapi_generated.go │ │ │ ├── register.go │ │ │ └── types.go │ │ │ ├── v1beta3 │ │ │ ├── conversion_generated.go │ │ │ ├── deepcopy_generated.go │ │ │ ├── doc.go │ │ │ ├── openapi_generated.go │ │ │ ├── register.go │ │ │ └── types.go │ │ │ ├── v1beta4 │ │ │ ├── conversion_generated.go │ │ │ ├── deepcopy_generated.go │ │ │ ├── doc.go │ │ │ ├── openapi_generated.go │ │ │ ├── register.go │ │ │ └── types.go │ │ │ └── v1beta5 │ │ │ ├── conversion_generated.go │ │ │ ├── deepcopy_generated.go │ │ │ ├── doc.go │ │ │ ├── openapi_generated.go │ │ │ ├── register.go │ │ │ └── types.go │ ├── client │ │ ├── client.go │ │ ├── fake.go │ │ ├── init.go │ │ ├── interface.go │ │ └── list.go │ ├── clientset │ │ ├── clientset.go │ │ ├── doc.go │ │ ├── fake │ │ │ ├── clientset_generated.go │ │ │ ├── doc.go │ │ │ └── register.go │ │ ├── scheme │ │ │ ├── doc.go │ │ │ └── register.go │ │ └── typed │ │ │ └── direct.csi.min.io │ │ │ ├── v1alpha1 │ │ │ ├── direct.csi.min.io_client.go │ │ │ ├── directcsidrive.go │ │ │ ├── directcsivolume.go │ │ │ ├── doc.go │ │ │ ├── fake │ │ │ │ ├── doc.go │ │ │ │ ├── fake_direct.csi.min.io_client.go │ │ │ │ ├── fake_directcsidrive.go │ │ │ │ └── fake_directcsivolume.go │ │ │ └── generated_expansion.go │ │ │ ├── v1beta1 │ │ │ ├── direct.csi.min.io_client.go │ │ │ ├── directcsidrive.go │ │ │ ├── directcsivolume.go │ │ │ ├── doc.go │ │ │ ├── fake │ │ │ │ ├── doc.go │ │ │ │ ├── fake_direct.csi.min.io_client.go │ │ │ │ ├── fake_directcsidrive.go │ │ │ │ └── fake_directcsivolume.go │ │ │ └── generated_expansion.go │ │ │ ├── v1beta2 │ │ │ ├── direct.csi.min.io_client.go │ │ │ ├── directcsidrive.go │ │ │ ├── directcsivolume.go │ │ │ ├── doc.go │ │ │ ├── fake │ │ │ │ ├── doc.go │ │ │ │ ├── fake_direct.csi.min.io_client.go │ │ │ │ ├── fake_directcsidrive.go │ │ │ │ └── fake_directcsivolume.go │ │ │ └── generated_expansion.go │ │ │ ├── v1beta3 │ │ │ ├── direct.csi.min.io_client.go │ │ │ ├── directcsidrive.go │ │ │ ├── directcsivolume.go │ │ │ ├── doc.go │ │ │ ├── fake │ │ │ │ ├── doc.go │ │ │ │ ├── fake_direct.csi.min.io_client.go │ │ │ │ ├── fake_directcsidrive.go │ │ │ │ └── fake_directcsivolume.go │ │ │ └── generated_expansion.go │ │ │ ├── v1beta4 │ │ │ ├── direct.csi.min.io_client.go │ │ │ ├── directcsidrive.go │ │ │ ├── directcsivolume.go │ │ │ ├── doc.go │ │ │ ├── fake │ │ │ │ ├── doc.go │ │ │ │ ├── fake_direct.csi.min.io_client.go │ │ │ │ ├── fake_directcsidrive.go │ │ │ │ └── fake_directcsivolume.go │ │ │ └── generated_expansion.go │ │ │ └── v1beta5 │ │ │ ├── direct.csi.min.io_client.go │ │ │ ├── directcsidrive.go │ │ │ ├── directcsivolume.go │ │ │ ├── doc.go │ │ │ ├── fake │ │ │ ├── doc.go │ │ │ ├── fake_direct.csi.min.io_client.go │ │ │ ├── fake_directcsidrive.go │ │ │ └── fake_directcsivolume.go │ │ │ └── generated_expansion.go │ └── converter │ │ ├── convert.go │ │ ├── converter_test.go │ │ ├── drive_downgrade.go │ │ ├── drive_upgrade.go │ │ ├── framework.go │ │ ├── label.go │ │ ├── sys.go │ │ ├── volume_downgrade.go │ │ └── volume_upgrade.go ├── metrics │ ├── collector.go │ ├── collector_test.go │ └── metrics.go ├── node │ ├── event.go │ └── sync.go ├── sys │ ├── fake.go │ ├── mkdir.go │ ├── mount.go │ ├── mount_linux.go │ └── mount_other.go ├── types │ ├── aliases.go │ ├── aliases.go.in │ ├── fake.go │ └── types.go ├── utils │ └── utils.go ├── volume │ ├── event.go │ └── event_test.go └── xfs │ ├── empty.testdata │ ├── mkfs.go │ ├── mkfs_linux.go │ ├── mkfs_other.go │ ├── mount.go │ ├── mount_linux.go │ ├── mount_other.go │ ├── probe.go │ ├── probe_linux.go │ ├── probe_linux_test.go │ ├── probe_other.go │ ├── quota.go │ ├── quota_linux.go │ ├── quota_other.go │ ├── repair.go │ ├── repair_linux.go │ ├── repair_other.go │ ├── xfs.testdata │ └── zero.testdata ├── resources ├── base │ ├── CSIDriver.yaml │ ├── ClusterRole.yaml │ ├── ClusterRoleBinding.yaml │ ├── DaemonSet.yaml │ ├── Deployment.yaml │ ├── Namespace.yaml │ ├── Role.yaml │ ├── RoleBinding.yaml │ ├── ServiceAccount.yaml │ ├── StorageClass.yaml │ ├── directpvdrives.directpv.min.io.yaml │ ├── directpvinitrequests.directpv.min.io.yaml │ ├── directpvnodes.directpv.min.io.yaml │ ├── directpvvolumes.directpv.min.io.yaml │ └── kustomization.yaml ├── legacy │ ├── CSIDriver.yaml │ ├── DaemonSet.yaml │ ├── Deployment.yaml │ ├── StorageClass.yaml │ └── kustomization.yaml ├── openshift-with-legacy │ └── kustomization.yaml ├── openshift │ └── kustomization.yaml └── v4.0 │ ├── base │ └── kustomization.yaml │ ├── legacy │ └── kustomization.yaml │ ├── openshift-with-legacy │ └── kustomization.yaml │ ├── openshift │ └── kustomization.yaml │ └── psp │ ├── PodSecurityPolicy-ClusterRoleBinding.yaml │ ├── PodSecurityPolicy.yaml │ └── kustomization.yaml ├── seccomp.json └── sidecars ├── release-csi-external-health-monitor-controller.sh ├── release-csi-provisioner.sh ├── release-csi-resizer.sh ├── release-livenessprobe.sh ├── release-node-driver-registrar.sh └── release.sh /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | .github 3 | docs 4 | default.etcd 5 | *.gz 6 | *.tar.gz 7 | *.bzip2 8 | *.zip 9 | dist/ 10 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 16 | **Expected behavior** 17 | A clear and concise description of what you expected to happen. 18 | 19 | **Screenshots and logs** 20 | 21 | If applicable, add screenshots to help explain your problem. Or logs from the pods in directpv-min-io namespace. 22 | 23 | **Deployment information (please complete the following information):** 24 | - DirectPV version: (This can be captured by `kubectl directpv --version`) 25 | - Kubernetes Version: 26 | - OS info: 27 | - Kernel version: 28 | 29 | **Additional context** 30 | Add any other context about the problem here. 31 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | branches: [master, v4.0] 6 | 7 | pull_request: 8 | branches: [master, v4.0] 9 | 10 | # This ensures that previous jobs for the PR are canceled when the PR is 11 | # updated. 12 | concurrency: 13 | group: ${{ github.workflow }}-${{ github.head_ref }} 14 | cancel-in-progress: true 15 | 16 | jobs: 17 | build: 18 | runs-on: ubuntu-latest 19 | steps: 20 | - uses: actions/checkout@v4 21 | - uses: actions/setup-go@v5 22 | with: 23 | go-version: 1.24.x 24 | check-latest: true 25 | - name: Set environment 26 | run: | 27 | echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV 28 | mkdir -p "$(go env GOPATH)/src/github.com/minio/" 29 | ln -s "$PWD" "$(go env GOPATH)/src/github.com/minio/directpv" 30 | - name: Build and test 31 | env: 32 | CGO_ENABLED: 0 33 | run: | 34 | ./build.sh 35 | go test -v ./... 36 | - uses: docker/setup-qemu-action@v3 37 | - name: Check Goreleaser 38 | uses: goreleaser/goreleaser-action@v6 39 | with: 40 | args: release --skip=publish,sign --clean --snapshot 41 | -------------------------------------------------------------------------------- /.github/workflows/linters.yml: -------------------------------------------------------------------------------- 1 | name: Linters 2 | 3 | on: 4 | push: 5 | branches: [ master, devel ] 6 | 7 | pull_request: 8 | branches: [ master, devel ] 9 | 10 | # This ensures that previous jobs for the PR are canceled when the PR is 11 | # updated. 12 | concurrency: 13 | group: ${{ github.workflow }}-${{ github.head_ref }} 14 | cancel-in-progress: true 15 | 16 | jobs: 17 | linters: 18 | runs-on: ubuntu-latest 19 | steps: 20 | - uses: actions/checkout@v4 21 | - uses: actions/setup-go@v5 22 | with: 23 | go-version: 1.24.x 24 | check-latest: true 25 | - uses: ludeeus/action-shellcheck@master 26 | - uses: golangci/golangci-lint-action@v7 27 | with: 28 | version: v2.0.2 29 | args: --config ./.golangci.yml --timeout=60m 30 | -------------------------------------------------------------------------------- /.github/workflows/vulncheck.yml: -------------------------------------------------------------------------------- 1 | name: VulnCheck 2 | 3 | on: 4 | push: 5 | branches: [ master, devel ] 6 | 7 | pull_request: 8 | branches: [ master, devel ] 9 | 10 | # This ensures that previous jobs for the PR are canceled when the PR is 11 | # updated. 12 | concurrency: 13 | group: ${{ github.workflow }}-${{ github.head_ref }} 14 | cancel-in-progress: true 15 | 16 | jobs: 17 | vulncheck: 18 | name: Analysis 19 | runs-on: ubuntu-latest 20 | steps: 21 | - name: Check out code 22 | uses: actions/checkout@v4 23 | - name: Set up Go 24 | uses: actions/setup-go@v5 25 | with: 26 | go-version: 1.24.x 27 | check-latest: true 28 | - name: Install govulncheck 29 | run: go install golang.org/x/vuln/cmd/govulncheck@latest 30 | shell: bash 31 | - name: Run govulncheck 32 | run: govulncheck ./... 33 | shell: bash 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | centos*.xml 3 | *.qcow2* 4 | directpv 5 | !directpv/ 6 | kubectl-directpv 7 | !kubectl-directpv/ 8 | vdb.xml 9 | drives.yaml 10 | dist/ 11 | kustomize 12 | operator-sdk 13 | kubectl-directpv_* 14 | -------------------------------------------------------------------------------- /.golangci.yml: -------------------------------------------------------------------------------- 1 | version: "2" 2 | run: 3 | go: "1.24" 4 | linters: 5 | default: none 6 | enable: 7 | - durationcheck 8 | - gocritic 9 | - gomodguard 10 | - govet 11 | - ineffassign 12 | - misspell 13 | - revive 14 | - staticcheck 15 | - unconvert 16 | - unused 17 | - usetesting 18 | settings: 19 | misspell: 20 | locale: US 21 | exclusions: 22 | generated: lax 23 | rules: 24 | - path: (.+)\.go$ 25 | text: should have a package comment 26 | - path: (.+)\.go$ 27 | text: exitAfterDefer 28 | - path: (.+)\.go$ 29 | text: redefines-builtin-id 30 | paths: 31 | - third_party$ 32 | - builtin$ 33 | - examples$ 34 | formatters: 35 | enable: 36 | - gofmt 37 | - gofumpt 38 | - goimports 39 | exclusions: 40 | generated: lax 41 | paths: 42 | - third_party$ 43 | - builtin$ 44 | - examples$ 45 | -------------------------------------------------------------------------------- /AlmaLinux.repo: -------------------------------------------------------------------------------- 1 | [base-8] 2 | name=AlmaLinux 8 - $basearch - Base 3 | baseurl=https://repo.almalinux.org/almalinux/8/BaseOS/$basearch/os/ 4 | gpgcheck=1 5 | enabled=1 6 | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux 7 | [appstream-8] 8 | name=AlmaLinux 8 - $basearch - AppStream 9 | baseurl=https://repo.almalinux.org/almalinux/8/AppStream/$basearch/os/ 10 | gpgcheck=1 11 | enabled=1 12 | gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux 13 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM registry.access.redhat.com/ubi8/ubi-minimal:8.10 2 | 3 | WORKDIR / 4 | 5 | COPY directpv /directpv 6 | COPY CREDITS /licenses/CREDITS 7 | COPY LICENSE /licenses/LICENSE 8 | 9 | RUN microdnf update --nodocs 10 | 11 | COPY AlmaLinux.repo /etc/yum.repos.d/AlmaLinux.repo 12 | 13 | RUN \ 14 | curl -L https://repo.almalinux.org/almalinux/8/BaseOS/x86_64/os/RPM-GPG-KEY-AlmaLinux -o /etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux && \ 15 | microdnf install xfsprogs --nodocs && \ 16 | microdnf clean all && \ 17 | rm -f /etc/yum.repos.d/AlmaLinux.repo 18 | 19 | ENTRYPOINT ["/directpv"] 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DirectPV 2 | 3 | [DirectPV](https://github.com/minio/directpv) is a [CSI](https://kubernetes.io/blog/2019/01/15/container-storage-interface-ga/) driver for [Direct Attached Storage](https://en.wikipedia.org/wiki/Direct-attached_storage). In a simpler sense, it is a distributed persistent volume manager, and not a storage system like SAN or NAS. It is useful to *discover, format, mount, schedule and monitor* drives across servers. 4 | 5 | Distributed data stores such as object storage, databases and message queues are designed for direct attached storage, and they handle high availability and data durability by themselves. Running them on traditional SAN or NAS based CSI drivers (Network PV) adds yet another layer of replication/erasure coding and extra network hops in the data path. This additional layer of disaggregation results in increased-complexity and poor performance. 6 | 7 | ![Architecture Diagram](https://github.com/minio/directpv/blob/master/docs/images/architecture.png?raw=true) 8 | 9 | ## Quickstart 10 | 11 | 1. Install DirectPV Krew plugin 12 | ```sh 13 | $ kubectl krew install directpv 14 | ``` 15 | 16 | 2. Install DirectPV in your kubernetes cluster 17 | ```sh 18 | $ kubectl directpv install 19 | ``` 20 | 21 | 3. Get information of the installation 22 | ```sh 23 | $ kubectl directpv info 24 | ``` 25 | 26 | 4. Add drives 27 | ```sh 28 | # Probe and save drive information to drives.yaml file. 29 | $ kubectl directpv discover 30 | 31 | # Initialize selected drives. 32 | $ kubectl directpv init drives.yaml 33 | ``` 34 | 35 | 5. Deploy a demo MinIO server 36 | ```sh 37 | $ curl -sfL https://github.com/minio/directpv/raw/master/functests/minio.yaml | kubectl apply -f - 38 | ``` 39 | 40 | ## Further information 41 | Refer [detailed documentation](./docs/README.md) 42 | 43 | ## Join Community 44 | DirectPV is a MinIO project. You can contact the authors over the [slack channel](https://slack.min.io/) 45 | 46 | ## Unsupported versions 47 | * Versions `v1.x`, `v2.x` and `v3.x` of DirectCSI/DirectPV are marked end-of-life and unsupported. 48 | * DirectPV version `v4.0.x` entered maintenance mode on Jan 01, 2025. 49 | 50 | ## License 51 | DirectPV is released under GNU AGPLv3 license. Refer the [LICENSE document](https://github.com/minio/directpv/blob/master/LICENSE) for a complete copy of the license. 52 | -------------------------------------------------------------------------------- /apparmor.profile: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | profile directpv flags=(attach_disconnected,mediate_deleted) { 4 | #include 5 | 6 | network, 7 | file, 8 | unix, 9 | 10 | # allow all mounts 11 | mount, 12 | 13 | # allow all umounts 14 | umount, 15 | 16 | deny /bin/** wl, 17 | deny /boot/** wl, 18 | deny /etc/** wl, 19 | deny /home/** wl, 20 | deny /lib/** wl, 21 | deny /lib64/** wl, 22 | deny /media/** wl, 23 | deny /mnt/** wl, 24 | deny /opt/** wl, 25 | deny /proc/** wl, 26 | deny /root/** wl, 27 | deny /sbin/** wl, 28 | deny /srv/** wl, 29 | deny /sys/** wl, 30 | deny /run/udev/data/** wl, 31 | # deny /usr/** wl, 32 | 33 | # allow directpv directory to be writeable 34 | /var/lib/directpv/** w, 35 | /var/lib/kubelet/** w, 36 | /csi/** w, 37 | /sys/fs/xfs/**/error/metadata/{EIO,ENOSPC}/retry_timeout_seconds rw, 38 | 39 | # only a limited set of binaries can be executed 40 | /usr/sbin/mkfs ix, 41 | /usr/sbin/mkfs.xfs ix, 42 | /directpv ix, 43 | 44 | deny /bin/sh mrwklx, 45 | deny /bin/bash mrwklx, 46 | deny /bin/dash mrwklx, 47 | deny /usr/bin/sh mrwklx, 48 | deny /usr/bin/bash mrwklx, 49 | deny /usr/bin/dash mrwklx, 50 | 51 | capability sys_admin, 52 | capability sys_chroot, 53 | capability sys_resource, 54 | capability net_bind_service, 55 | capability mknod, 56 | capability kill, 57 | capability ipc_owner, 58 | capability fsetid, 59 | capability fowner, 60 | capability dac_override, 61 | capability dac_read_search, 62 | capability chown, 63 | capability lease, 64 | capability setgid, 65 | capability setuid, 66 | capability setfcap, 67 | 68 | deny @{PROC}/* w, # deny write for all files directly in /proc (not in a subdir) 69 | deny @{PROC}/{[^1-9],[^1-9][^0-9],[^1-9s][^0-9y][^0-9s],[^1-9][^0-9][^0-9][^0-9]*}/** w, 70 | deny @{PROC}/sys/[^k]** w, # deny /proc/sys except /proc/sys/k* (effectively /proc/sys/kernel) 71 | deny @{PROC}/sys/kernel/{?,??,[^s][^h][^m]**} w, # deny everything except shm* in /proc/sys/kernel/ 72 | deny @{PROC}/sysrq-trigger rwklx, 73 | deny @{PROC}/mem rwklx, 74 | deny @{PROC}/kmem rwklx, 75 | deny @{PROC}/kcore rwklx, 76 | deny /sys/[^f]*/** wklx, 77 | deny /sys/f[^s]*/** wklx, 78 | deny /sys/fs/[^c]*/** wklx, 79 | deny /sys/fs/c[^g]*/** wklx, 80 | deny /sys/fs/cg[^r]*/** wklx, 81 | deny /sys/firmware/efi/efivars/** rwklx, 82 | deny /sys/kernel/security/** rwklx, 83 | } 84 | -------------------------------------------------------------------------------- /boilerplate.go.txt: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # This file is part of MinIO DirectPV 3 | # Copyright (c) 2021, 2022 MinIO, Inc. 4 | # 5 | # This program is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU Affero General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU Affero General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Affero General Public License 16 | # along with this program. If not, see . 17 | 18 | set -o errexit 19 | set -o nounset 20 | set -o pipefail 21 | 22 | cd "$(dirname "$0")" 23 | 24 | ./codegen.sh 25 | 26 | BUILD_VERSION=$(git describe --tags --always --dirty) 27 | 28 | export CGO_ENABLED=0 29 | 30 | go build -tags "osusergo netgo static_build" \ 31 | -ldflags="-X main.Version=${BUILD_VERSION} -extldflags=-static" \ 32 | github.com/minio/directpv/cmd/directpv 33 | 34 | go build -tags "osusergo netgo static_build" \ 35 | -ldflags="-X main.Version=${BUILD_VERSION} -extldflags=-static" \ 36 | github.com/minio/directpv/cmd/kubectl-directpv 37 | -------------------------------------------------------------------------------- /cmd/directpv/legacy-node-server.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package main 18 | 19 | import ( 20 | "context" 21 | 22 | "github.com/minio/directpv/pkg/consts" 23 | pkgidentity "github.com/minio/directpv/pkg/csi/identity" 24 | "github.com/minio/directpv/pkg/csi/node" 25 | legacyclient "github.com/minio/directpv/pkg/legacy/client" 26 | "github.com/spf13/cobra" 27 | "k8s.io/klog/v2" 28 | ) 29 | 30 | var legacyNodeServerCmd = &cobra.Command{ 31 | Use: consts.LegacyNodeServerName, 32 | Short: "Start legacy node server.", 33 | SilenceUsage: true, 34 | SilenceErrors: true, 35 | RunE: func(c *cobra.Command, _ []string) error { 36 | klog.InfoS("Starting DirectPV legacy node server", "version", Version) 37 | return startLegacyNodeServer(c.Context()) 38 | }, 39 | } 40 | 41 | func startLegacyNodeServer(ctx context.Context) error { 42 | var cancel context.CancelFunc 43 | ctx, cancel = context.WithCancel(ctx) 44 | defer cancel() 45 | 46 | idServer, err := pkgidentity.NewServer(legacyclient.Identity, Version, pkgidentity.GetDefaultPluginCapabilities()) 47 | if err != nil { 48 | return err 49 | } 50 | klog.V(3).Infof("Legacy identity server started") 51 | 52 | errCh := make(chan error) 53 | 54 | nodeServer := node.NewLegacyServer(nodeID, rack, zone, region) 55 | klog.V(3).Infof("Legacy node server started") 56 | 57 | go func() { 58 | if err := runServers(ctx, csiEndpoint, idServer, nil, nodeServer); err != nil { 59 | klog.ErrorS(err, "unable to start GRPC servers") 60 | errCh <- err 61 | } 62 | }() 63 | 64 | go func() { 65 | if err := serveReadinessEndpoint(ctx); err != nil { 66 | klog.ErrorS(err, "unable to start readiness endpoint") 67 | errCh <- err 68 | } 69 | }() 70 | 71 | return <-errCh 72 | } 73 | -------------------------------------------------------------------------------- /cmd/directpv/node-controller.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package main 18 | 19 | import ( 20 | "context" 21 | "errors" 22 | "os" 23 | 24 | "github.com/minio/directpv/pkg/consts" 25 | "github.com/minio/directpv/pkg/initrequest" 26 | "github.com/minio/directpv/pkg/node" 27 | "github.com/minio/directpv/pkg/sys" 28 | "github.com/spf13/cobra" 29 | "k8s.io/klog/v2" 30 | ) 31 | 32 | var nodeControllerCmd = &cobra.Command{ 33 | Use: consts.NodeControllerName, 34 | Short: "Start node controller.", 35 | SilenceUsage: true, 36 | SilenceErrors: true, 37 | RunE: func(c *cobra.Command, _ []string) error { 38 | klog.InfoS("Starting DirectPV node controller", "version", Version) 39 | if err := sys.Mkdir(consts.MountRootDir, 0o755); err != nil && !errors.Is(err, os.ErrExist) { 40 | return err 41 | } 42 | if err := node.Sync(c.Context(), nodeID); err != nil { 43 | return err 44 | } 45 | return startNodeController(c.Context()) 46 | }, 47 | } 48 | 49 | func startNodeController(ctx context.Context) error { 50 | var cancel context.CancelFunc 51 | ctx, cancel = context.WithCancel(ctx) 52 | defer cancel() 53 | 54 | errCh := make(chan error) 55 | 56 | go func() { 57 | node.StartController(ctx, nodeID) 58 | errCh <- errors.New("node controller stopped") 59 | }() 60 | 61 | go func() { 62 | initrequest.StartController( 63 | ctx, 64 | nodeID, 65 | identity, 66 | rack, 67 | zone, 68 | region, 69 | ) 70 | errCh <- errors.New("initrequest controller stopped") 71 | }() 72 | 73 | return <-errCh 74 | } 75 | -------------------------------------------------------------------------------- /cmd/directpv/ready.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package main 18 | 19 | import ( 20 | "context" 21 | "fmt" 22 | "net" 23 | "net/http" 24 | 25 | "github.com/minio/directpv/pkg/consts" 26 | "k8s.io/klog/v2" 27 | ) 28 | 29 | func serveReadinessEndpoint(ctx context.Context) error { 30 | server := &http.Server{} 31 | mux := http.NewServeMux() 32 | mux.HandleFunc(consts.ReadinessPath, readinessHandler) 33 | server.Handler = mux 34 | 35 | config := net.ListenConfig{} 36 | listener, err := config.Listen(ctx, "tcp", fmt.Sprintf(":%v", readinessPort)) 37 | if err != nil { 38 | return err 39 | } 40 | 41 | for { 42 | klog.V(3).Infof("Serving readiness endpoint at :%v", readinessPort) 43 | if err = server.Serve(listener); err != nil { 44 | klog.ErrorS(err, "unable to serve readiness endpoint") 45 | return err 46 | } 47 | } 48 | } 49 | 50 | // readinessHandler - Checks if the process is up. Always returns success. 51 | func readinessHandler(w http.ResponseWriter, r *http.Request) { 52 | klog.V(5).Infof("Received readiness request %v", r) 53 | if r.Method != http.MethodGet { 54 | w.WriteHeader(http.StatusMethodNotAllowed) 55 | } else { 56 | w.WriteHeader(http.StatusOK) 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /cmd/kubectl-directpv/migrate.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package main 18 | 19 | import ( 20 | "context" 21 | "os" 22 | "strings" 23 | "time" 24 | 25 | "github.com/minio/directpv/pkg/admin" 26 | "github.com/minio/directpv/pkg/consts" 27 | "github.com/spf13/cobra" 28 | ) 29 | 30 | var retainFlag bool 31 | 32 | var migrateCmd = &cobra.Command{ 33 | Use: "migrate", 34 | Short: "Migrate drives and volumes from legacy DirectCSI", 35 | Example: strings.ReplaceAll( 36 | `1. Migrate drives and volumes from legacy DirectCSI 37 | $ kubectl {PLUGIN_NAME} migrate`, 38 | `{PLUGIN_NAME}`, 39 | consts.AppName, 40 | ), 41 | Run: func(c *cobra.Command, _ []string) { 42 | migrateMain(c.Context()) 43 | }, 44 | } 45 | 46 | func init() { 47 | setFlagOpts(migrateCmd) 48 | 49 | addDryRunFlag(migrateCmd, "Run in dry run mode") 50 | migrateCmd.PersistentFlags().BoolVar(&retainFlag, "retain", retainFlag, "retain legacy CRD after migration") 51 | } 52 | 53 | func migrateMain(ctx context.Context) { 54 | suffix := time.Now().Format(time.RFC3339) 55 | if err := adminClient.Migrate(ctx, admin.MigrateArgs{ 56 | Quiet: quietFlag, 57 | Retain: retainFlag, 58 | DrivesBackupFile: "directcsidrives-" + suffix + ".yaml", 59 | VolumesBackupFile: "directcsivolumes-" + suffix + ".yaml", 60 | }); err != nil { 61 | eprintf(true, "migration failed; %v", err) 62 | os.Exit(1) 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /cmd/kubectl-directpv/resume.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2022, 2023 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package main 18 | 19 | import ( 20 | "github.com/spf13/cobra" 21 | ) 22 | 23 | var resumeCmd = &cobra.Command{ 24 | Use: "resume", 25 | Short: "Resume suspended drives and volumes", 26 | PersistentPreRunE: func(cmd *cobra.Command, args []string) error { 27 | if parent := cmd.Parent(); parent != nil { 28 | parent.PersistentPreRunE(parent, args) 29 | } 30 | return nil 31 | }, 32 | } 33 | 34 | func init() { 35 | setFlagOpts(resumeCmd) 36 | 37 | addDryRunFlag(resumeCmd, "Run in dry run mode") 38 | 39 | resumeCmd.AddCommand(resumeDrivesCmd) 40 | resumeCmd.AddCommand(resumeVolumesCmd) 41 | } 42 | -------------------------------------------------------------------------------- /cmd/kubectl-directpv/suspend.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2022, 2023 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package main 18 | 19 | import ( 20 | "github.com/spf13/cobra" 21 | ) 22 | 23 | var suspendCmd = &cobra.Command{ 24 | Use: "suspend", 25 | Short: "Suspend drives and volumes", 26 | PersistentPreRunE: func(cmd *cobra.Command, args []string) error { 27 | if parent := cmd.Parent(); parent != nil { 28 | parent.PersistentPreRunE(parent, args) 29 | } 30 | return nil 31 | }, 32 | } 33 | 34 | func init() { 35 | setFlagOpts(suspendCmd) 36 | 37 | addDryRunFlag(suspendCmd, "Run in dry run mode") 38 | 39 | suspendCmd.AddCommand(suspendDrivesCmd) 40 | suspendCmd.AddCommand(suspendVolumesCmd) 41 | } 42 | -------------------------------------------------------------------------------- /cmd/kubectl-directpv/uninstall.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package main 18 | 19 | import ( 20 | "context" 21 | "fmt" 22 | "os" 23 | 24 | "github.com/minio/directpv/pkg/admin" 25 | "github.com/minio/directpv/pkg/consts" 26 | "github.com/spf13/cobra" 27 | ) 28 | 29 | var uninstallCmd = &cobra.Command{ 30 | Use: "uninstall", 31 | Short: "Uninstall " + consts.AppPrettyName + " in Kubernetes", 32 | SilenceUsage: true, 33 | SilenceErrors: true, 34 | Run: func(c *cobra.Command, _ []string) { 35 | uninstallMain(c.Context()) 36 | }, 37 | } 38 | 39 | func init() { 40 | setFlagOpts(uninstallCmd) 41 | 42 | addDangerousFlag(uninstallCmd, "If present, uninstall forcefully which may cause data loss") 43 | uninstallCmd.PersistentFlags().MarkHidden("dangerous") 44 | } 45 | 46 | func uninstallMain(ctx context.Context) { 47 | err := adminClient.Uninstall( 48 | ctx, 49 | admin.UninstallArgs{ 50 | Quiet: quietFlag, 51 | Dangerous: dangerousFlag, 52 | }, 53 | ) 54 | if err != nil { 55 | eprintf(true, "%v\n", err) 56 | os.Exit(1) 57 | } 58 | if !quietFlag { 59 | fmt.Println(consts.AppPrettyName + " uninstalled successfully") 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /codecov.yaml: -------------------------------------------------------------------------------- 1 | coverage: 2 | status: 3 | project: 4 | default: 5 | informational: true 6 | patch: 7 | default: 8 | informational: true 9 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # DirectPV 2 | DirectPV is a CSI driver to provision local volumes to Pods using [Direct Attached Storage](https://en.wikipedia.org/wiki/Direct-attached_storage). It comes with two components. 3 | 1. `DirectPV plugin` - To be installed on local machine, to manage DirectPV CSI driver. 4 | 2. `DirectPV CSI driver` - To be installed on kubernetes cluster, to provision local volumes. 5 | 6 | ## For new users 7 | Refer below documentation 8 | * [Installation guide](./installation.md) 9 | * [Drive management guide](./drive-management.md) 10 | * [Volume provisioning guide](./volume-provisioning.md) 11 | * [Volume management guide](./volume-management.md) 12 | * [Command reference guide](./command-reference.md) 13 | * [Monitoring guide](./monitoring.md) 14 | 15 | ## For existing users 16 | Refer below documentation 17 | * [Upgrade guide](./upgrade.md) 18 | * [Node management guide](./node-management.md) 19 | 20 | ## Further references 21 | * [Volume scheduling guide](./volume-scheduling.md) 22 | * [Issue reporting](./issue-reporting.md) 23 | * [DirectPV CSI driver specification](./specification.md) 24 | * [Troubleshooting guide](./faq.md) 25 | -------------------------------------------------------------------------------- /docs/developer.md: -------------------------------------------------------------------------------- 1 | # Development and Testing 2 | We welcome any contribution to DirectPV. All your pull requests are welcomed. 3 | 4 | ## Building DirectPV from source 5 | 1. Get source code from [DirectPV Github repository](https://github.com/minio/directpv) 6 | 2. Run `./build.sh`. You will get `directpv` CSI driver binary and `kubectl-directpv` plugin binary. 7 | 8 | ## Building DirectPV container image 9 | 1. Run `podman build -t quay.io/minio/directpv:$(./kubectl-directpv --version | awk '{ print $NF }') .` 10 | 11 | ## Pushing container image to kubernetes nodes 12 | 1. Run `podman save --output directpv.tar quay.io/minio/directpv:$(./kubectl-directpv --version | awk '{ print $NF }')` to get image tarball. 13 | 2. Copy `directpv.tar` to all your kubernetes nodes. 14 | 3. Import `directpv.tar` by running `/usr/local/bin/ctr images import --digests --base-name quay.io/minio/directpv directpv.tar` on each node. This step works for `K3S` cluster. 15 | 16 | ## Installing DirectPV build 17 | 1. Run `./kubectl-directpv install` 18 | -------------------------------------------------------------------------------- /docs/images/architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minio/directpv/1fb86efd610ab2f8b56ae7f29787bdc2e5776619/docs/images/architecture.png -------------------------------------------------------------------------------- /docs/images/directpv_architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minio/directpv/1fb86efd610ab2f8b56ae7f29787bdc2e5776619/docs/images/directpv_architecture.png -------------------------------------------------------------------------------- /docs/node-management.md: -------------------------------------------------------------------------------- 1 | # Node management 2 | 3 | ## Prerequisites 4 | * Working DirectPV plugin. To install the plugin, refer to the [plugin installation guide](./installation.md#directpv-plugin-installation). 5 | * Working DirectPV CSI driver in Kubernetes. To install the driver, refer to the [driver installation guide](./installation.md#directpv-csi-driver-installation). 6 | 7 | ## Add node 8 | After Adding a node into DirectPV DaemonSet, run DirectPV plugin `discover` command. Below is an example: 9 | ```sh 10 | $ kubectl directpv discover 11 | ``` 12 | 13 | ## List node 14 | Run DirectPV plugin `info` command to get list of nodes. Below is an example: 15 | ```sh 16 | $ kubectl directpv info 17 | ┌──────────┬──────────┬───────────┬─────────┬────────┐ 18 | │ NODE │ CAPACITY │ ALLOCATED │ VOLUMES │ DRIVES │ 19 | ├──────────┼──────────┼───────────┼─────────┼────────┤ 20 | │ • master │ 512 MiB │ 32 MiB │ 2 │ 1 │ 21 | │ • node1 │ 512 MiB │ 32 MiB │ 2 │ 1 │ 22 | └──────────┴──────────┴───────────┴─────────┴────────┘ 23 | 24 | 64 MiB/1.0 GiB used, 4 volumes, 2 drives 25 | 26 | ``` 27 | 28 | Refer to the [info command](./command-reference.md#info-command) for more information. 29 | 30 | ## Delete node 31 | ***CAUTION: THIS IS DANGEROUS OPERATION WHICH LEADS TO DATA LOSS*** 32 | 33 | Before removing a node make sure no volumes or drives on the node are in use, then remove the node from DirectPV DaemonSet and run [remove-node.sh](./tools/remove-node.sh) script. 34 | -------------------------------------------------------------------------------- /docs/openshift.md: -------------------------------------------------------------------------------- 1 | # DirectPV on Red Hat OpenShift 2 | DirectPV runs under project `directpv` in Red Hat OpenShift. Project `directpv` is automatically created after successful DirectPV installation. 3 | 4 | ## Settings required 5 | * Add privileges to `directpv` namespace and DirectPV service account by adding `system:serviceaccount:directpv:directpv-min-io` to `users` section of YAML generated by command `$ oc edit scc privileged` 6 | 7 | ## Limitations 8 | * DirectPV does not support volume snapshot feature as per CSI specification. DirectPV is specifically meant for use cases like MinIO where the data availability and resiliency is taken care by the application itself. Additionally, with the AWS S3 versioning APIs and internal healing, snapshots is not a requirement. 9 | * DirectPV does not support `ReadWriteMany` volume access mode. The workloads using DirectPV run local to the node and are provisioned from local storage drives in the node. This allows the workloads to directly access data without any additional network hops, unlike remote volumes, network PVs, etc. The additional network hops may lead to poor performance and increases the complexity. With `ReadWriteOnce` access mode, DirectPV provides high performance storage for Pods. 10 | 11 | ## SELinux in OpenShift 12 | 13 | In a SELinux enabled system, pod may fail to start due to `relabel failed` error on suspended volume. As the suspended volumes are read-only, Kublet tries to do SELinux relabeling by `lsetxattr` system call to write extended attributes. This issue is fixable by adding `spec.securityContext.seLinuxOptions.type: spc_t` at pod level or container level along with appropriate Security Context Constraints (SCCs) in place. A complete detail is available at https://access.redhat.com/solutions/7025337. The following example shows how to set `spc_t` SELinux settings at pod level: 14 | 15 | ```yaml 16 | apiVersion: v1 17 | kind: Pod 18 | metadata: 19 | name: sleep-pod 20 | spec: 21 | securityContext: 22 | seLinuxOptions: 23 | type: "spc_t" # Setting to fix the issue 24 | volumes: 25 | - name: sleep-volume 26 | persistentVolumeClaim: 27 | claimName: sleep-pvc 28 | containers: 29 | - name: sleep-container 30 | image: example.org/test/sleep:v0.0.1 31 | volumeMounts: 32 | - mountPath: "/mnt" 33 | name: sleep-volume 34 | ``` 35 | -------------------------------------------------------------------------------- /docs/tools/remove-directcsi.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # This file is part of MinIO DirectPV 4 | # Copyright (c) 2023 MinIO, Inc. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Affero General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Affero General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Affero General Public License 17 | # along with this program. If not, see . 18 | 19 | # 20 | # This script removes direct-csi drives and volumes after taking backup YAMLs 21 | # to directcsidrives.yaml and directcsivolumes.yaml 22 | # 23 | 24 | set -e -C -o pipefail 25 | 26 | function init() { 27 | if [[ $# -ne 0 ]]; then 28 | echo "usage: remove-directcsi.sh" 29 | echo 30 | echo "This script removes direct-csi drives and volumes after taking backup YAMLs" 31 | echo "to directcsidrives.yaml and directcsivolumes.yaml" 32 | exit 255 33 | fi 34 | 35 | if ! which kubectl >/dev/null 2>&1; then 36 | echo "kubectl not found; please install" 37 | exit 255 38 | fi 39 | } 40 | 41 | # usage: unset_object_finalizers 42 | function unset_object_finalizers() { 43 | kubectl get "${1}" -o custom-columns=NAME:.metadata.name --no-headers | while read -r resource_name; do 44 | kubectl patch "${1}" "${resource_name}" -p '{"metadata":{"finalizers":null}}' --type=merge 45 | done 46 | } 47 | 48 | function main() { 49 | kubectl get directcsivolumes -o yaml > directcsivolumes.yaml 50 | kubectl get directcsidrives -o yaml > directcsidrives.yaml 51 | 52 | # unset the finalizers 53 | unset_object_finalizers "directcsidrives" 54 | unset_object_finalizers "directcsivolumes" 55 | 56 | # delete the resources 57 | kubectl delete directcsivolumes --all 58 | kubectl delete directcsidrives --all 59 | } 60 | 61 | init "$@" 62 | main "$@" 63 | -------------------------------------------------------------------------------- /docs/tools/remove-node.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # This file is part of MinIO DirectPV 4 | # Copyright (c) 2023 MinIO, Inc. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Affero General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Affero General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Affero General Public License 17 | # along with this program. If not, see . 18 | 19 | set -e -C -o pipefail 20 | 21 | declare NODE 22 | 23 | function delete_resource() { 24 | resource="$1" 25 | selector="directpv.min.io/node=${NODE}" 26 | 27 | # unset the finalizers 28 | kubectl get "${resource}" --selector="${selector}" -o custom-columns=NAME:.metadata.name --no-headers | while read -r name; do 29 | kubectl patch "${resource}" "${name}" -p '{"metadata":{"finalizers":null}}' --type=merge 30 | done 31 | 32 | # delete the objects 33 | kubectl delete "${resource}" --selector="${selector}" --ignore-not-found=true 34 | } 35 | 36 | function init() { 37 | if [[ $# -ne 1 ]]; then 38 | cat < 40 | 41 | This script forcefully removes all the DirectPV resources from the node. 42 | CAUTION: Remove operation is irreversible and may incur data loss if not used cautiously. 43 | EOF 44 | exit 255 45 | fi 46 | 47 | if ! which kubectl >/dev/null 2>&1; then 48 | echo "kubectl not found; please install" 49 | exit 255 50 | fi 51 | 52 | NODE="$1" 53 | 54 | if kubectl get --ignore-not-found=true csinode "${NODE}" -o go-template='{{range .spec.drivers}}{{if eq .name "directpv-min-io"}}{{.name}}{{break}}{{end}}{{end}}' | grep -q .; then 55 | echo "node ${NODE} is still in use; remove node ${NODE} from DirectPV DaemonSet and try again" 56 | exit 255 57 | fi 58 | } 59 | 60 | function main() { 61 | delete_resource directpvvolumes 62 | delete_resource directpvdrives 63 | delete_resource directpvinitrequests 64 | kubectl delete directpvnode "${NODE}" --ignore-not-found=true 65 | } 66 | 67 | init "$@" 68 | main "$@" 69 | -------------------------------------------------------------------------------- /docs/upgrade.md: -------------------------------------------------------------------------------- 1 | # Upgrade DirectPV installation 2 | 3 | ## Upgrade DirectPV CSI driver 4 | 5 | ### Upgrade DirectPV CSI driver v4.x.x 6 | 7 | #### Offline upgrade 8 | Follow the below steps for an offline upgrade 9 | 1. Uninstall DirectPV CSI driver. 10 | ```sh 11 | $ kubectl directpv uninstall 12 | ``` 13 | 2. Upgrade DirectPV plugin by [this documentation](#upgrade-directpv-plugin). 14 | 3. Install the latest DirectPV CSI driver by [this documentation](./installation.md#directpv-csi-driver-installation). 15 | 16 | #### In-place upgrade 17 | Follow the below steps for an in-place upgrade 18 | 1. Upgrade DirectPV plugin by [this documentation](#upgrade-directpv-plugin). 19 | 2. Run install script with appropriate node-selector, tolerations, and `KUBELET_DIR_PATH` environment variable. Below is an example: 20 | ```sh 21 | $ curl -sfL https://github.com/minio/directpv/raw/master/docs/tools/install.sh | sh -s - apply 22 | ``` 23 | 24 | ### Upgrade legacy DirectCSI CSI driver 25 | Follow the below steps to upgrade to the latest DirectPV CSI driver from a legacy DirectCSI installation. 26 | 1. Uninstall DirectCSI driver if you run v3.1.0 or newer version. For other versions, skip this step. 27 | ```sh 28 | $ kubectl directcsi uninstall 29 | ``` 30 | 2. Install the latest DirectPV plugin by [this documentation](./installation.md#directpv-plugin-installation) or upgrade existing DirectPV plugin by [this documentation](#upgrade-directpv-plugin). 31 | 3. Install the latest DirectPV CSI driver by [this documentation](./installation.md#directpv-csi-driver-installation). 32 | 4. Uninstall DirectCSI driver if you run older than v3.1.0 version. For other versions, skip this step. 33 | ```sh 34 | $ kubectl directcsi uninstall 35 | ``` 36 | 37 | ## Upgrade DirectPV plugin 38 | 39 | ### Upgrade using `Krew` 40 | To upgrade the plugin, run below command 41 | ```sh 42 | $ kubectl krew upgrade directpv 43 | ``` 44 | 45 | ### Upgrade of release binary 46 | Refer to the [binary installation documentation](./installation.md#installation-of-release-binary). 47 | -------------------------------------------------------------------------------- /functests/Dockerfile.sleep: -------------------------------------------------------------------------------- 1 | FROM alpine:latest 2 | RUN echo 'while true; do echo I am in a sleep loop; sleep 3; done' > sleep.sh 3 | ENTRYPOINT sh sleep.sh 4 | -------------------------------------------------------------------------------- /functests/execute.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # This file is part of MinIO DirectPV 4 | # Copyright (c) 2021, 2022 MinIO, Inc. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Affero General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Affero General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Affero General Public License 17 | # along with this program. If not, see . 18 | 19 | function execute() { 20 | # Open /var/tmp/check.sh.xtrace for fd 3 21 | exec 3>/var/tmp/check.sh.xtrace 22 | 23 | # Set PS4 to [filename:lineno]: for tracing 24 | # Save all traces to fd 3 25 | # Run passed command with enabled errexit/xtrace 26 | PS4='+ [${BASH_SOURCE}:${FUNCNAME[0]:+${FUNCNAME[0]}():}${LINENO}]: ' BASH_XTRACEFD=3 bash -ex "$@" 27 | exit_status=$? 28 | 29 | # Close fd 3 30 | exec 3>&- 31 | 32 | if [ "$exit_status" -ne 0 ]; then 33 | echo 34 | echo "xtrace:" 35 | tail /var/tmp/check.sh.xtrace | tac 36 | fi 37 | 38 | return "$exit_status" 39 | } 40 | 41 | execute "$@" 42 | -------------------------------------------------------------------------------- /functests/minio.yaml: -------------------------------------------------------------------------------- 1 | kind: Service 2 | apiVersion: v1 3 | metadata: 4 | name: minio 5 | labels: 6 | app: minio 7 | spec: 8 | selector: 9 | app: minio 10 | ports: 11 | - name: minio 12 | port: 9000 13 | --- 14 | apiVersion: apps/v1 15 | kind: StatefulSet 16 | metadata: 17 | name: minio 18 | labels: 19 | app: minio 20 | spec: 21 | serviceName: "minio" 22 | replicas: 4 23 | selector: 24 | matchLabels: 25 | app: minio 26 | template: 27 | metadata: 28 | labels: 29 | app: minio 30 | directpv.min.io/organization: minio 31 | directpv.min.io/app: minio-example 32 | directpv.min.io/tenant: tenant-1 33 | spec: 34 | containers: 35 | - name: minio 36 | image: minio/minio 37 | env: 38 | - name: MINIO_ACCESS_KEY 39 | value: minio 40 | - name: MINIO_SECRET_KEY 41 | value: minio123 42 | volumeMounts: 43 | - name: minio-data-1 44 | mountPath: /data1 45 | - name: minio-data-2 46 | mountPath: /data2 47 | - name: minio-data-3 48 | mountPath: /data3 49 | - name: minio-data-4 50 | mountPath: /data4 51 | args: 52 | - "server" 53 | - "http://minio-{0...3}.minio.default.svc.cluster.local:9000/data{1...4}" 54 | volumeClaimTemplates: # This is the specification in which you reference the StorageClass 55 | - metadata: 56 | name: minio-data-1 57 | spec: 58 | accessModes: [ "ReadWriteOnce" ] 59 | resources: 60 | requests: 61 | storage: 16Mi 62 | storageClassName: directpv-min-io # This field references the existing StorageClass 63 | - metadata: 64 | name: minio-data-2 65 | spec: 66 | accessModes: [ "ReadWriteOnce" ] 67 | resources: 68 | requests: 69 | storage: 16Mi 70 | storageClassName: directpv-min-io # This field references the existing StorageClass 71 | - metadata: 72 | name: minio-data-3 73 | spec: 74 | accessModes: [ "ReadWriteOnce" ] 75 | resources: 76 | requests: 77 | storage: 16Mi 78 | storageClassName: directpv-min-io # This field references the existing StorageClass 79 | - metadata: 80 | name: minio-data-4 81 | spec: 82 | accessModes: [ "ReadWriteOnce" ] 83 | resources: 84 | requests: 85 | storage: 16Mi 86 | storageClassName: directpv-min-io # This field references the existing StorageClass 87 | -------------------------------------------------------------------------------- /functests/run-migration-tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # This file is part of MinIO DirectPV 4 | # Copyright (c) 2022 MinIO, Inc. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Affero General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Affero General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Affero General Public License 17 | # along with this program. If not, see . 18 | 19 | ME=$(basename "$0"); export ME 20 | 21 | if [ "$#" -ne 1 ]; then 22 | echo "usage: $ME " 23 | exit 255 24 | fi 25 | 26 | cd "$(dirname "$0")" || exit 255 27 | DIRECTPV_DIR="$(cd .. && echo "$PWD")" 28 | export DIRECTPV_DIR 29 | 30 | ./execute.sh migration-tests.sh "$1" 31 | -------------------------------------------------------------------------------- /functests/run-tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # This file is part of MinIO DirectPV 4 | # Copyright (c) 2021, 2022 MinIO, Inc. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Affero General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Affero General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Affero General Public License 17 | # along with this program. If not, see . 18 | 19 | ME=$(basename "$0"); export ME 20 | cd "$(dirname "$0")" || exit 255 21 | DIRECTPV_DIR="$(cd .. && echo "$PWD")" 22 | export DIRECTPV_DIR 23 | 24 | ./execute.sh tests.sh 25 | -------------------------------------------------------------------------------- /functests/sleep.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: PersistentVolumeClaim 3 | metadata: 4 | name: sleep-pvc 5 | spec: 6 | volumeMode: Filesystem 7 | storageClassName: directpv-min-io 8 | accessModes: 9 | - ReadWriteOnce 10 | resources: 11 | requests: 12 | storage: 8Mi 13 | --- 14 | apiVersion: v1 15 | kind: Pod 16 | metadata: 17 | name: sleep-pod 18 | spec: 19 | volumes: 20 | - name: sleep-volume 21 | persistentVolumeClaim: 22 | claimName: sleep-pvc 23 | containers: 24 | - name: sleep-container 25 | image: example.org/test/sleep:v0.0.1 26 | volumeMounts: 27 | - mountPath: "/mnt" 28 | name: sleep-volume 29 | --- 30 | -------------------------------------------------------------------------------- /functests/tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # This file is part of MinIO DirectPV 4 | # Copyright (c) 2021, 2022 MinIO, Inc. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU Affero General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU Affero General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Affero General Public License 17 | # along with this program. If not, see . 18 | 19 | set -ex 20 | 21 | # shellcheck source=/dev/null 22 | source "common.sh" 23 | 24 | function run_tests() { 25 | setup_lvm 26 | setup_luks 27 | pod_count=$(( 3 + ACTIVE_NODES )) 28 | if [ "${KUSTOMIZE}" == "true" ]; then 29 | install_directpv_kustomize "${DIRECTPV_DIR}/kubectl-directpv" "${pod_count}" 30 | else 31 | install_directpv "${DIRECTPV_DIR}/kubectl-directpv" "${pod_count}" 32 | fi 33 | add_drives "${DIRECTPV_DIR}/kubectl-directpv" 34 | deploy_minio minio.yaml 35 | test_force_delete 36 | test_drive_suspension "${DIRECTPV_DIR}/kubectl-directpv" 37 | test_volume_suspension "${DIRECTPV_DIR}/kubectl-directpv" 38 | uninstall_minio "${DIRECTPV_DIR}/kubectl-directpv" minio.yaml 39 | test_volume_expansion "${DIRECTPV_DIR}/kubectl-directpv" sleep.yaml 40 | remove_drives "${DIRECTPV_DIR}/kubectl-directpv" 41 | if [ "${KUSTOMIZE}" == "true" ]; then 42 | uninstall_directpv_kustomize "${pod_count}" 43 | else 44 | uninstall_directpv "${DIRECTPV_DIR}/kubectl-directpv" "${pod_count}" 45 | fi 46 | unmount_directpv 47 | remove_luks 48 | remove_lvm 49 | } 50 | 51 | run_tests 52 | -------------------------------------------------------------------------------- /package.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ## Goreleaser helper script. 4 | 5 | if [ "$#" -ne 1 ]; then 6 | echo "usage: package.sh " 7 | exit 255 8 | fi 9 | 10 | dir="$(dirname "$1")" 11 | binary=$(basename "${dir}") 12 | cp -f LICENSE CREDITS README.md "${dir}" 13 | rm -f "${binary}.zip" 14 | zip -r -j "${binary}.zip" "${dir}" 15 | -------------------------------------------------------------------------------- /pkg/admin/client.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2024 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package admin 18 | 19 | import ( 20 | "github.com/minio/directpv/pkg/client" 21 | "k8s.io/client-go/rest" 22 | ) 23 | 24 | // Client represents the admin clientset 25 | type Client struct { 26 | *client.Client 27 | } 28 | 29 | // NewClient returns a new admin client 30 | func NewClient(c *rest.Config) (*Client, error) { 31 | directpvClientSet, err := client.NewClient(c) 32 | if err != nil { 33 | return nil, err 34 | } 35 | return &Client{ 36 | Client: directpvClientSet, 37 | }, nil 38 | } 39 | -------------------------------------------------------------------------------- /pkg/admin/init_config_v1.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2024 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package admin 18 | 19 | import directpvtypes "github.com/minio/directpv/pkg/apis/directpv.min.io/types" 20 | 21 | // InitConfigV1 defines the config to initialize the devices 22 | type InitConfigV1 struct { 23 | Version string `yaml:"version" json:"version"` 24 | Nodes []NodeInfoV1 `yaml:"nodes,omitempty" json:"nodes,omitempty"` 25 | } 26 | 27 | // NodeInfoV1 holds the node information 28 | type NodeInfoV1 struct { 29 | Name directpvtypes.NodeID `yaml:"name" json:"name"` 30 | Drives []DriveInfoV1 `yaml:"drives,omitempty" json:"drives,omitempty"` 31 | } 32 | 33 | // DriveInfoV1 represents the drives that are to be initialized 34 | type DriveInfoV1 struct { 35 | ID string `yaml:"id" json:"id"` 36 | Name string `yaml:"name" json:"name"` 37 | Size uint64 `yaml:"size" json:"size"` 38 | Make string `yaml:"make" json:"make"` 39 | FS string `yaml:"fs,omitempty" json:"fs,omitempty"` 40 | Select string `yaml:"select,omitempty" json:"select,omitempty"` 41 | } 42 | -------------------------------------------------------------------------------- /pkg/admin/installer/consts.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package installer 18 | 19 | import "github.com/minio/directpv/pkg/consts" 20 | 21 | const ( 22 | // UnixCSIEndpoint is csi drive control socket. 23 | UnixCSIEndpoint = "unix:///csi/csi.sock" 24 | 25 | namespace = consts.AppName 26 | healthZContainerPortName = "healthz" 27 | healthZContainerPort = 9898 28 | csiDirVolumeName = "socket-dir" 29 | csiDirVolumePath = "/csi" 30 | selectorKey = "selector." + consts.GroupName 31 | kubeNodeNameEnvVarName = "KUBE_NODE_NAME" 32 | csiEndpointEnvVarName = "CSI_ENDPOINT" 33 | pluginName = "kubectl-" + consts.AppName 34 | selectorValueEnabled = "enabled" 35 | serviceSelector = "selector." + consts.GroupName + ".service" 36 | healthZContainerPortPath = "/healthz" 37 | logLevel = 3 38 | createdByLabel = "created-by" 39 | localhost = "localhost" 40 | ) 41 | -------------------------------------------------------------------------------- /pkg/admin/logger.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2024 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package admin 18 | 19 | // LogType represents the type of the log 20 | type LogType int 21 | 22 | const ( 23 | // UnknownLogType denotes the dummy LogType 24 | UnknownLogType LogType = iota 25 | // ErrorLogType denotes the error LogType 26 | ErrorLogType 27 | // InfoLogType denotes the non-error info LogType 28 | InfoLogType 29 | ) 30 | 31 | // LogMessage represents the log message 32 | type LogMessage struct { 33 | Type LogType 34 | Err error 35 | Code string 36 | Message string 37 | Values map[string]any 38 | FormattedMessage string 39 | } 40 | 41 | // LogFunc represents the logger 42 | type LogFunc func(LogMessage) 43 | 44 | func nullLogger(_ LogMessage) {} 45 | -------------------------------------------------------------------------------- /pkg/admin/uninstall.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2023 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package admin 18 | 19 | import ( 20 | "context" 21 | 22 | "github.com/minio/directpv/pkg/admin/installer" 23 | legacyclient "github.com/minio/directpv/pkg/legacy/client" 24 | ) 25 | 26 | // UninstallArgs represents the args to uninstall 27 | type UninstallArgs struct { 28 | Quiet bool 29 | Dangerous bool 30 | } 31 | 32 | // Uninstall uninstalls directpv 33 | func (client Client) Uninstall(ctx context.Context, args UninstallArgs) error { 34 | legacyClient, err := legacyclient.NewClient(client.K8s()) 35 | if err != nil { 36 | return err 37 | } 38 | return installer.Uninstall(ctx, args.Quiet, args.Dangerous, installer.GetDefaultTasks(client.Client, legacyClient)) 39 | } 40 | -------------------------------------------------------------------------------- /pkg/apis/directpv.min.io/v1beta1/doc.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // +k8s:deepcopy-gen=package,register 18 | // +k8s:openapi-gen=true 19 | // +groupName=directpv.min.io 20 | 21 | package v1beta1 22 | -------------------------------------------------------------------------------- /pkg/client/clients.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package client 18 | 19 | import ( 20 | "github.com/minio/directpv/pkg/types" 21 | "k8s.io/client-go/rest" 22 | ) 23 | 24 | var ( 25 | initialized int32 26 | client *Client 27 | ) 28 | 29 | // GetClient returns the client 30 | func GetClient() *Client { 31 | return client 32 | } 33 | 34 | // RESTClient gets latest versioned REST client. 35 | func RESTClient() rest.Interface { 36 | return client.REST() 37 | } 38 | 39 | // DriveClient gets latest versioned drive interface. 40 | func DriveClient() types.LatestDriveInterface { 41 | return client.Drive() 42 | } 43 | 44 | // VolumeClient gets latest versioned volume interface. 45 | func VolumeClient() types.LatestVolumeInterface { 46 | return client.Volume() 47 | } 48 | 49 | // NodeClient gets latest versioned node interface. 50 | func NodeClient() types.LatestNodeInterface { 51 | return client.Node() 52 | } 53 | 54 | // InitRequestClient gets latest versioned init request interface. 55 | func InitRequestClient() types.LatestInitRequestInterface { 56 | return client.InitRequest() 57 | } 58 | 59 | // NewDriveLister returns the new drive lister 60 | func NewDriveLister() *DriveLister { 61 | return client.NewDriveLister() 62 | } 63 | 64 | // NewVolumeLister returns the new volume lister 65 | func NewVolumeLister() *VolumeLister { 66 | return client.NewVolumeLister() 67 | } 68 | 69 | // NewNodeLister returns the new node lister 70 | func NewNodeLister() *NodeLister { 71 | return client.NewNodeLister() 72 | } 73 | 74 | // NewInitRequestLister returns the new initrequest lister 75 | func NewInitRequestLister() *InitRequestLister { 76 | return client.NewInitRequestLister() 77 | } 78 | -------------------------------------------------------------------------------- /pkg/client/discovery.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2024 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package client 18 | 19 | import ( 20 | "context" 21 | "fmt" 22 | 23 | directpvtypes "github.com/minio/directpv/pkg/apis/directpv.min.io/types" 24 | "github.com/minio/directpv/pkg/types" 25 | "github.com/minio/directpv/pkg/utils" 26 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 27 | ) 28 | 29 | // SyncNodes compares the csinodes with directpvnode list and syncs them 30 | // It adds the missing nodes and deletes the non-existing nodes 31 | func (c Client) SyncNodes(ctx context.Context) (err error) { 32 | csiNodes, err := c.K8s().GetCSINodes(ctx) 33 | if err != nil { 34 | return fmt.Errorf("unable to get CSI nodes; %w", err) 35 | } 36 | nodes, err := c.NewNodeLister().Get(ctx) 37 | if err != nil { 38 | return fmt.Errorf("unable to get nodes; %w", err) 39 | } 40 | 41 | var nodeNames []string 42 | for _, node := range nodes { 43 | nodeNames = append(nodeNames, node.Name) 44 | } 45 | 46 | // Add missing nodes. 47 | for _, csiNode := range csiNodes { 48 | if !utils.Contains(nodeNames, csiNode) { 49 | node := types.NewNode(directpvtypes.NodeID(csiNode), []types.Device{}) 50 | node.Spec.Refresh = true 51 | if _, err = c.Node().Create(ctx, node, metav1.CreateOptions{}); err != nil { 52 | return fmt.Errorf("unable to create node %v; %w", csiNode, err) 53 | } 54 | } 55 | } 56 | 57 | // Remove non-existing nodes. 58 | for _, nodeName := range nodeNames { 59 | if !utils.Contains(csiNodes, nodeName) { 60 | if err = c.Node().Delete(ctx, nodeName, metav1.DeleteOptions{}); err != nil { 61 | return fmt.Errorf("unable to remove non-existing node %v; %w", nodeName, err) 62 | } 63 | } 64 | } 65 | return nil 66 | } 67 | -------------------------------------------------------------------------------- /pkg/client/drive_lister_test.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package client 18 | 19 | import ( 20 | "fmt" 21 | "testing" 22 | 23 | clientsetfake "github.com/minio/directpv/pkg/clientset/fake" 24 | "github.com/minio/directpv/pkg/types" 25 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 26 | "k8s.io/apimachinery/pkg/runtime" 27 | ) 28 | 29 | func TestGetDriveList(t *testing.T) { 30 | clientset := types.NewExtFakeClientset(clientsetfake.NewSimpleClientset()) 31 | SetDriveInterface(clientset.DirectpvLatest().DirectPVDrives()) 32 | drives, err := client.NewDriveLister().Get(t.Context()) 33 | if err != nil { 34 | t.Fatalf("unexpected error: %v", err) 35 | } 36 | if len(drives) != 0 { 37 | t.Fatalf("expected: 0, got: %v", len(drives)) 38 | } 39 | 40 | objects := []runtime.Object{} 41 | for i := 0; i < 2000; i++ { 42 | objects = append( 43 | objects, &types.Drive{ObjectMeta: metav1.ObjectMeta{Name: fmt.Sprintf("drive-%v", i)}}, 44 | ) 45 | } 46 | 47 | clientset = types.NewExtFakeClientset(clientsetfake.NewSimpleClientset(objects...)) 48 | SetDriveInterface(clientset.DirectpvLatest().DirectPVDrives()) 49 | drives, err = client.NewDriveLister().Get(t.Context()) 50 | if err != nil { 51 | t.Fatalf("unexpected error: %v", err) 52 | } 53 | if len(drives) != 2000 { 54 | t.Fatalf("expected: 2000, got: %v", len(drives)) 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /pkg/client/init_test.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package client 18 | 19 | func init() { 20 | FakeInit() 21 | } 22 | -------------------------------------------------------------------------------- /pkg/client/scheme.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package client 18 | 19 | import ( 20 | "github.com/minio/directpv/pkg/types" 21 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 22 | "k8s.io/apimachinery/pkg/runtime" 23 | "k8s.io/apimachinery/pkg/runtime/schema" 24 | "k8s.io/apimachinery/pkg/runtime/serializer" 25 | utilruntime "k8s.io/apimachinery/pkg/util/runtime" 26 | kubernetesscheme "k8s.io/client-go/kubernetes/scheme" 27 | ) 28 | 29 | // Scheme is new runtime scheme. 30 | var Scheme = runtime.NewScheme() 31 | 32 | // Codecs is new codec of new runtime scheme. 33 | var Codecs = serializer.NewCodecFactory(Scheme) 34 | 35 | // ParameterCodec is new parameter codec of new runtime scheme. 36 | var ParameterCodec = runtime.NewParameterCodec(Scheme) 37 | 38 | var localSchemeBuilder = runtime.SchemeBuilder{ 39 | kubernetesscheme.AddToScheme, 40 | types.LatestAddToScheme, 41 | } 42 | 43 | // AddToScheme adds all types of this clientset into the given scheme. This allows composition 44 | // of clientsets, like in: 45 | // 46 | // import ( 47 | // "k8s.io/client-go/kubernetes" 48 | // clientsetscheme "k8s.io/client-go/kubernetes/scheme" 49 | // aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" 50 | // ) 51 | // 52 | // kclientset, _ := kubernetes.NewForConfig(c) 53 | // _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) 54 | // 55 | // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types 56 | // correctly. 57 | var AddToScheme = localSchemeBuilder.AddToScheme 58 | 59 | func init() { 60 | metav1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) 61 | utilruntime.Must(AddToScheme(Scheme)) 62 | } 63 | -------------------------------------------------------------------------------- /pkg/clientset/fake/doc.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated fake clientset. 20 | package fake 21 | -------------------------------------------------------------------------------- /pkg/clientset/fake/register.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package fake 20 | 21 | import ( 22 | directpvv1beta1 "github.com/minio/directpv/pkg/apis/directpv.min.io/v1beta1" 23 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 24 | runtime "k8s.io/apimachinery/pkg/runtime" 25 | schema "k8s.io/apimachinery/pkg/runtime/schema" 26 | serializer "k8s.io/apimachinery/pkg/runtime/serializer" 27 | utilruntime "k8s.io/apimachinery/pkg/util/runtime" 28 | ) 29 | 30 | var scheme = runtime.NewScheme() 31 | var codecs = serializer.NewCodecFactory(scheme) 32 | 33 | var localSchemeBuilder = runtime.SchemeBuilder{ 34 | directpvv1beta1.AddToScheme, 35 | } 36 | 37 | // AddToScheme adds all types of this clientset into the given scheme. This allows composition 38 | // of clientsets, like in: 39 | // 40 | // import ( 41 | // "k8s.io/client-go/kubernetes" 42 | // clientsetscheme "k8s.io/client-go/kubernetes/scheme" 43 | // aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" 44 | // ) 45 | // 46 | // kclientset, _ := kubernetes.NewForConfig(c) 47 | // _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) 48 | // 49 | // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types 50 | // correctly. 51 | var AddToScheme = localSchemeBuilder.AddToScheme 52 | 53 | func init() { 54 | v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) 55 | utilruntime.Must(AddToScheme(scheme)) 56 | } 57 | -------------------------------------------------------------------------------- /pkg/clientset/scheme/doc.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package contains the scheme of the automatically generated clientset. 20 | package scheme 21 | -------------------------------------------------------------------------------- /pkg/clientset/scheme/register.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package scheme 20 | 21 | import ( 22 | directpvv1beta1 "github.com/minio/directpv/pkg/apis/directpv.min.io/v1beta1" 23 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 24 | runtime "k8s.io/apimachinery/pkg/runtime" 25 | schema "k8s.io/apimachinery/pkg/runtime/schema" 26 | serializer "k8s.io/apimachinery/pkg/runtime/serializer" 27 | utilruntime "k8s.io/apimachinery/pkg/util/runtime" 28 | ) 29 | 30 | var Scheme = runtime.NewScheme() 31 | var Codecs = serializer.NewCodecFactory(Scheme) 32 | var ParameterCodec = runtime.NewParameterCodec(Scheme) 33 | var localSchemeBuilder = runtime.SchemeBuilder{ 34 | directpvv1beta1.AddToScheme, 35 | } 36 | 37 | // AddToScheme adds all types of this clientset into the given scheme. This allows composition 38 | // of clientsets, like in: 39 | // 40 | // import ( 41 | // "k8s.io/client-go/kubernetes" 42 | // clientsetscheme "k8s.io/client-go/kubernetes/scheme" 43 | // aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" 44 | // ) 45 | // 46 | // kclientset, _ := kubernetes.NewForConfig(c) 47 | // _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) 48 | // 49 | // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types 50 | // correctly. 51 | var AddToScheme = localSchemeBuilder.AddToScheme 52 | 53 | func init() { 54 | v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) 55 | utilruntime.Must(AddToScheme(Scheme)) 56 | } 57 | -------------------------------------------------------------------------------- /pkg/clientset/typed/directpv.min.io/v1beta1/doc.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated typed clients. 20 | package v1beta1 21 | -------------------------------------------------------------------------------- /pkg/clientset/typed/directpv.min.io/v1beta1/fake/doc.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // Package fake has the automatically generated clients. 20 | package fake 21 | -------------------------------------------------------------------------------- /pkg/clientset/typed/directpv.min.io/v1beta1/fake/fake_directpv.min.io_client.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package fake 20 | 21 | import ( 22 | v1beta1 "github.com/minio/directpv/pkg/clientset/typed/directpv.min.io/v1beta1" 23 | rest "k8s.io/client-go/rest" 24 | testing "k8s.io/client-go/testing" 25 | ) 26 | 27 | type FakeDirectpvV1beta1 struct { 28 | *testing.Fake 29 | } 30 | 31 | func (c *FakeDirectpvV1beta1) DirectPVDrives() v1beta1.DirectPVDriveInterface { 32 | return newFakeDirectPVDrives(c) 33 | } 34 | 35 | func (c *FakeDirectpvV1beta1) DirectPVInitRequests() v1beta1.DirectPVInitRequestInterface { 36 | return newFakeDirectPVInitRequests(c) 37 | } 38 | 39 | func (c *FakeDirectpvV1beta1) DirectPVNodes() v1beta1.DirectPVNodeInterface { 40 | return newFakeDirectPVNodes(c) 41 | } 42 | 43 | func (c *FakeDirectpvV1beta1) DirectPVVolumes() v1beta1.DirectPVVolumeInterface { 44 | return newFakeDirectPVVolumes(c) 45 | } 46 | 47 | // RESTClient returns a RESTClient that is used to communicate 48 | // with API server by this client implementation. 49 | func (c *FakeDirectpvV1beta1) RESTClient() rest.Interface { 50 | var ret *rest.RESTClient 51 | return ret 52 | } 53 | -------------------------------------------------------------------------------- /pkg/clientset/typed/directpv.min.io/v1beta1/fake/fake_directpvdrive.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package fake 20 | 21 | import ( 22 | v1beta1 "github.com/minio/directpv/pkg/apis/directpv.min.io/v1beta1" 23 | directpvminiov1beta1 "github.com/minio/directpv/pkg/clientset/typed/directpv.min.io/v1beta1" 24 | gentype "k8s.io/client-go/gentype" 25 | ) 26 | 27 | // fakeDirectPVDrives implements DirectPVDriveInterface 28 | type fakeDirectPVDrives struct { 29 | *gentype.FakeClientWithList[*v1beta1.DirectPVDrive, *v1beta1.DirectPVDriveList] 30 | Fake *FakeDirectpvV1beta1 31 | } 32 | 33 | func newFakeDirectPVDrives(fake *FakeDirectpvV1beta1) directpvminiov1beta1.DirectPVDriveInterface { 34 | return &fakeDirectPVDrives{ 35 | gentype.NewFakeClientWithList[*v1beta1.DirectPVDrive, *v1beta1.DirectPVDriveList]( 36 | fake.Fake, 37 | "", 38 | v1beta1.SchemeGroupVersion.WithResource("directpvdrives"), 39 | v1beta1.SchemeGroupVersion.WithKind("DirectPVDrive"), 40 | func() *v1beta1.DirectPVDrive { return &v1beta1.DirectPVDrive{} }, 41 | func() *v1beta1.DirectPVDriveList { return &v1beta1.DirectPVDriveList{} }, 42 | func(dst, src *v1beta1.DirectPVDriveList) { dst.ListMeta = src.ListMeta }, 43 | func(list *v1beta1.DirectPVDriveList) []*v1beta1.DirectPVDrive { 44 | return gentype.ToPointerSlice(list.Items) 45 | }, 46 | func(list *v1beta1.DirectPVDriveList, items []*v1beta1.DirectPVDrive) { 47 | list.Items = gentype.FromPointerSlice(items) 48 | }, 49 | ), 50 | fake, 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /pkg/clientset/typed/directpv.min.io/v1beta1/fake/fake_directpvinitrequest.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package fake 20 | 21 | import ( 22 | v1beta1 "github.com/minio/directpv/pkg/apis/directpv.min.io/v1beta1" 23 | directpvminiov1beta1 "github.com/minio/directpv/pkg/clientset/typed/directpv.min.io/v1beta1" 24 | gentype "k8s.io/client-go/gentype" 25 | ) 26 | 27 | // fakeDirectPVInitRequests implements DirectPVInitRequestInterface 28 | type fakeDirectPVInitRequests struct { 29 | *gentype.FakeClientWithList[*v1beta1.DirectPVInitRequest, *v1beta1.DirectPVInitRequestList] 30 | Fake *FakeDirectpvV1beta1 31 | } 32 | 33 | func newFakeDirectPVInitRequests(fake *FakeDirectpvV1beta1) directpvminiov1beta1.DirectPVInitRequestInterface { 34 | return &fakeDirectPVInitRequests{ 35 | gentype.NewFakeClientWithList[*v1beta1.DirectPVInitRequest, *v1beta1.DirectPVInitRequestList]( 36 | fake.Fake, 37 | "", 38 | v1beta1.SchemeGroupVersion.WithResource("directpvinitrequests"), 39 | v1beta1.SchemeGroupVersion.WithKind("DirectPVInitRequest"), 40 | func() *v1beta1.DirectPVInitRequest { return &v1beta1.DirectPVInitRequest{} }, 41 | func() *v1beta1.DirectPVInitRequestList { return &v1beta1.DirectPVInitRequestList{} }, 42 | func(dst, src *v1beta1.DirectPVInitRequestList) { dst.ListMeta = src.ListMeta }, 43 | func(list *v1beta1.DirectPVInitRequestList) []*v1beta1.DirectPVInitRequest { 44 | return gentype.ToPointerSlice(list.Items) 45 | }, 46 | func(list *v1beta1.DirectPVInitRequestList, items []*v1beta1.DirectPVInitRequest) { 47 | list.Items = gentype.FromPointerSlice(items) 48 | }, 49 | ), 50 | fake, 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /pkg/clientset/typed/directpv.min.io/v1beta1/fake/fake_directpvnode.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package fake 20 | 21 | import ( 22 | v1beta1 "github.com/minio/directpv/pkg/apis/directpv.min.io/v1beta1" 23 | directpvminiov1beta1 "github.com/minio/directpv/pkg/clientset/typed/directpv.min.io/v1beta1" 24 | gentype "k8s.io/client-go/gentype" 25 | ) 26 | 27 | // fakeDirectPVNodes implements DirectPVNodeInterface 28 | type fakeDirectPVNodes struct { 29 | *gentype.FakeClientWithList[*v1beta1.DirectPVNode, *v1beta1.DirectPVNodeList] 30 | Fake *FakeDirectpvV1beta1 31 | } 32 | 33 | func newFakeDirectPVNodes(fake *FakeDirectpvV1beta1) directpvminiov1beta1.DirectPVNodeInterface { 34 | return &fakeDirectPVNodes{ 35 | gentype.NewFakeClientWithList[*v1beta1.DirectPVNode, *v1beta1.DirectPVNodeList]( 36 | fake.Fake, 37 | "", 38 | v1beta1.SchemeGroupVersion.WithResource("directpvnodes"), 39 | v1beta1.SchemeGroupVersion.WithKind("DirectPVNode"), 40 | func() *v1beta1.DirectPVNode { return &v1beta1.DirectPVNode{} }, 41 | func() *v1beta1.DirectPVNodeList { return &v1beta1.DirectPVNodeList{} }, 42 | func(dst, src *v1beta1.DirectPVNodeList) { dst.ListMeta = src.ListMeta }, 43 | func(list *v1beta1.DirectPVNodeList) []*v1beta1.DirectPVNode { 44 | return gentype.ToPointerSlice(list.Items) 45 | }, 46 | func(list *v1beta1.DirectPVNodeList, items []*v1beta1.DirectPVNode) { 47 | list.Items = gentype.FromPointerSlice(items) 48 | }, 49 | ), 50 | fake, 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /pkg/clientset/typed/directpv.min.io/v1beta1/fake/fake_directpvvolume.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package fake 20 | 21 | import ( 22 | v1beta1 "github.com/minio/directpv/pkg/apis/directpv.min.io/v1beta1" 23 | directpvminiov1beta1 "github.com/minio/directpv/pkg/clientset/typed/directpv.min.io/v1beta1" 24 | gentype "k8s.io/client-go/gentype" 25 | ) 26 | 27 | // fakeDirectPVVolumes implements DirectPVVolumeInterface 28 | type fakeDirectPVVolumes struct { 29 | *gentype.FakeClientWithList[*v1beta1.DirectPVVolume, *v1beta1.DirectPVVolumeList] 30 | Fake *FakeDirectpvV1beta1 31 | } 32 | 33 | func newFakeDirectPVVolumes(fake *FakeDirectpvV1beta1) directpvminiov1beta1.DirectPVVolumeInterface { 34 | return &fakeDirectPVVolumes{ 35 | gentype.NewFakeClientWithList[*v1beta1.DirectPVVolume, *v1beta1.DirectPVVolumeList]( 36 | fake.Fake, 37 | "", 38 | v1beta1.SchemeGroupVersion.WithResource("directpvvolumes"), 39 | v1beta1.SchemeGroupVersion.WithKind("DirectPVVolume"), 40 | func() *v1beta1.DirectPVVolume { return &v1beta1.DirectPVVolume{} }, 41 | func() *v1beta1.DirectPVVolumeList { return &v1beta1.DirectPVVolumeList{} }, 42 | func(dst, src *v1beta1.DirectPVVolumeList) { dst.ListMeta = src.ListMeta }, 43 | func(list *v1beta1.DirectPVVolumeList) []*v1beta1.DirectPVVolume { 44 | return gentype.ToPointerSlice(list.Items) 45 | }, 46 | func(list *v1beta1.DirectPVVolumeList, items []*v1beta1.DirectPVVolume) { 47 | list.Items = gentype.FromPointerSlice(items) 48 | }, 49 | ), 50 | fake, 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /pkg/clientset/typed/directpv.min.io/v1beta1/generated_expansion.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package v1beta1 20 | 21 | type DirectPVDriveExpansion interface{} 22 | 23 | type DirectPVInitRequestExpansion interface{} 24 | 25 | type DirectPVNodeExpansion interface{} 26 | 27 | type DirectPVVolumeExpansion interface{} 28 | -------------------------------------------------------------------------------- /pkg/converter/drive_downgrade.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package converter 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" 21 | "k8s.io/klog/v2" 22 | ) 23 | 24 | func downgradeDriveObject(object *unstructured.Unstructured, toVersion string) error { 25 | switch object.GetAPIVersion() { 26 | case versionV1Beta1: 27 | if toVersion == versionV1Beta1 { 28 | klog.V(10).Info("No migration required") 29 | break 30 | } 31 | default: 32 | klog.Fatalf("unknown object API version %v to convert to %v", object.GetAPIVersion(), toVersion) 33 | } 34 | return nil 35 | } 36 | -------------------------------------------------------------------------------- /pkg/converter/drive_upgrade.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package converter 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" 21 | "k8s.io/klog/v2" 22 | ) 23 | 24 | func upgradeDriveObject(object *unstructured.Unstructured, toVersion string) error { 25 | switch object.GetAPIVersion() { 26 | case versionV1Beta1: 27 | if toVersion == versionV1Beta1 { 28 | klog.V(10).Info("Successfully migrated") 29 | break 30 | } 31 | default: 32 | klog.Fatalf("unknown object API version %v to convert to %v", object.GetAPIVersion(), toVersion) 33 | } 34 | return nil 35 | } 36 | -------------------------------------------------------------------------------- /pkg/converter/init_request_downgrade.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package converter 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" 21 | "k8s.io/klog/v2" 22 | ) 23 | 24 | func downgradeInitRequestObject(object *unstructured.Unstructured, toVersion string) error { 25 | switch object.GetAPIVersion() { 26 | case versionV1Beta1: 27 | if toVersion == versionV1Beta1 { 28 | klog.V(10).Info("No migration required") 29 | break 30 | } 31 | default: 32 | klog.Fatalf("unknown object API version %v to convert to %v", object.GetAPIVersion(), toVersion) 33 | } 34 | return nil 35 | } 36 | -------------------------------------------------------------------------------- /pkg/converter/init_request_upgrade.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package converter 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" 21 | "k8s.io/klog/v2" 22 | ) 23 | 24 | func upgradeInitRequestObject(object *unstructured.Unstructured, toVersion string) error { 25 | switch object.GetAPIVersion() { 26 | case versionV1Beta1: 27 | if toVersion == versionV1Beta1 { 28 | klog.V(10).Info("Successfully migrated") 29 | break 30 | } 31 | default: 32 | klog.Fatalf("unknown object API version %v to convert to %v", object.GetAPIVersion(), toVersion) 33 | } 34 | return nil 35 | } 36 | -------------------------------------------------------------------------------- /pkg/converter/node_downgrade.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package converter 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" 21 | "k8s.io/klog/v2" 22 | ) 23 | 24 | func downgradeNodeObject(object *unstructured.Unstructured, toVersion string) error { 25 | switch object.GetAPIVersion() { 26 | case versionV1Beta1: 27 | if toVersion == versionV1Beta1 { 28 | klog.V(10).Info("No migration required") 29 | break 30 | } 31 | default: 32 | klog.Fatalf("unknown object API version %v to convert to %v", object.GetAPIVersion(), toVersion) 33 | } 34 | return nil 35 | } 36 | -------------------------------------------------------------------------------- /pkg/converter/node_upgrade.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package converter 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" 21 | "k8s.io/klog/v2" 22 | ) 23 | 24 | func upgradeNodeObject(object *unstructured.Unstructured, toVersion string) error { 25 | switch object.GetAPIVersion() { 26 | case versionV1Beta1: 27 | if toVersion == versionV1Beta1 { 28 | klog.V(10).Info("Successfully migrated") 29 | break 30 | } 31 | default: 32 | klog.Fatalf("unknown object API version %v to convert to %v", object.GetAPIVersion(), toVersion) 33 | } 34 | return nil 35 | } 36 | -------------------------------------------------------------------------------- /pkg/converter/volume_downgrade.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package converter 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" 21 | "k8s.io/klog/v2" 22 | ) 23 | 24 | func downgradeVolumeObject(object *unstructured.Unstructured, toVersion string) error { 25 | switch object.GetAPIVersion() { 26 | case versionV1Beta1: 27 | if toVersion == versionV1Beta1 { 28 | klog.V(10).Info("Successfully migrated") 29 | break 30 | } 31 | default: 32 | klog.Fatalf("unknown object API version %v to convert to %v", object.GetAPIVersion(), toVersion) 33 | } 34 | return nil 35 | } 36 | -------------------------------------------------------------------------------- /pkg/converter/volume_upgrade.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package converter 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" 21 | "k8s.io/klog/v2" 22 | ) 23 | 24 | func upgradeVolumeObject(object *unstructured.Unstructured, toVersion string) error { 25 | switch object.GetAPIVersion() { 26 | case versionV1Beta1: 27 | if toVersion == versionV1Beta1 { 28 | klog.V(10).Info("Successfully migrated") 29 | break 30 | } 31 | default: 32 | klog.Fatalf("unknown object API version %v to convert to %v", object.GetAPIVersion(), toVersion) 33 | } 34 | 35 | return nil 36 | } 37 | -------------------------------------------------------------------------------- /pkg/csi/controller/legacy_server.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package controller 18 | 19 | import ( 20 | "context" 21 | 22 | "github.com/container-storage-interface/spec/lib/go/csi" 23 | "github.com/minio/directpv/pkg/consts" 24 | "google.golang.org/grpc/codes" 25 | "google.golang.org/grpc/status" 26 | ) 27 | 28 | // LegacyServer denotes legacy controller server. 29 | type LegacyServer struct { 30 | Server 31 | } 32 | 33 | // NewLegacyServer creates new legacy controller server. 34 | func NewLegacyServer() *LegacyServer { 35 | return &LegacyServer{} 36 | } 37 | 38 | // CreateVolume - Creates a volume 39 | // reference: https://github.com/container-storage-interface/spec/blob/master/spec.md#createvolume 40 | func (c *LegacyServer) CreateVolume(_ context.Context, _ *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error) { 41 | return nil, status.Errorf( 42 | codes.InvalidArgument, 43 | "legacy volume creation not supported; use %v storage class", 44 | consts.Identity, 45 | ) 46 | } 47 | -------------------------------------------------------------------------------- /pkg/csi/node/fake.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package node 18 | 19 | import ( 20 | "context" 21 | "errors" 22 | 23 | "github.com/minio/directpv/pkg/sys" 24 | "github.com/minio/directpv/pkg/xfs" 25 | ) 26 | 27 | const testNodeName = "test-node" 28 | 29 | func createFakeServer() *Server { 30 | return &Server{ 31 | nodeID: testNodeName, 32 | identity: "test-identity", 33 | rack: "test-rack", 34 | zone: "test-zone", 35 | region: "test-region", 36 | getMounts: func() (*sys.MountInfo, error) { return nil, nil }, 37 | getDeviceByFSUUID: func(_ string) (string, error) { return "", nil }, 38 | bindMount: func(_, _ string, _ bool) error { return nil }, 39 | unmount: func(_ string) error { return nil }, 40 | getQuota: func(_ context.Context, _, _ string) (quota *xfs.Quota, err error) { 41 | return &xfs.Quota{}, nil 42 | }, 43 | setQuota: func(_ context.Context, _, _, _ string, _ xfs.Quota, _ bool) (err error) { 44 | return nil 45 | }, 46 | mkdir: func(path string) error { 47 | if path == "" { 48 | return errors.New("path is empty") 49 | } 50 | return nil 51 | }, 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /pkg/csi/node/legacy_server.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package node 18 | 19 | import ( 20 | "context" 21 | 22 | "github.com/container-storage-interface/spec/lib/go/csi" 23 | directpvtypes "github.com/minio/directpv/pkg/apis/directpv.min.io/types" 24 | ) 25 | 26 | // LegacyServer denotes legacy node server. 27 | type LegacyServer struct { 28 | Server 29 | } 30 | 31 | // NewLegacyServer creates legacy node server. 32 | func NewLegacyServer(nodeID directpvtypes.NodeID, rack, zone, region string) *LegacyServer { 33 | return &LegacyServer{Server: newServer("direct-csi-min-io", nodeID, rack, zone, region)} 34 | } 35 | 36 | // NodeGetInfo gets node information. 37 | // reference: https://github.com/container-storage-interface/spec/blob/master/spec.md#nodegetinfo 38 | func (server *LegacyServer) NodeGetInfo(_ context.Context, _ *csi.NodeGetInfoRequest) (*csi.NodeGetInfoResponse, error) { 39 | topology := &csi.Topology{ 40 | Segments: map[string]string{ 41 | "direct.csi.min.io/identity": server.identity, 42 | "direct.csi.min.io/rack": server.rack, 43 | "direct.csi.min.io/region": server.region, 44 | "direct.csi.min.io/zone": server.zone, 45 | "direct.csi.min.io/node": string(server.nodeID), 46 | }, 47 | } 48 | 49 | return &csi.NodeGetInfoResponse{ 50 | NodeId: string(server.nodeID), 51 | AccessibleTopology: topology, 52 | }, nil 53 | } 54 | -------------------------------------------------------------------------------- /pkg/csi/node/server_test.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2023 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package node 18 | 19 | import ( 20 | "context" 21 | "testing" 22 | 23 | "github.com/container-storage-interface/spec/lib/go/csi" 24 | "github.com/minio/directpv/pkg/client" 25 | clientsetfake "github.com/minio/directpv/pkg/clientset/fake" 26 | "github.com/minio/directpv/pkg/types" 27 | "github.com/minio/directpv/pkg/xfs" 28 | ) 29 | 30 | func init() { 31 | client.FakeInit() 32 | } 33 | 34 | func TestNodeExpandVolume(t *testing.T) { 35 | volumeID := "volume-id-1" 36 | volume := types.NewVolume(volumeID, "fsuuid1", "node-1", "drive-1", "sda", 100*MiB) 37 | volume.Status.DataPath = "volume/id/1/data/path" 38 | volume.Status.StagingTargetPath = "volume/id/1/staging/target/path" 39 | 40 | clientset := types.NewExtFakeClientset(clientsetfake.NewSimpleClientset(volume)) 41 | client.SetDriveInterface(clientset.DirectpvLatest().DirectPVDrives()) 42 | client.SetVolumeInterface(clientset.DirectpvLatest().DirectPVVolumes()) 43 | 44 | nodeServer := createFakeServer() 45 | nodeServer.getDeviceByFSUUID = func(_ string) (string, error) { 46 | return "sda", nil 47 | } 48 | nodeServer.setQuota = func(_ context.Context, _, _, _ string, _ xfs.Quota, _ bool) error { 49 | return nil 50 | } 51 | 52 | if _, err := nodeServer.NodeExpandVolume(t.Context(), &csi.NodeExpandVolumeRequest{ 53 | VolumeId: volumeID, 54 | VolumePath: "volume-id-1-volume-path", 55 | CapacityRange: &csi.CapacityRange{RequiredBytes: 100 * MiB}, 56 | }); err != nil { 57 | t.Fatal(err) 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /pkg/device/probe_other.go: -------------------------------------------------------------------------------- 1 | //go:build !linux 2 | 3 | // This file is part of MinIO DirectPV 4 | // Copyright (c) 2022 MinIO, Inc. 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU Affero General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU Affero General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU Affero General Public License 17 | // along with this program. If not, see . 18 | 19 | package device 20 | 21 | import ( 22 | "fmt" 23 | "runtime" 24 | ) 25 | 26 | func probe() (devices []Device, err error) { 27 | return nil, fmt.Errorf("unsupported operating system %v", runtime.GOOS) 28 | } 29 | 30 | func probeDevices(majorMinor ...string) (devices []Device, err error) { 31 | return nil, fmt.Errorf("unsupported operating system %v", runtime.GOOS) 32 | } 33 | -------------------------------------------------------------------------------- /pkg/device/utils.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package device 18 | 19 | import ( 20 | "bufio" 21 | "errors" 22 | "io" 23 | "os" 24 | "sort" 25 | "strings" 26 | ) 27 | 28 | func readdirnames(dirname string) ([]string, error) { 29 | dir, err := os.Open(dirname) 30 | if err != nil { 31 | if errors.Is(err, os.ErrNotExist) { 32 | err = nil 33 | } 34 | return nil, err 35 | } 36 | defer dir.Close() 37 | return dir.Readdirnames(-1) 38 | } 39 | 40 | func readFirstLine(filename string) (string, error) { 41 | getError := func(err error) error { 42 | switch { 43 | case errors.Is(err, os.ErrNotExist), errors.Is(err, os.ErrInvalid): 44 | return nil 45 | case strings.Contains(strings.ToLower(err.Error()), "no such device"): 46 | return nil 47 | case strings.Contains(strings.ToLower(err.Error()), "invalid argument"): 48 | return nil 49 | } 50 | return err 51 | } 52 | 53 | file, err := os.Open(filename) 54 | if err != nil { 55 | return "", getError(err) 56 | } 57 | defer file.Close() 58 | s, err := bufio.NewReader(file).ReadString('\n') 59 | if err != nil && !errors.Is(err, io.EOF) { 60 | return "", getError(err) 61 | } 62 | return strings.TrimSpace(s), nil 63 | } 64 | 65 | func toSlice(m map[string]string, separator string) []string { 66 | keys := []string{} 67 | for key := range m { 68 | keys = append(keys, key) 69 | } 70 | sort.Strings(keys) 71 | 72 | result := []string{} 73 | for _, key := range keys { 74 | result = append(result, key+separator+m[key]) 75 | } 76 | return result 77 | } 78 | -------------------------------------------------------------------------------- /pkg/initrequest/reflink_other.go: -------------------------------------------------------------------------------- 1 | //go:build !linux 2 | 3 | // This file is part of MinIO DirectPV 4 | // Copyright (c) 2022 MinIO, Inc. 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU Affero General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU Affero General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU Affero General Public License 17 | // along with this program. If not, see . 18 | 19 | package initrequest 20 | 21 | import ( 22 | "context" 23 | "fmt" 24 | "runtime" 25 | ) 26 | 27 | func reflinkSupported(ctx context.Context) (bool, error) { 28 | return false, fmt.Errorf("unsupported operating system %v", runtime.GOOS) 29 | } 30 | -------------------------------------------------------------------------------- /pkg/legacy/apis/direct.csi.min.io/v1alpha1/doc.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // +k8s:deepcopy-gen=package,register 18 | // +k8s:openapi-gen=true 19 | // +groupName=direct.csi.min.io 20 | 21 | package v1alpha1 22 | -------------------------------------------------------------------------------- /pkg/legacy/apis/direct.csi.min.io/v1alpha1/register.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package v1alpha1 18 | 19 | import ( 20 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 | "k8s.io/apimachinery/pkg/runtime" 22 | "k8s.io/apimachinery/pkg/runtime/schema" 23 | ) 24 | 25 | const ( 26 | // Group denotes group name. 27 | Group = "direct.csi.min.io" 28 | 29 | // Version denotes API version. 30 | Version = "v1alpha1" 31 | ) 32 | 33 | // SchemeGroupVersion is group version used to register these objects 34 | var SchemeGroupVersion = schema.GroupVersion{Group: Group, Version: Version} 35 | 36 | // Resource takes an unqualified resource and returns a Group qualified GroupResource 37 | func Resource(resource string) schema.GroupResource { 38 | return SchemeGroupVersion.WithResource(resource).GroupResource() 39 | } 40 | 41 | var ( 42 | // SchemeBuilder points to a list of functions added to Scheme. 43 | SchemeBuilder runtime.SchemeBuilder 44 | localSchemeBuilder = &SchemeBuilder 45 | // AddToScheme applies all stored functions to Scheme. 46 | AddToScheme = localSchemeBuilder.AddToScheme 47 | ) 48 | 49 | func init() { 50 | // We only register manually written functions here. The registration of the 51 | // generated functions takes place in the generated files. The separation 52 | // makes the code compile even when the generated files are missing. 53 | localSchemeBuilder.Register(addKnownTypes) 54 | } 55 | 56 | // Adds the list of known types to api.Scheme. 57 | func addKnownTypes(scheme *runtime.Scheme) error { 58 | scheme.AddKnownTypes(SchemeGroupVersion, 59 | &DirectCSIDrive{}, 60 | &DirectCSIDriveList{}, 61 | &DirectCSIVolume{}, 62 | &DirectCSIVolumeList{}, 63 | ) 64 | v1.AddToGroupVersion(scheme, SchemeGroupVersion) 65 | return nil 66 | } 67 | -------------------------------------------------------------------------------- /pkg/legacy/apis/direct.csi.min.io/v1beta1/doc.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // +k8s:deepcopy-gen=package,register 18 | // +k8s:openapi-gen=true 19 | // +groupName=direct.csi.min.io 20 | 21 | package v1beta1 22 | -------------------------------------------------------------------------------- /pkg/legacy/apis/direct.csi.min.io/v1beta1/register.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package v1beta1 18 | 19 | import ( 20 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 | "k8s.io/apimachinery/pkg/runtime" 22 | "k8s.io/apimachinery/pkg/runtime/schema" 23 | ) 24 | 25 | const ( 26 | // Group denotes group name. 27 | Group = "direct.csi.min.io" 28 | 29 | // Version denotes API version. 30 | Version = "v1beta1" 31 | ) 32 | 33 | // SchemeGroupVersion is group version used to register these objects 34 | var SchemeGroupVersion = schema.GroupVersion{Group: Group, Version: Version} 35 | 36 | // Resource takes an unqualified resource and returns a Group qualified GroupResource 37 | func Resource(resource string) schema.GroupResource { 38 | return SchemeGroupVersion.WithResource(resource).GroupResource() 39 | } 40 | 41 | var ( 42 | // SchemeBuilder points to a list of functions added to Scheme. 43 | SchemeBuilder runtime.SchemeBuilder 44 | localSchemeBuilder = &SchemeBuilder 45 | // AddToScheme applies all stored functions to Scheme. 46 | AddToScheme = localSchemeBuilder.AddToScheme 47 | ) 48 | 49 | func init() { 50 | // We only register manually written functions here. The registration of the 51 | // generated functions takes place in the generated files. The separation 52 | // makes the code compile even when the generated files are missing. 53 | localSchemeBuilder.Register(addKnownTypes) 54 | } 55 | 56 | // Adds the list of known types to api.Scheme. 57 | func addKnownTypes(scheme *runtime.Scheme) error { 58 | scheme.AddKnownTypes(SchemeGroupVersion, 59 | &DirectCSIDrive{}, 60 | &DirectCSIDriveList{}, 61 | &DirectCSIVolume{}, 62 | &DirectCSIVolumeList{}, 63 | ) 64 | v1.AddToGroupVersion(scheme, SchemeGroupVersion) 65 | return nil 66 | } 67 | -------------------------------------------------------------------------------- /pkg/legacy/apis/direct.csi.min.io/v1beta2/doc.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // +k8s:deepcopy-gen=package,register 18 | // +k8s:openapi-gen=true 19 | // +groupName=direct.csi.min.io 20 | // +k8s:conversion-gen=github.com/minio/directpv/pkg/legacy/apis/direct.csi.min.io/v1beta1 21 | 22 | package v1beta2 23 | -------------------------------------------------------------------------------- /pkg/legacy/apis/direct.csi.min.io/v1beta3/doc.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // +k8s:deepcopy-gen=package,register 18 | // +k8s:openapi-gen=true 19 | // +groupName=direct.csi.min.io 20 | // +k8s:conversion-gen=github.com/minio/directpv/pkg/legacy/apis/direct.csi.min.io/v1beta2 21 | 22 | package v1beta3 23 | -------------------------------------------------------------------------------- /pkg/legacy/apis/direct.csi.min.io/v1beta4/doc.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // +k8s:deepcopy-gen=package,register 18 | // +k8s:openapi-gen=true 19 | // +groupName=direct.csi.min.io 20 | // +k8s:conversion-gen=github.com/minio/directpv/pkg/legacy/apis/direct.csi.min.io/v1beta3 21 | 22 | package v1beta4 23 | -------------------------------------------------------------------------------- /pkg/legacy/apis/direct.csi.min.io/v1beta5/doc.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // +k8s:deepcopy-gen=package,register 18 | // +k8s:openapi-gen=true 19 | // +groupName=direct.csi.min.io 20 | // +k8s:conversion-gen=github.com/minio/directpv/pkg/legacy/apis/direct.csi.min.io/v1beta4 21 | 22 | package v1beta5 23 | -------------------------------------------------------------------------------- /pkg/legacy/client/fake.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package client 18 | 19 | import ( 20 | "github.com/minio/directpv/pkg/k8s" 21 | legacyclientsetfake "github.com/minio/directpv/pkg/legacy/clientset/fake" 22 | ) 23 | 24 | // FakeInit initializes fake clients. 25 | func FakeInit() { 26 | k8s.FakeInit() 27 | fakeClientset := legacyclientsetfake.NewSimpleClientset() 28 | client = &Client{ 29 | DriveClient: fakeClientset.DirectV1beta5().DirectCSIDrives(), 30 | VolumeClient: fakeClientset.DirectV1beta5().DirectCSIVolumes(), 31 | } 32 | } 33 | 34 | // SetDriveClient sets drive interface from fake clientset. 35 | // Note: To be used for writing test cases only 36 | func SetDriveClient(clientset *legacyclientsetfake.Clientset) { 37 | client.DriveClient = clientset.DirectV1beta5().DirectCSIDrives() 38 | } 39 | 40 | // SetVolumeClient sets volume interface from fake clientset. 41 | // Note: To be used for writing test cases only 42 | func SetVolumeClient(clientset *legacyclientsetfake.Clientset) { 43 | client.VolumeClient = clientset.DirectV1beta5().DirectCSIVolumes() 44 | } 45 | -------------------------------------------------------------------------------- /pkg/legacy/client/init.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package client 18 | 19 | import ( 20 | "fmt" 21 | "sync/atomic" 22 | 23 | "github.com/minio/directpv/pkg/k8s" 24 | "k8s.io/klog/v2" 25 | ) 26 | 27 | // Init initializes legacy clients. 28 | func Init() { 29 | if atomic.AddInt32(&initialized, 1) != 1 { 30 | return 31 | } 32 | var err error 33 | if err = k8s.Init(); err != nil { 34 | klog.Fatalf("unable to initialize k8s clients; %v", err) 35 | } 36 | client, err = NewClient(k8s.GetClient()) 37 | if err != nil { 38 | klog.Fatalf("unable to create legacy client; %v", err) 39 | } 40 | } 41 | 42 | // NewClient creates a legacy client 43 | func NewClient(k8sClient *k8s.Client) (*Client, error) { 44 | driveClient, err := DirectCSIDriveInterfaceForConfig(k8sClient) 45 | if err != nil { 46 | return nil, fmt.Errorf("unable to create new DirectCSI drive interface; %v", err) 47 | } 48 | volumeClient, err := DirectCSIVolumeInterfaceForConfig(k8sClient) 49 | if err != nil { 50 | return nil, fmt.Errorf("unable to create new DirectCSI volume interface; %v", err) 51 | } 52 | return &Client{ 53 | DriveClient: driveClient, 54 | VolumeClient: volumeClient, 55 | K8sClient: k8sClient, 56 | }, nil 57 | } 58 | -------------------------------------------------------------------------------- /pkg/legacy/clientset/doc.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated clientset. 20 | package clientset 21 | -------------------------------------------------------------------------------- /pkg/legacy/clientset/fake/doc.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated fake clientset. 20 | package fake 21 | -------------------------------------------------------------------------------- /pkg/legacy/clientset/scheme/doc.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package contains the scheme of the automatically generated clientset. 20 | package scheme 21 | -------------------------------------------------------------------------------- /pkg/legacy/clientset/typed/direct.csi.min.io/v1alpha1/doc.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated typed clients. 20 | package v1alpha1 21 | -------------------------------------------------------------------------------- /pkg/legacy/clientset/typed/direct.csi.min.io/v1alpha1/fake/doc.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // Package fake has the automatically generated clients. 20 | package fake 21 | -------------------------------------------------------------------------------- /pkg/legacy/clientset/typed/direct.csi.min.io/v1alpha1/fake/fake_direct.csi.min.io_client.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package fake 20 | 21 | import ( 22 | v1alpha1 "github.com/minio/directpv/pkg/legacy/clientset/typed/direct.csi.min.io/v1alpha1" 23 | rest "k8s.io/client-go/rest" 24 | testing "k8s.io/client-go/testing" 25 | ) 26 | 27 | type FakeDirectV1alpha1 struct { 28 | *testing.Fake 29 | } 30 | 31 | func (c *FakeDirectV1alpha1) DirectCSIDrives() v1alpha1.DirectCSIDriveInterface { 32 | return &FakeDirectCSIDrives{c} 33 | } 34 | 35 | func (c *FakeDirectV1alpha1) DirectCSIVolumes() v1alpha1.DirectCSIVolumeInterface { 36 | return &FakeDirectCSIVolumes{c} 37 | } 38 | 39 | // RESTClient returns a RESTClient that is used to communicate 40 | // with API server by this client implementation. 41 | func (c *FakeDirectV1alpha1) RESTClient() rest.Interface { 42 | var ret *rest.RESTClient 43 | return ret 44 | } 45 | -------------------------------------------------------------------------------- /pkg/legacy/clientset/typed/direct.csi.min.io/v1alpha1/generated_expansion.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package v1alpha1 20 | 21 | type DirectCSIDriveExpansion interface{} 22 | 23 | type DirectCSIVolumeExpansion interface{} 24 | -------------------------------------------------------------------------------- /pkg/legacy/clientset/typed/direct.csi.min.io/v1beta1/doc.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated typed clients. 20 | package v1beta1 21 | -------------------------------------------------------------------------------- /pkg/legacy/clientset/typed/direct.csi.min.io/v1beta1/fake/doc.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // Package fake has the automatically generated clients. 20 | package fake 21 | -------------------------------------------------------------------------------- /pkg/legacy/clientset/typed/direct.csi.min.io/v1beta1/fake/fake_direct.csi.min.io_client.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package fake 20 | 21 | import ( 22 | v1beta1 "github.com/minio/directpv/pkg/legacy/clientset/typed/direct.csi.min.io/v1beta1" 23 | rest "k8s.io/client-go/rest" 24 | testing "k8s.io/client-go/testing" 25 | ) 26 | 27 | type FakeDirectV1beta1 struct { 28 | *testing.Fake 29 | } 30 | 31 | func (c *FakeDirectV1beta1) DirectCSIDrives() v1beta1.DirectCSIDriveInterface { 32 | return &FakeDirectCSIDrives{c} 33 | } 34 | 35 | func (c *FakeDirectV1beta1) DirectCSIVolumes() v1beta1.DirectCSIVolumeInterface { 36 | return &FakeDirectCSIVolumes{c} 37 | } 38 | 39 | // RESTClient returns a RESTClient that is used to communicate 40 | // with API server by this client implementation. 41 | func (c *FakeDirectV1beta1) RESTClient() rest.Interface { 42 | var ret *rest.RESTClient 43 | return ret 44 | } 45 | -------------------------------------------------------------------------------- /pkg/legacy/clientset/typed/direct.csi.min.io/v1beta1/generated_expansion.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package v1beta1 20 | 21 | type DirectCSIDriveExpansion interface{} 22 | 23 | type DirectCSIVolumeExpansion interface{} 24 | -------------------------------------------------------------------------------- /pkg/legacy/clientset/typed/direct.csi.min.io/v1beta2/doc.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated typed clients. 20 | package v1beta2 21 | -------------------------------------------------------------------------------- /pkg/legacy/clientset/typed/direct.csi.min.io/v1beta2/fake/doc.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // Package fake has the automatically generated clients. 20 | package fake 21 | -------------------------------------------------------------------------------- /pkg/legacy/clientset/typed/direct.csi.min.io/v1beta2/fake/fake_direct.csi.min.io_client.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package fake 20 | 21 | import ( 22 | v1beta2 "github.com/minio/directpv/pkg/legacy/clientset/typed/direct.csi.min.io/v1beta2" 23 | rest "k8s.io/client-go/rest" 24 | testing "k8s.io/client-go/testing" 25 | ) 26 | 27 | type FakeDirectV1beta2 struct { 28 | *testing.Fake 29 | } 30 | 31 | func (c *FakeDirectV1beta2) DirectCSIDrives() v1beta2.DirectCSIDriveInterface { 32 | return &FakeDirectCSIDrives{c} 33 | } 34 | 35 | func (c *FakeDirectV1beta2) DirectCSIVolumes() v1beta2.DirectCSIVolumeInterface { 36 | return &FakeDirectCSIVolumes{c} 37 | } 38 | 39 | // RESTClient returns a RESTClient that is used to communicate 40 | // with API server by this client implementation. 41 | func (c *FakeDirectV1beta2) RESTClient() rest.Interface { 42 | var ret *rest.RESTClient 43 | return ret 44 | } 45 | -------------------------------------------------------------------------------- /pkg/legacy/clientset/typed/direct.csi.min.io/v1beta2/generated_expansion.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package v1beta2 20 | 21 | type DirectCSIDriveExpansion interface{} 22 | 23 | type DirectCSIVolumeExpansion interface{} 24 | -------------------------------------------------------------------------------- /pkg/legacy/clientset/typed/direct.csi.min.io/v1beta3/doc.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated typed clients. 20 | package v1beta3 21 | -------------------------------------------------------------------------------- /pkg/legacy/clientset/typed/direct.csi.min.io/v1beta3/fake/doc.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // Package fake has the automatically generated clients. 20 | package fake 21 | -------------------------------------------------------------------------------- /pkg/legacy/clientset/typed/direct.csi.min.io/v1beta3/fake/fake_direct.csi.min.io_client.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package fake 20 | 21 | import ( 22 | v1beta3 "github.com/minio/directpv/pkg/legacy/clientset/typed/direct.csi.min.io/v1beta3" 23 | rest "k8s.io/client-go/rest" 24 | testing "k8s.io/client-go/testing" 25 | ) 26 | 27 | type FakeDirectV1beta3 struct { 28 | *testing.Fake 29 | } 30 | 31 | func (c *FakeDirectV1beta3) DirectCSIDrives() v1beta3.DirectCSIDriveInterface { 32 | return &FakeDirectCSIDrives{c} 33 | } 34 | 35 | func (c *FakeDirectV1beta3) DirectCSIVolumes() v1beta3.DirectCSIVolumeInterface { 36 | return &FakeDirectCSIVolumes{c} 37 | } 38 | 39 | // RESTClient returns a RESTClient that is used to communicate 40 | // with API server by this client implementation. 41 | func (c *FakeDirectV1beta3) RESTClient() rest.Interface { 42 | var ret *rest.RESTClient 43 | return ret 44 | } 45 | -------------------------------------------------------------------------------- /pkg/legacy/clientset/typed/direct.csi.min.io/v1beta3/generated_expansion.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package v1beta3 20 | 21 | type DirectCSIDriveExpansion interface{} 22 | 23 | type DirectCSIVolumeExpansion interface{} 24 | -------------------------------------------------------------------------------- /pkg/legacy/clientset/typed/direct.csi.min.io/v1beta4/doc.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated typed clients. 20 | package v1beta4 21 | -------------------------------------------------------------------------------- /pkg/legacy/clientset/typed/direct.csi.min.io/v1beta4/fake/doc.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // Package fake has the automatically generated clients. 20 | package fake 21 | -------------------------------------------------------------------------------- /pkg/legacy/clientset/typed/direct.csi.min.io/v1beta4/fake/fake_direct.csi.min.io_client.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package fake 20 | 21 | import ( 22 | v1beta4 "github.com/minio/directpv/pkg/legacy/clientset/typed/direct.csi.min.io/v1beta4" 23 | rest "k8s.io/client-go/rest" 24 | testing "k8s.io/client-go/testing" 25 | ) 26 | 27 | type FakeDirectV1beta4 struct { 28 | *testing.Fake 29 | } 30 | 31 | func (c *FakeDirectV1beta4) DirectCSIDrives() v1beta4.DirectCSIDriveInterface { 32 | return &FakeDirectCSIDrives{c} 33 | } 34 | 35 | func (c *FakeDirectV1beta4) DirectCSIVolumes() v1beta4.DirectCSIVolumeInterface { 36 | return &FakeDirectCSIVolumes{c} 37 | } 38 | 39 | // RESTClient returns a RESTClient that is used to communicate 40 | // with API server by this client implementation. 41 | func (c *FakeDirectV1beta4) RESTClient() rest.Interface { 42 | var ret *rest.RESTClient 43 | return ret 44 | } 45 | -------------------------------------------------------------------------------- /pkg/legacy/clientset/typed/direct.csi.min.io/v1beta4/generated_expansion.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package v1beta4 20 | 21 | type DirectCSIDriveExpansion interface{} 22 | 23 | type DirectCSIVolumeExpansion interface{} 24 | -------------------------------------------------------------------------------- /pkg/legacy/clientset/typed/direct.csi.min.io/v1beta5/doc.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // This package has the automatically generated typed clients. 20 | package v1beta5 21 | -------------------------------------------------------------------------------- /pkg/legacy/clientset/typed/direct.csi.min.io/v1beta5/fake/doc.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | // Package fake has the automatically generated clients. 20 | package fake 21 | -------------------------------------------------------------------------------- /pkg/legacy/clientset/typed/direct.csi.min.io/v1beta5/fake/fake_direct.csi.min.io_client.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package fake 20 | 21 | import ( 22 | v1beta5 "github.com/minio/directpv/pkg/legacy/clientset/typed/direct.csi.min.io/v1beta5" 23 | rest "k8s.io/client-go/rest" 24 | testing "k8s.io/client-go/testing" 25 | ) 26 | 27 | type FakeDirectV1beta5 struct { 28 | *testing.Fake 29 | } 30 | 31 | func (c *FakeDirectV1beta5) DirectCSIDrives() v1beta5.DirectCSIDriveInterface { 32 | return &FakeDirectCSIDrives{c} 33 | } 34 | 35 | func (c *FakeDirectV1beta5) DirectCSIVolumes() v1beta5.DirectCSIVolumeInterface { 36 | return &FakeDirectCSIVolumes{c} 37 | } 38 | 39 | // RESTClient returns a RESTClient that is used to communicate 40 | // with API server by this client implementation. 41 | func (c *FakeDirectV1beta5) RESTClient() rest.Interface { 42 | var ret *rest.RESTClient 43 | return ret 44 | } 45 | -------------------------------------------------------------------------------- /pkg/legacy/clientset/typed/direct.csi.min.io/v1beta5/generated_expansion.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | // Code generated by client-gen. DO NOT EDIT. 18 | 19 | package v1beta5 20 | 21 | type DirectCSIDriveExpansion interface{} 22 | 23 | type DirectCSIVolumeExpansion interface{} 24 | -------------------------------------------------------------------------------- /pkg/legacy/converter/framework.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package converter 18 | 19 | const ( 20 | versionV1Alpha1 = "direct.csi.min.io/v1alpha1" 21 | versionV1Beta1 = "direct.csi.min.io/v1beta1" 22 | versionV1Beta2 = "direct.csi.min.io/v1beta2" 23 | versionV1Beta3 = "direct.csi.min.io/v1beta3" 24 | versionV1Beta4 = "direct.csi.min.io/v1beta4" 25 | versionV1Beta5 = "direct.csi.min.io/v1beta5" 26 | ) 27 | 28 | var supportedVersions = []string{ 29 | versionV1Alpha1, 30 | versionV1Beta1, 31 | versionV1Beta2, 32 | versionV1Beta3, 33 | versionV1Beta4, 34 | versionV1Beta5, 35 | } // ordered 36 | 37 | type crdKind string 38 | 39 | const ( 40 | driveCRDKind crdKind = "DirectCSIDrive" 41 | volumeCRDKind crdKind = "DirectCSIVolume" 42 | ) 43 | -------------------------------------------------------------------------------- /pkg/legacy/converter/sys.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package converter 18 | 19 | import "github.com/minio/directpv/pkg/consts" 20 | 21 | const ( 22 | // HostDevRoot is "/dev" directory. 23 | HostDevRoot = "/dev" 24 | 25 | // DirectCSIDevRoot is "/var/lib/direct-csi/devices" directory. 26 | DirectCSIDevRoot = consts.LegacyAppRootDir + "/devices" 27 | 28 | // DirectCSIPartitionInfix is partition infix value. 29 | DirectCSIPartitionInfix = "-part-" 30 | 31 | // HostPartitionInfix is host infix value. 32 | HostPartitionInfix = "p" 33 | ) 34 | -------------------------------------------------------------------------------- /pkg/metrics/metrics.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package metrics 18 | 19 | import ( 20 | "context" 21 | "fmt" 22 | "net" 23 | "net/http" 24 | 25 | directpvtypes "github.com/minio/directpv/pkg/apis/directpv.min.io/types" 26 | "github.com/prometheus/client_golang/prometheus" 27 | "github.com/prometheus/client_golang/prometheus/promhttp" 28 | "k8s.io/klog/v2" 29 | ) 30 | 31 | func metricsHandler(nodeID directpvtypes.NodeID) http.Handler { 32 | mc := newMetricsCollector(nodeID) 33 | prometheus.MustRegister(mc) 34 | 35 | registry := prometheus.NewRegistry() 36 | if err := registry.Register(mc); err != nil { 37 | panic(err) 38 | } 39 | 40 | gatherers := prometheus.Gatherers{ 41 | registry, 42 | } 43 | 44 | return promhttp.InstrumentMetricHandler( 45 | registry, 46 | promhttp.HandlerFor(gatherers, 47 | promhttp.HandlerOpts{ 48 | ErrorHandling: promhttp.ContinueOnError, 49 | }), 50 | ) 51 | } 52 | 53 | // ServeMetrics starts metrics service. 54 | func ServeMetrics(ctx context.Context, nodeID directpvtypes.NodeID, port int) { 55 | config := net.ListenConfig{} 56 | listener, err := config.Listen(ctx, "tcp", fmt.Sprintf(":%v", port)) 57 | if err != nil { 58 | panic(err) 59 | } 60 | 61 | server := &http.Server{Handler: metricsHandler(nodeID)} 62 | 63 | klog.V(2).Infof("Starting metrics exporter at port %v", port) 64 | if err := server.Serve(listener); err != nil { 65 | klog.ErrorS(err, "unable to start metrics server") 66 | if err != http.ErrServerClosed { 67 | panic(err) 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /pkg/node/sync.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package node 18 | 19 | import ( 20 | "context" 21 | 22 | directpvtypes "github.com/minio/directpv/pkg/apis/directpv.min.io/types" 23 | "github.com/minio/directpv/pkg/client" 24 | "github.com/minio/directpv/pkg/device" 25 | "github.com/minio/directpv/pkg/types" 26 | apierrors "k8s.io/apimachinery/pkg/api/errors" 27 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 28 | "k8s.io/client-go/util/retry" 29 | ) 30 | 31 | func probeDevices(nodeID directpvtypes.NodeID) ([]types.Device, error) { 32 | devices, err := device.Probe() 33 | if err != nil { 34 | return nil, err 35 | } 36 | var nodeDevices []types.Device 37 | for i := range devices { 38 | nodeDevices = append(nodeDevices, devices[i].ToNodeDevice(nodeID)) 39 | } 40 | return nodeDevices, nil 41 | } 42 | 43 | // Sync probes the local devices and syncs the DirectPVNode CRD objects with the probed information. 44 | func Sync(ctx context.Context, nodeID directpvtypes.NodeID) error { 45 | devices, err := probeDevices(nodeID) 46 | if err != nil { 47 | return err 48 | } 49 | updateFunc := func() error { 50 | nodeClient := client.NodeClient() 51 | node, err := nodeClient.Get(ctx, string(nodeID), metav1.GetOptions{}) 52 | if err != nil { 53 | if !apierrors.IsNotFound(err) { 54 | return err 55 | } 56 | _, err = nodeClient.Create(ctx, types.NewNode(nodeID, devices), metav1.CreateOptions{}) 57 | return err 58 | } 59 | node.Status.Devices = devices 60 | node.Spec.Refresh = false 61 | if _, err := nodeClient.Update(ctx, node, metav1.UpdateOptions{TypeMeta: types.NewNodeTypeMeta()}); err != nil { 62 | return err 63 | } 64 | return nil 65 | } 66 | 67 | return retry.RetryOnConflict(retry.DefaultRetry, updateFunc) 68 | } 69 | -------------------------------------------------------------------------------- /pkg/sys/fake.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2025 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package sys 18 | 19 | // FakeMountInfo creates mount information with tesing mount entries 20 | func FakeMountInfo(mountEntries ...MountEntry) *MountInfo { 21 | infoMap := map[uint64]*MountEntry{} 22 | mountPointMap := map[string][]uint64{} 23 | mountSourceMap := map[string][]uint64{} 24 | majorMinorMap := map[string][]uint64{} 25 | rootMap := map[string][]uint64{} 26 | 27 | for i, mountEntry := range mountEntries { 28 | xxHash := uint64(i) 29 | infoMap[xxHash] = &mountEntry 30 | mountPointMap[mountEntry.MountPoint] = append(mountPointMap[mountEntry.MountPoint], xxHash) 31 | mountSourceMap[mountEntry.MountSource] = append(mountSourceMap[mountEntry.MountSource], xxHash) 32 | majorMinorMap[mountEntry.MajorMinor] = append(majorMinorMap[mountEntry.MajorMinor], xxHash) 33 | rootMap[mountEntry.Root] = append(rootMap[mountEntry.Root], xxHash) 34 | } 35 | 36 | return &MountInfo{ 37 | infoMap: infoMap, 38 | mountPointMap: mountPointMap, 39 | mountSourceMap: mountSourceMap, 40 | majorMinorMap: majorMinorMap, 41 | rootMap: rootMap, 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /pkg/sys/mkdir.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package sys 18 | 19 | import ( 20 | "errors" 21 | "os" 22 | "path" 23 | ) 24 | 25 | // Mkdir is a util to mkdir with some special error handling 26 | func Mkdir(name string, perm os.FileMode) (err error) { 27 | if err = os.Mkdir(name, perm); err != nil && errors.Is(err, os.ErrExist) { 28 | // If the device has Input/Output error, mkdir fails with "file exists" (https://github.com/golang/go/issues/8283) 29 | // Doing a Stat to confirm if we see I/O errors on the drive 30 | if _, err = os.Stat(path.Dir(name)); err == nil { 31 | return os.ErrExist 32 | } 33 | } 34 | return err 35 | } 36 | -------------------------------------------------------------------------------- /pkg/sys/mount_other.go: -------------------------------------------------------------------------------- 1 | //go:build !linux 2 | 3 | // This file is part of MinIO DirectPV 4 | // Copyright (c) 2021, 2022 MinIO, Inc. 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU Affero General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU Affero General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU Affero General Public License 17 | // along with this program. If not, see . 18 | 19 | package sys 20 | 21 | import ( 22 | "fmt" 23 | "runtime" 24 | ) 25 | 26 | func newMountInfo() (*MountInfo, error) { 27 | return nil, fmt.Errorf("unsupported operating system %v", runtime.GOOS) 28 | } 29 | 30 | func mount(device, target, fsType string, flags []string, superBlockFlags string) error { 31 | return fmt.Errorf("unsupported operating system %v", runtime.GOOS) 32 | } 33 | 34 | func unmount(target string, force, detach, expire bool) error { 35 | return fmt.Errorf("unsupported operating system %v", runtime.GOOS) 36 | } 37 | 38 | func bindMount(source, target, fsType string, recursive, readOnly bool, superBlockFlags string) error { 39 | return fmt.Errorf("unsupported operating system %v", runtime.GOOS) 40 | } 41 | -------------------------------------------------------------------------------- /pkg/types/fake.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package types 18 | 19 | import "github.com/minio/directpv/pkg/clientset/fake" 20 | 21 | // ExtFakeClientset denotes extended fake clientset. 22 | type ExtFakeClientset struct { 23 | *fake.Clientset 24 | } 25 | 26 | // NewExtFakeClientset creates new extended fake clientset. 27 | func NewExtFakeClientset(cs *fake.Clientset) *ExtFakeClientset { 28 | return &ExtFakeClientset{cs} 29 | } 30 | -------------------------------------------------------------------------------- /pkg/xfs/empty.testdata: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minio/directpv/1fb86efd610ab2f8b56ae7f29787bdc2e5776619/pkg/xfs/empty.testdata -------------------------------------------------------------------------------- /pkg/xfs/mkfs.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package xfs 18 | 19 | import ( 20 | "context" 21 | 22 | "github.com/minio/directpv/pkg/consts" 23 | ) 24 | 25 | // FSLabel is filesystem label. 26 | const FSLabel = consts.AppCapsName 27 | 28 | // MakeFS is a utility function to format a device 29 | func MakeFS(ctx context.Context, device, uuid string, force, reflink bool) (fsuuid, label string, totalCapacity, freeCapacity uint64, err error) { 30 | return makeFS(ctx, device, uuid, force, reflink) 31 | } 32 | -------------------------------------------------------------------------------- /pkg/xfs/mkfs_linux.go: -------------------------------------------------------------------------------- 1 | //go:build linux 2 | 3 | // This file is part of MinIO DirectPV 4 | // Copyright (c) 2021, 2022 MinIO, Inc. 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU Affero General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU Affero General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU Affero General Public License 17 | // along with this program. If not, see . 18 | 19 | package xfs 20 | 21 | import ( 22 | "context" 23 | "fmt" 24 | "os/exec" 25 | ) 26 | 27 | func makeFS(ctx context.Context, device, uuid string, force, reflink bool) (fsuuid, label string, totalCapacity, freeCapacity uint64, err error) { 28 | args := []string{"-i", "maxpct=50", "-m", fmt.Sprintf("uuid=%v", uuid)} 29 | if !reflink { 30 | args = append(args, "-m", "reflink=0") 31 | } 32 | if force { 33 | args = append(args, "-f") 34 | } 35 | args = append(args, "-L", FSLabel, device) 36 | 37 | var output []byte 38 | if output, err = exec.CommandContext(ctx, "mkfs.xfs", args...).CombinedOutput(); err != nil { 39 | err = fmt.Errorf( 40 | "unable to execute command %v; output=%v; error=%w", 41 | append([]string{"mkfs.xfs"}, args...), string(output), err, 42 | ) 43 | return 44 | } 45 | 46 | return probe(device) 47 | } 48 | -------------------------------------------------------------------------------- /pkg/xfs/mkfs_other.go: -------------------------------------------------------------------------------- 1 | //go:build !linux 2 | 3 | // This file is part of MinIO DirectPV 4 | // Copyright (c) 2021, 2022 MinIO, Inc. 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU Affero General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU Affero General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU Affero General Public License 17 | // along with this program. If not, see . 18 | 19 | package xfs 20 | 21 | import ( 22 | "context" 23 | "fmt" 24 | "runtime" 25 | ) 26 | 27 | func makeFS(ctx context.Context, device, uuid string, force, reflink bool) (fsuuid, label string, totalCapacity, freeCapacity uint64, err error) { 28 | err = fmt.Errorf("unsupported operating system %v", runtime.GOOS) 29 | return 30 | } 31 | -------------------------------------------------------------------------------- /pkg/xfs/mount.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package xfs 18 | 19 | // Mount mounts device to target. 20 | func Mount(device, target string) error { 21 | return mount(device, target) 22 | } 23 | 24 | // BindMount bind-mounts source to target. 25 | func BindMount(source, target string, readOnly bool) error { 26 | return bindMount(source, target, readOnly) 27 | } 28 | -------------------------------------------------------------------------------- /pkg/xfs/mount_linux.go: -------------------------------------------------------------------------------- 1 | //go:build linux 2 | 3 | // This file is part of MinIO DirectPV 4 | // Copyright (c) 2021, 2022 MinIO, Inc. 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU Affero General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU Affero General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU Affero General Public License 17 | // along with this program. If not, see . 18 | 19 | package xfs 20 | 21 | import ( 22 | "errors" 23 | "os" 24 | "path" 25 | 26 | "github.com/minio/directpv/pkg/sys" 27 | "k8s.io/klog/v2" 28 | ) 29 | 30 | func mount(device, target string) error { 31 | if err := sys.Mkdir(target, 0o777); err != nil && !errors.Is(err, os.ErrExist) { 32 | return err 33 | } 34 | 35 | if err := sys.Mount(device, target, "xfs", []string{"noatime"}, "prjquota"); err != nil { 36 | return err 37 | } 38 | 39 | name := path.Base(device) 40 | if name == "/" || name == "." { 41 | klog.Errorf("unable to get device name from device %v", device) 42 | return nil 43 | } 44 | 45 | if err := os.WriteFile("/sys/fs/xfs/"+name+"/error/metadata/EIO/max_retries", []byte("0"), 0o644); err != nil { 46 | klog.ErrorS(err, "unable to set EIO max_retries device", "name", name) 47 | } 48 | 49 | if err := os.WriteFile("/sys/fs/xfs/"+name+"/error/metadata/ENOSPC/max_retries", []byte("0"), 0o644); err != nil { 50 | klog.ErrorS(err, "unable to set ENOSPC max_retries device", "name", name) 51 | } 52 | 53 | if err := os.WriteFile("/sys/fs/xfs/"+name+"/error/metadata/default/max_retries", []byte("0"), 0o644); err != nil { 54 | klog.ErrorS(err, "unable to set default max_retries device", "name", name) 55 | } 56 | 57 | return nil 58 | } 59 | 60 | func bindMount(source, target string, readOnly bool) error { 61 | return sys.BindMount(source, target, "xfs", false, readOnly, "prjquota") 62 | } 63 | -------------------------------------------------------------------------------- /pkg/xfs/mount_other.go: -------------------------------------------------------------------------------- 1 | //go:build !linux 2 | 3 | // This file is part of MinIO DirectPV 4 | // Copyright (c) 2021, 2022 MinIO, Inc. 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU Affero General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU Affero General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU Affero General Public License 17 | // along with this program. If not, see . 18 | 19 | package xfs 20 | 21 | import ( 22 | "fmt" 23 | "runtime" 24 | ) 25 | 26 | func mount(device, target string) error { 27 | return fmt.Errorf("unsupported operating system %v", runtime.GOOS) 28 | } 29 | 30 | func bindMount(source, target string, readOnly bool) error { 31 | return fmt.Errorf("unsupported operating system %v", runtime.GOOS) 32 | } 33 | -------------------------------------------------------------------------------- /pkg/xfs/probe.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package xfs 18 | 19 | import "errors" 20 | 21 | // MinSupportedDeviceSize is minimum supported size for default XFS filesystem. 22 | const MinSupportedDeviceSize = 16 * 1024 * 1024 // 16 MiB 23 | 24 | // ErrFSNotFound denotes filesystem not found error. 25 | var ErrFSNotFound = errors.New("filesystem not found") 26 | 27 | // Probe probes XFS filesystem on device. 28 | func Probe(device string) (fsuuid, label string, totalCapacity, freeCapacity uint64, err error) { 29 | return probe(device) 30 | } 31 | -------------------------------------------------------------------------------- /pkg/xfs/probe_other.go: -------------------------------------------------------------------------------- 1 | //go:build !linux 2 | 3 | // This file is part of MinIO DirectPV 4 | // Copyright (c) 2021, 2022 MinIO, Inc. 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU Affero General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU Affero General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU Affero General Public License 17 | // along with this program. If not, see . 18 | 19 | package xfs 20 | 21 | import ( 22 | "fmt" 23 | "runtime" 24 | ) 25 | 26 | func probe(path string) (fsuuid, label string, totalCapacity, freeCapacity uint64, err error) { 27 | err = fmt.Errorf("unsupported operating system %v", runtime.GOOS) 28 | return 29 | } 30 | -------------------------------------------------------------------------------- /pkg/xfs/quota.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2021, 2022 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package xfs 18 | 19 | import ( 20 | "context" 21 | "errors" 22 | "fmt" 23 | ) 24 | 25 | // ErrCanceled denotes canceled by context error. 26 | var ErrCanceled = errors.New("canceled by context") 27 | 28 | // Quota denotes XFS quota information. 29 | type Quota struct { 30 | HardLimit uint64 31 | SoftLimit uint64 32 | CurrentSpace uint64 33 | } 34 | 35 | // GetQuota returns XFS quota information of given volume ID. 36 | func GetQuota(ctx context.Context, device, volumeID string) (quota *Quota, err error) { 37 | doneCh := make(chan struct{}) 38 | go func() { 39 | quota, err = getQuota(device, volumeID) 40 | close(doneCh) 41 | }() 42 | 43 | select { 44 | case <-ctx.Done(): 45 | return nil, fmt.Errorf("%w; %v", ErrCanceled, ctx.Err()) 46 | case <-doneCh: 47 | } 48 | 49 | return quota, err 50 | } 51 | 52 | // SetQuota sets quota information on given path and volume ID. 53 | func SetQuota(ctx context.Context, device, path, volumeID string, quota Quota, update bool) (err error) { 54 | doneCh := make(chan struct{}) 55 | go func() { 56 | err = setQuota(device, path, volumeID, quota, update) 57 | close(doneCh) 58 | }() 59 | 60 | select { 61 | case <-ctx.Done(): 62 | return fmt.Errorf("%w; %v", ErrCanceled, ctx.Err()) 63 | case <-doneCh: 64 | } 65 | 66 | return err 67 | } 68 | -------------------------------------------------------------------------------- /pkg/xfs/quota_other.go: -------------------------------------------------------------------------------- 1 | //go:build !linux 2 | 3 | // This file is part of MinIO DirectPV 4 | // Copyright (c) 2021, 2022 MinIO, Inc. 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU Affero General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU Affero General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU Affero General Public License 17 | // along with this program. If not, see . 18 | 19 | package xfs 20 | 21 | import ( 22 | "fmt" 23 | "runtime" 24 | ) 25 | 26 | func getQuota(device, volumeID string) (*Quota, error) { 27 | return nil, fmt.Errorf("unsupported operating system %v", runtime.GOOS) 28 | } 29 | 30 | func setQuota(device, path, volumeID string, quota Quota, update bool) error { 31 | return fmt.Errorf("unsupported operating system %v", runtime.GOOS) 32 | } 33 | -------------------------------------------------------------------------------- /pkg/xfs/repair.go: -------------------------------------------------------------------------------- 1 | // This file is part of MinIO DirectPV 2 | // Copyright (c) 2024 MinIO, Inc. 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | package xfs 18 | 19 | import ( 20 | "context" 21 | "io" 22 | ) 23 | 24 | // Repair is a utility function to repair XFS on a device 25 | func Repair(ctx context.Context, device string, force, disablePrefetch, dryRun bool, output io.Writer) error { 26 | return repair(ctx, device, force, disablePrefetch, dryRun, output) 27 | } 28 | -------------------------------------------------------------------------------- /pkg/xfs/repair_linux.go: -------------------------------------------------------------------------------- 1 | //go:build linux 2 | 3 | // This file is part of MinIO DirectPV 4 | // Copyright (c) 2024 MinIO, Inc. 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU Affero General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU Affero General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU Affero General Public License 17 | // along with this program. If not, see . 18 | 19 | package xfs 20 | 21 | import ( 22 | "context" 23 | "fmt" 24 | "io" 25 | "os/exec" 26 | ) 27 | 28 | func repair(ctx context.Context, device string, force, disablePrefetch, dryRun bool, output io.Writer) error { 29 | args := []string{device, "-v"} 30 | if force { 31 | args = append(args, "-L") 32 | } 33 | if disablePrefetch { 34 | args = append(args, "-P") 35 | } 36 | if dryRun { 37 | args = append(args, "-n") 38 | } 39 | 40 | cmd := exec.CommandContext(ctx, "xfs_repair", args...) 41 | cmd.Stdout = output 42 | cmd.Stderr = output 43 | if err := cmd.Run(); err != nil { 44 | return fmt.Errorf("unable to run xfs_repair on device %v; %w", device, err) 45 | } 46 | 47 | return nil 48 | } 49 | -------------------------------------------------------------------------------- /pkg/xfs/repair_other.go: -------------------------------------------------------------------------------- 1 | //go:build !linux 2 | 3 | // This file is part of MinIO DirectPV 4 | // Copyright (c) 2024 MinIO, Inc. 5 | // 6 | // This program is free software: you can redistribute it and/or modify 7 | // it under the terms of the GNU Affero General Public License as published by 8 | // the Free Software Foundation, either version 3 of the License, or 9 | // (at your option) any later version. 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU Affero General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU Affero General Public License 17 | // along with this program. If not, see . 18 | 19 | package xfs 20 | 21 | import ( 22 | "context" 23 | "fmt" 24 | "io" 25 | "runtime" 26 | ) 27 | 28 | func repair(_ context.Context, _ string, _, _, _ bool, _ io.Writer) error { 29 | return fmt.Errorf("unsupported operating system %v", runtime.GOOS) 30 | } 31 | -------------------------------------------------------------------------------- /pkg/xfs/xfs.testdata: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/minio/directpv/1fb86efd610ab2f8b56ae7f29787bdc2e5776619/pkg/xfs/xfs.testdata -------------------------------------------------------------------------------- /pkg/xfs/zero.testdata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /resources/base/CSIDriver.yaml: -------------------------------------------------------------------------------- 1 | 2 | apiVersion: storage.k8s.io/v1 3 | kind: CSIDriver 4 | metadata: 5 | creationTimestamp: null 6 | labels: 7 | application-name: directpv.min.io 8 | application-type: CSIDriver 9 | directpv.min.io/created-by: kubectl-directpv 10 | directpv.min.io/version: v1beta1 11 | name: directpv-min-io 12 | spec: 13 | attachRequired: false 14 | podInfoOnMount: true 15 | volumeLifecycleModes: 16 | - Persistent 17 | - Ephemeral 18 | -------------------------------------------------------------------------------- /resources/base/ClusterRoleBinding.yaml: -------------------------------------------------------------------------------- 1 | 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | kind: ClusterRoleBinding 4 | metadata: 5 | annotations: 6 | rbac.authorization.kubernetes.io/autoupdate: "true" 7 | creationTimestamp: null 8 | labels: 9 | application-name: directpv.min.io 10 | application-type: CSIDriver 11 | directpv.min.io/created-by: kubectl-directpv 12 | directpv.min.io/version: v1beta1 13 | name: directpv-min-io 14 | roleRef: 15 | apiGroup: rbac.authorization.k8s.io 16 | kind: ClusterRole 17 | name: directpv-min-io 18 | subjects: 19 | - kind: ServiceAccount 20 | name: directpv-min-io 21 | namespace: directpv 22 | -------------------------------------------------------------------------------- /resources/base/Namespace.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | creationTimestamp: null 5 | finalizers: 6 | - foregroundDeletion 7 | labels: 8 | application-name: directpv.min.io 9 | application-type: CSIDriver 10 | directpv.min.io/created-by: kubectl-directpv 11 | directpv.min.io/version: v1beta1 12 | pod-security.kubernetes.io/enforce: privileged 13 | name: directpv 14 | spec: {} 15 | status: {} 16 | -------------------------------------------------------------------------------- /resources/base/Role.yaml: -------------------------------------------------------------------------------- 1 | 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | kind: Role 4 | metadata: 5 | annotations: 6 | rbac.authorization.kubernetes.io/autoupdate: "true" 7 | creationTimestamp: null 8 | labels: 9 | application-name: directpv.min.io 10 | application-type: CSIDriver 11 | directpv.min.io/created-by: kubectl-directpv 12 | directpv.min.io/version: v1beta1 13 | name: directpv-min-io 14 | namespace: directpv 15 | rules: 16 | - apiGroups: 17 | - coordination.k8s.io 18 | resources: 19 | - leases 20 | verbs: 21 | - create 22 | - delete 23 | - get 24 | - list 25 | - update 26 | - watch 27 | -------------------------------------------------------------------------------- /resources/base/RoleBinding.yaml: -------------------------------------------------------------------------------- 1 | 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | kind: RoleBinding 4 | metadata: 5 | annotations: 6 | rbac.authorization.kubernetes.io/autoupdate: "true" 7 | creationTimestamp: null 8 | labels: 9 | application-name: directpv.min.io 10 | application-type: CSIDriver 11 | directpv.min.io/created-by: kubectl-directpv 12 | directpv.min.io/version: v1beta1 13 | name: directpv-min-io 14 | namespace: directpv 15 | roleRef: 16 | apiGroup: rbac.authorization.k8s.io 17 | kind: Role 18 | name: directpv-min-io 19 | subjects: 20 | - kind: ServiceAccount 21 | name: directpv-min-io 22 | namespace: directpv 23 | -------------------------------------------------------------------------------- /resources/base/ServiceAccount.yaml: -------------------------------------------------------------------------------- 1 | 2 | apiVersion: v1 3 | kind: ServiceAccount 4 | metadata: 5 | creationTimestamp: null 6 | labels: 7 | application-name: directpv.min.io 8 | application-type: CSIDriver 9 | directpv.min.io/created-by: kubectl-directpv 10 | directpv.min.io/version: v1beta1 11 | name: directpv-min-io 12 | namespace: directpv 13 | -------------------------------------------------------------------------------- /resources/base/StorageClass.yaml: -------------------------------------------------------------------------------- 1 | 2 | allowVolumeExpansion: true 3 | allowedTopologies: 4 | - matchLabelExpressions: 5 | - key: directpv.min.io/identity 6 | values: 7 | - directpv-min-io 8 | apiVersion: storage.k8s.io/v1 9 | kind: StorageClass 10 | metadata: 11 | creationTimestamp: null 12 | finalizers: 13 | - foregroundDeletion 14 | labels: 15 | application-name: directpv.min.io 16 | application-type: CSIDriver 17 | directpv.min.io/created-by: kubectl-directpv 18 | directpv.min.io/version: v1beta1 19 | name: directpv-min-io 20 | parameters: 21 | csi.storage.k8s.io/fstype: xfs 22 | provisioner: directpv-min-io 23 | reclaimPolicy: Delete 24 | volumeBindingMode: WaitForFirstConsumer 25 | -------------------------------------------------------------------------------- /resources/base/kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - Namespace.yaml 6 | - directpvdrives.directpv.min.io.yaml 7 | - directpvinitrequests.directpv.min.io.yaml 8 | - directpvnodes.directpv.min.io.yaml 9 | - directpvvolumes.directpv.min.io.yaml 10 | - CSIDriver.yaml 11 | - StorageClass.yaml 12 | - ServiceAccount.yaml 13 | - ClusterRole.yaml 14 | - ClusterRoleBinding.yaml 15 | - Role.yaml 16 | - RoleBinding.yaml 17 | - DaemonSet.yaml 18 | - Deployment.yaml 19 | 20 | images: 21 | - name: quay.io/minio/directpv 22 | digest: sha256:83fd05fe114ed15c3975333c90cbe18c782d9c4d5c7ad6fdb8cc835e380ba505 23 | 24 | - name: quay.io/minio/csi-node-driver-registrar 25 | digest: sha256:dafc7f667aa2e20d7f059c20db02dd6987c2624d64d8f166cd5930721be98ea9 26 | 27 | - name: quay.io/minio/livenessprobe 28 | digest: sha256:783010e10e4d74b6b2b157a4b52772c5a264fd76bb2ad671054b8c3f706c8324 29 | 30 | - name: quay.io/minio/csi-provisioner 31 | digest: sha256:fc1f992dd5591357fa123c396aaadaea5033f312b9c136a11d62cf698474bebb 32 | 33 | - name: quay.io/minio/csi-resizer 34 | digest: sha256:58fa627393f20892b105a137d27e236dfaec233a3a64980f84dcb15f38c21533 35 | 36 | patches: 37 | - patch: |- 38 | - op: replace 39 | path: /metadata/annotations/directpv.min.io~1image-tag 40 | value: v4.1.4 41 | target: 42 | kind: Deployment 43 | name: controller 44 | - patch: |- 45 | - op: replace 46 | path: /metadata/annotations/directpv.min.io~1image-tag 47 | value: v4.1.4 48 | target: 49 | kind: DaemonSet 50 | name: node-server 51 | -------------------------------------------------------------------------------- /resources/legacy/CSIDriver.yaml: -------------------------------------------------------------------------------- 1 | 2 | apiVersion: storage.k8s.io/v1 3 | kind: CSIDriver 4 | metadata: 5 | creationTimestamp: null 6 | labels: 7 | application-name: directpv.min.io 8 | application-type: CSIDriver 9 | directpv.min.io/created-by: kubectl-directpv 10 | directpv.min.io/version: v1beta1 11 | name: direct-csi-min-io 12 | spec: 13 | attachRequired: false 14 | podInfoOnMount: true 15 | volumeLifecycleModes: 16 | - Persistent 17 | - Ephemeral 18 | -------------------------------------------------------------------------------- /resources/legacy/StorageClass.yaml: -------------------------------------------------------------------------------- 1 | 2 | allowVolumeExpansion: true 3 | allowedTopologies: 4 | - matchLabelExpressions: 5 | - key: directpv.min.io/identity 6 | values: 7 | - directpv-min-io 8 | apiVersion: storage.k8s.io/v1 9 | kind: StorageClass 10 | metadata: 11 | creationTimestamp: null 12 | finalizers: 13 | - foregroundDeletion 14 | labels: 15 | application-name: directpv.min.io 16 | application-type: CSIDriver 17 | directpv.min.io/created-by: kubectl-directpv 18 | directpv.min.io/version: v1beta1 19 | name: direct-csi-min-io 20 | parameters: 21 | csi.storage.k8s.io/fstype: xfs 22 | provisioner: directpv-min-io 23 | reclaimPolicy: Delete 24 | volumeBindingMode: WaitForFirstConsumer 25 | -------------------------------------------------------------------------------- /resources/legacy/kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - ../base 6 | - CSIDriver.yaml 7 | - DaemonSet.yaml 8 | - Deployment.yaml 9 | - StorageClass.yaml 10 | 11 | images: 12 | - name: quay.io/minio/directpv 13 | digest: sha256:83fd05fe114ed15c3975333c90cbe18c782d9c4d5c7ad6fdb8cc835e380ba505 14 | 15 | - name: quay.io/minio/csi-node-driver-registrar 16 | digest: sha256:dafc7f667aa2e20d7f059c20db02dd6987c2624d64d8f166cd5930721be98ea9 17 | 18 | - name: quay.io/minio/livenessprobe 19 | digest: sha256:783010e10e4d74b6b2b157a4b52772c5a264fd76bb2ad671054b8c3f706c8324 20 | 21 | - name: quay.io/minio/csi-provisioner 22 | digest: sha256:fc1f992dd5591357fa123c396aaadaea5033f312b9c136a11d62cf698474bebb 23 | 24 | - name: quay.io/minio/csi-resizer 25 | digest: sha256:58fa627393f20892b105a137d27e236dfaec233a3a64980f84dcb15f38c21533 26 | 27 | -------------------------------------------------------------------------------- /resources/openshift-with-legacy/kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - ../legacy 6 | 7 | images: 8 | - name: quay.io/minio/csi-node-driver-registrar 9 | newName: registry.redhat.io/openshift4/ose-csi-node-driver-registrar-rhel8 10 | digest: sha256:ab54e6a2e8a6a1ca2da5aaf25f784c09f5bf22ea32224ec1bdb6c564f88695a9 11 | 12 | - name: quay.io/minio/livenessprobe 13 | newName: registry.redhat.io/openshift4/ose-csi-livenessprobe-rhel8 14 | digest: sha256:b28029f929fe2a28e666910d1acc57c3474fabdb2f9129688ef1ca56c7231d90 15 | 16 | - name: quay.io/minio/csi-provisioner 17 | newName: registry.redhat.io/openshift4/ose-csi-external-provisioner-rhel8 18 | digest: sha256:8bf8aa8975790e19ba107fd58699f98389e3fb692d192f4df3078fff7f0a4bba 19 | 20 | - name: quay.io/minio/csi-resizer@sha256:58fa627393f20892b105a137d27e236dfaec233a3a64980f84dcb15f38c21533 21 | newName: registry.redhat.io/openshift4/ose-csi-external-resizer-rhel8 22 | digest: sha256:bed8de36bac80108909205342b2d92e4de5adbfa33bf13f9346236fca52a0d3e 23 | -------------------------------------------------------------------------------- /resources/openshift/kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - ../base 6 | 7 | images: 8 | - name: quay.io/minio/csi-node-driver-registrar 9 | newName: registry.redhat.io/openshift4/ose-csi-node-driver-registrar-rhel8 10 | digest: sha256:ab54e6a2e8a6a1ca2da5aaf25f784c09f5bf22ea32224ec1bdb6c564f88695a9 11 | 12 | - name: quay.io/minio/livenessprobe 13 | newName: registry.redhat.io/openshift4/ose-csi-livenessprobe-rhel8 14 | digest: sha256:b28029f929fe2a28e666910d1acc57c3474fabdb2f9129688ef1ca56c7231d90 15 | 16 | - name: quay.io/minio/csi-provisioner 17 | newName: registry.redhat.io/openshift4/ose-csi-external-provisioner-rhel8 18 | digest: sha256:8bf8aa8975790e19ba107fd58699f98389e3fb692d192f4df3078fff7f0a4bba 19 | 20 | - name: quay.io/minio/csi-resizer@sha256:58fa627393f20892b105a137d27e236dfaec233a3a64980f84dcb15f38c21533 21 | newName: registry.redhat.io/openshift4/ose-csi-external-resizer-rhel8 22 | digest: sha256:bed8de36bac80108909205342b2d92e4de5adbfa33bf13f9346236fca52a0d3e 23 | -------------------------------------------------------------------------------- /resources/v4.0/base/kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - ../../base 6 | - ../psp 7 | 8 | images: 9 | - name: quay.io/minio/directpv 10 | digest: sha256:98c23183f3abb8d9b6e0c300677605cc822e039fc81ce0e5dd8bef1006547627 11 | 12 | patches: 13 | - patch: |- 14 | - op: replace 15 | path: /metadata/annotations/directpv.min.io~1image-tag 16 | value: v4.0.16 17 | target: 18 | kind: Deployment 19 | name: controller 20 | - patch: |- 21 | - op: replace 22 | path: /metadata/annotations/directpv.min.io~1image-tag 23 | value: v4.0.16 24 | target: 25 | kind: DaemonSet 26 | name: node-server 27 | -------------------------------------------------------------------------------- /resources/v4.0/legacy/kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - ../../legacy 6 | - ../psp 7 | 8 | images: 9 | - name: quay.io/minio/directpv 10 | digest: sha256:98c23183f3abb8d9b6e0c300677605cc822e039fc81ce0e5dd8bef1006547627 11 | -------------------------------------------------------------------------------- /resources/v4.0/openshift-with-legacy/kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - ../../openshift-with-legacy 6 | - ../psp 7 | 8 | images: 9 | - name: quay.io/minio/directpv 10 | digest: sha256:98c23183f3abb8d9b6e0c300677605cc822e039fc81ce0e5dd8bef1006547627 11 | -------------------------------------------------------------------------------- /resources/v4.0/openshift/kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - ../../openshift 6 | - ../psp 7 | 8 | images: 9 | - name: quay.io/minio/directpv 10 | digest: sha256:98c23183f3abb8d9b6e0c300677605cc822e039fc81ce0e5dd8bef1006547627 11 | -------------------------------------------------------------------------------- /resources/v4.0/psp/PodSecurityPolicy-ClusterRoleBinding.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: ClusterRoleBinding 3 | metadata: 4 | creationTimestamp: null 5 | labels: 6 | application-name: directpv.min.io 7 | application-type: CSIDriver 8 | directpv.min.io/created-by: kubectl-directpv 9 | directpv.min.io/version: v1beta1 10 | name: psp-directpv-min-io 11 | roleRef: 12 | apiGroup: rbac.authorization.k8s.io 13 | kind: ClusterRole 14 | name: directpv-min-io 15 | subjects: 16 | - apiGroup: rbac.authorization.k8s.io 17 | kind: Group 18 | name: system:serviceaccounts:directpv-min-io 19 | -------------------------------------------------------------------------------- /resources/v4.0/psp/PodSecurityPolicy.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: policy/v1beta1 2 | kind: PodSecurityPolicy 3 | metadata: 4 | creationTimestamp: null 5 | labels: 6 | application-name: directpv.min.io 7 | application-type: CSIDriver 8 | directpv.min.io/created-by: kubectl-directpv 9 | directpv.min.io/version: v1beta1 10 | name: directpv-min-io 11 | spec: 12 | allowedCapabilities: 13 | - '*' 14 | allowedHostPaths: 15 | - pathPrefix: /proc 16 | readOnly: true 17 | - pathPrefix: /sys 18 | - pathPrefix: /run/udev/data 19 | readOnly: true 20 | - pathPrefix: /var/lib/directpv 21 | - pathPrefix: /csi 22 | - pathPrefix: /var/lib/kubelet 23 | fsGroup: 24 | rule: RunAsAny 25 | hostPID: true 26 | privileged: true 27 | runAsUser: 28 | rule: RunAsAny 29 | seLinux: 30 | rule: RunAsAny 31 | supplementalGroups: 32 | rule: RunAsAny 33 | volumes: 34 | - hostPath 35 | -------------------------------------------------------------------------------- /resources/v4.0/psp/kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - PodSecurityPolicy.yaml 6 | - PodSecurityPolicy-ClusterRoleBinding.yaml 7 | -------------------------------------------------------------------------------- /sidecars/release-csi-external-health-monitor-controller.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # This file is part of MinIO DirectPV 3 | # Copyright (c) 2024 MinIO, Inc. 4 | # 5 | # This program is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU Affero General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU Affero General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Affero General Public License 16 | # along with this program. If not, see . 17 | 18 | ME=$(basename "$0"); export ME 19 | cd "$(dirname "$0")" || exit 255 20 | 21 | export GITHUB_PROJECT_NAME=external-health-monitor 22 | export PROJECT_NAME=csi-external-health-monitor-controller 23 | export PROJECT_DESCRIPTION="CSI External Health Monitor Controller" 24 | 25 | if [ "$#" -ne 1 ]; then 26 | cat < 29 | EXAMPLES: 30 | # Release ${PROJECT_NAME} v0.13.0 31 | $ ${ME} v0.13.0 32 | EOF 33 | exit 255 34 | fi 35 | 36 | # shellcheck source=/dev/null 37 | source release.sh 38 | release "$1" 39 | -------------------------------------------------------------------------------- /sidecars/release-csi-provisioner.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # This file is part of MinIO DirectPV 3 | # Copyright (c) 2024 MinIO, Inc. 4 | # 5 | # This program is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU Affero General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU Affero General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Affero General Public License 16 | # along with this program. If not, see . 17 | 18 | ME=$(basename "$0"); export ME 19 | cd "$(dirname "$0")" || exit 255 20 | 21 | export GITHUB_PROJECT_NAME=external-provisioner 22 | export PROJECT_NAME=csi-provisioner 23 | export PROJECT_DESCRIPTION="CSI External Provisioner" 24 | 25 | if [ "$#" -ne 1 ]; then 26 | cat < 29 | EXAMPLES: 30 | # Release ${PROJECT_NAME} v5.0.2 31 | $ ${ME} v5.0.2 32 | EOF 33 | exit 255 34 | fi 35 | 36 | # shellcheck source=/dev/null 37 | source release.sh 38 | release "$1" 39 | -------------------------------------------------------------------------------- /sidecars/release-csi-resizer.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # This file is part of MinIO DirectPV 3 | # Copyright (c) 2024 MinIO, Inc. 4 | # 5 | # This program is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU Affero General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU Affero General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Affero General Public License 16 | # along with this program. If not, see . 17 | 18 | ME=$(basename "$0"); export ME 19 | cd "$(dirname "$0")" || exit 255 20 | 21 | export GITHUB_PROJECT_NAME=external-resizer 22 | export PROJECT_NAME=csi-resizer 23 | export PROJECT_DESCRIPTION="CSI External Resizer" 24 | 25 | if [ "$#" -ne 1 ]; then 26 | cat < 29 | EXAMPLES: 30 | # Release ${PROJECT_NAME} v1.22.0 31 | $ ${ME} v1.22.0 32 | EOF 33 | exit 255 34 | fi 35 | 36 | # shellcheck source=/dev/null 37 | source release.sh 38 | release "$1" 39 | -------------------------------------------------------------------------------- /sidecars/release-livenessprobe.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # This file is part of MinIO DirectPV 3 | # Copyright (c) 2024 MinIO, Inc. 4 | # 5 | # This program is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU Affero General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU Affero General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Affero General Public License 16 | # along with this program. If not, see . 17 | 18 | ME=$(basename "$0"); export ME 19 | cd "$(dirname "$0")" || exit 255 20 | 21 | export GITHUB_PROJECT_NAME=livenessprobe 22 | export PROJECT_NAME=livenessprobe 23 | export PROJECT_DESCRIPTION="CSI Drive Liveness Probe" 24 | 25 | if [ "$#" -ne 1 ]; then 26 | cat < 29 | EXAMPLES: 30 | # Release ${PROJECT_NAME} v2.14.0 31 | $ ${ME} v2.14.0 32 | EOF 33 | exit 255 34 | fi 35 | 36 | # shellcheck source=/dev/null 37 | source release.sh 38 | release "$1" 39 | -------------------------------------------------------------------------------- /sidecars/release-node-driver-registrar.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # This file is part of MinIO DirectPV 3 | # Copyright (c) 2024 MinIO, Inc. 4 | # 5 | # This program is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU Affero General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU Affero General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Affero General Public License 16 | # along with this program. If not, see . 17 | 18 | ME=$(basename "$0"); export ME 19 | cd "$(dirname "$0")" || exit 255 20 | 21 | export GITHUB_PROJECT_NAME=node-driver-registrar 22 | export PROJECT_NAME=csi-node-driver-registrar 23 | export PROJECT_DESCRIPTION="CSI Node Driver Registrar" 24 | 25 | if [ "$#" -ne 1 ]; then 26 | cat < 29 | EXAMPLES: 30 | # Release ${PROJECT_NAME} v2.12.0 31 | $ ${ME} v2.12.0 32 | EOF 33 | exit 255 34 | fi 35 | 36 | # shellcheck source=/dev/null 37 | source release.sh 38 | release "$1" 39 | --------------------------------------------------------------------------------