4.8 KiB
Contributing to democratic-csi
Development Environment Setup
This project uses a hybrid development approach with devcontainers for IDE configuration and Vagrant for system-level testing.
Prerequisites
Before you begin, ensure you have the following installed:
- Visual Studio Code
- Docker
- Vagrant
- Virtualization Provider:
- For Intel/AMD Machines: VirtualBox
- For Apple Silicon: Qemu (
brew install qemu vagrantandvagrant plugin install vagrant-qemu)
Development Workflow
1. Local Development with Devcontainers
Devcontainers provide a consistent development environment with:
- Configured VSCode extensions
- Necessary development tools
- Integrated development experience
To use the devcontainer:
- Open the project in VSCode
- Install the "Dev Containers" extension
- Click "Reopen in Container" when prompted
- Start coding with pre-configured environment
[!Note] For
iSCSIit's mandatory to use the Vagrant VM, due to the need of a kernel driver. However for other tests the container is probably enough. It's possible to run thehack/run.shas explained below in the devcontainer and see if it's possible, before spinning up a full VM.
2. System Testing with Vagrant
Vagrant provides a full virtual machine environment for:
- System-level testing
- Running code with kernel dependencies
- Simulating production-like environments
Workflow:
# Navigate to project directory
cd ~/democratic-csi
# Start the Vagrant VM
vagrant up
# Connect to the VM
vagrant ssh
# Inside the VM, navigate to the project
cd ~/democratic-csi
# Run project tests, the config.yaml can be any from the examples folders
# just configured for your own environment.
# You can also create a file `dev/secrets.env` that has `export VARIABLE=VALUE`
# and reference those in your `config.yaml`
./hack/run.sh -c ./hack/config.yaml
![Note] For running tests with democratic-csi the authentication needs to be disabled, as it always initiates connections to the share without authentication.
Keeping Files in Sync
Use these methods to keep your local files synchronized with the Vagrant VM:
Manual Sync
# Sync files from local to Vagrant VM
vagrant rsync
Continuous Sync
# Automatically sync files as they change
vagrant rsync-auto
3. Deploy development version to K8s cluster
Deployment provides a good environment for:
- Final testing in a real world scenario
- Run the final version until included in a release
[!Note] Make sure to do the build on the architecture you will be running it. For example, don't build in Apple Silicon if your cluster runs in amd64.
- Login to your github container registry
docker login ghcr.io
[!Important] Login to the container registry is stored plain text, use a PAT instead of your Github password. Create a PAT with write:packages.
- Compile and push to your github container registry.
./hack/build_push.sh
- When you deploy, in the
values.yamladd the following, using the output from the script
controller:
driver:
image: ghcr.io/your_user/democratic-csi:your_branch-fc02fc4
node:
driver:
image: ghcr.io/your_user/democratic-csi:your_branch-fc02fc4
-
Make the Image Public
By default, images pushed to GHCR are private. To make it public:
- Go to GitHub → Your Repository → Packages (or directly github.com/USERNAME?tab=packages)
- Select the package
- Click Package Settings
- Change Visibility to Public
Best Practices
- Use devcontainer for day-to-day development and coding
- Use Vagrant for comprehensive system testing
- Always run
vagrant rsyncbefore running tests in the VM - Commit and push changes frequently
- If encountering issues, try:
- Recreating the devcontainer
- Reprovisioning the Vagrant VM with
vagrant reload --provisionorvagrant destroy -f && vagrant up
Troubleshooting
Devcontainer Issues
- Ensure Docker is running
- Rebuild the container if extensions fail to load
- Check VSCode Dev Containers extension logs
Vagrant Issues
- Verify virtualization is enabled in your BIOS
- Ensure you have the latest Vagrant and virtualization provider
- For Apple Silicon, use Parallels or Lima
Contribution Guidelines
- Create a new branch for your feature targetting
next - Write clear, concise commit messages
- Include coverage for tests of csi-sanity for new functionality
- Run tests in Vagrant VM
- Submit a pull request with a clear description of changes
Contact
For any questions or issues, please open an issue on the project repository.