-
Notifications
You must be signed in to change notification settings - Fork 11
Create .devcontainer with kind for local development and document in developer guide #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…r guide Co-authored-by: xgerman <6990342+xgerman@users.noreply.github.com>
Co-authored-by: xgerman <6990342+xgerman@users.noreply.github.com>
.devcontainer/devcontainer.json
Outdated
| "helm": "latest", | ||
| "minikube": "none" | ||
| }, | ||
| "ghcr.io/rio/features/kind:1": {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
failed on my MAC, "ghcr.io/mpriscella/features/kind:1": {}, worked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the kind feature reference to use ghcr.io/mpriscella/features/kind:1 for Mac compatibility. The change is in commit 7887848.
|
Also I see this error: postCreateCommand from devcontainer.json failed with exit code 1. Skipping any further user-provided commands. |
Co-authored-by: xgerman <6990342+xgerman@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR establishes a comprehensive development environment setup for the DocumentDB Kubernetes Operator using VS Code DevContainers and kind (Kubernetes in Docker), addressing issue #8. It provides both containerized and manual development workflows with complete automation scripts and detailed documentation.
Key changes include:
- Complete DevContainer configuration with Go 1.23, Docker-in-Docker, kubectl, Helm, and kind
- Automated setup scripts for environment verification, quick deployment, and post-creation configuration
- Comprehensive developer guide with 350+ lines covering workflows, testing, and troubleshooting
- Updated main README with development sections and quick start instructions
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/developer-guide.md | New comprehensive developer guide with DevContainer quickstart, manual setup, workflows, and troubleshooting |
| README.md | Updated with development section highlighting DevContainer setup and manual alternatives |
| .devcontainer/verify-environment.sh | Environment verification script checking all required tools and configurations |
| .devcontainer/setup.sh | Post-creation setup script installing Go tools and development dependencies |
| .devcontainer/quick-setup.sh | Complete automation script creating kind cluster with operator deployment and sample DocumentDB |
| .devcontainer/kind-config.yaml | Optimized kind cluster configuration with port mappings for LoadBalancer testing |
| .devcontainer/devcontainer.json | Main DevContainer configuration with Go 1.23, Docker-in-Docker, and VS Code extensions |
| .devcontainer/README.md | DevContainer-specific documentation with usage examples and troubleshooting |
| # Check Go | ||
| if command -v go >/dev/null 2>&1; then | ||
| go_version=$(go version) | ||
| if [[ $go_version == *"go1.23"* ]] || [[ $go_version == *"go1.24"* ]] || [[ $go_version > *"go1.23"* ]]; then |
Copilot
AI
Jul 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String comparison with '>' operator will not work correctly for version comparison. The condition [[ $go_version > *"go1.23"* ]] uses lexicographic comparison, not semantic version comparison. Consider using a proper version comparison function or simplifying to just check for go1.23+.
| # Check Go | |
| if command -v go >/dev/null 2>&1; then | |
| go_version=$(go version) | |
| if [[ $go_version == *"go1.23"* ]] || [[ $go_version == *"go1.24"* ]] || [[ $go_version > *"go1.23"* ]]; then | |
| # Function to compare semantic versions | |
| compare_versions() { | |
| local v1=$(echo "$1" | sed 's/go//; s/[^0-9.]*//g') | |
| local v2=$(echo "$2" | sed 's/go//; s/[^0-9.]*//g') | |
| local IFS=. | |
| local i | |
| read -r -a v1_parts <<< "$v1" | |
| read -r -a v2_parts <<< "$v2" | |
| for ((i=0; i<${#v1_parts[@]}; i++)); do | |
| if [[ ${v1_parts[i]} -gt ${v2_parts[i]} ]]; then | |
| return 0 | |
| elif [[ ${v1_parts[i]} -lt ${v2_parts[i]} ]]; then | |
| return 1 | |
| fi | |
| done | |
| return 0 | |
| } | |
| # Check Go | |
| if command -v go >/dev/null 2>&1; then | |
| go_version=$(go version) | |
| if compare_versions "$go_version" "go1.23"; then |
| echo "🔐 Installing cert-manager..." | ||
| if ! kubectl get namespace cert-manager >/dev/null 2>&1; then | ||
| kubectl create namespace cert-manager | ||
| kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.15.0/cert-manager.yaml |
Copilot
AI
Jul 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applying YAML directly from a remote URL without verification poses a security risk. Consider downloading the manifest first, verifying its integrity, or using Helm to install cert-manager with proper version pinning.
|
|
||
| The project includes Helm charts for deployment: | ||
|
|
||
| 1. **Install cert-manager (required dependency):** |
Copilot
AI
Jul 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Adding Helm repositories without verification may pose security risks. Consider adding instructions to verify the repository's authenticity or mention the need to trust the source.
| 1. **Install cert-manager (required dependency):** | |
| 1. **Install cert-manager (required dependency):** | |
| Before adding the repository, verify its authenticity by ensuring the URL is correct and from a trusted source (e.g., https://charts.jetstack.io is the official repository for cert-manager). |
Co-authored-by: xgerman <6990342+xgerman@users.noreply.github.com>
I've improved the setup script error handling to address the postCreateCommand failure. The enhanced script now includes:
The script is now more robust and provides better diagnostics when issues occur. Changes in commit 4a95ce5. |
|
running |
|
|
||
| # Build and load operator image | ||
| echo "🔨 Building operator image..." | ||
| make docker-build IMG=controller:latest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seeing failure...
=> => naming to docker.io/library/controller:latest 0.0s
📤 Loading operator image into kind cluster...
Image: "controller:latest" with ID "sha256:0a1edbcaa628c26deb1939009fdd542e220d38b2b94766dfff5b47159a5187bc" not yet present on node "documentdb-dev-worker", loading...
Image: "controller:latest" with ID "sha256:0a1edbcaa628c26deb1939009fdd542e220d38b2b94766dfff5b47159a5187bc" not yet present on node "documentdb-dev-control-plane", loading...
🚀 Deploying DocumentDB operator...
Downloading sigs.k8s.io/controller-tools/cmd/controller-gen@v0.17.2
go: could not create module cache: mkdir /go/pkg/mod: permission denied
make: *** [Makefile:195: /workspaces/documentdb-kubernetes-operator/bin/controller-gen] Error 1
This PR provides a comprehensive development environment setup for the DocumentDB Kubernetes Operator using VS Code DevContainers and kind (Kubernetes in Docker).
Complete DevContainer Configuration
Automated Setup Scripts
.devcontainer/setup.sh- Robust post-create setup with enhanced error handling, debug mode, and graceful failure recovery.devcontainer/quick-setup.sh- One-command complete setup: creates kind cluster, builds operator, and deploys with sample DocumentDB.devcontainer/verify-environment.sh- Validates all tools and configuration are properly installed.devcontainer/kind-config.yaml- Optimized kind cluster configuration with port mappings for LoadBalancer testingComprehensive Documentation
docs/developer-guide.md- Complete 350+ line developer guide covering DevContainer quick start, manual setup, development workflows, testing strategies, building procedures, cluster management, and troubleshooting.devcontainer/README.md- DevContainer-specific documentation with usage examples and troubleshooting guidanceEnhanced Reliability
The setup script includes robust error handling with:
DEBUG=true) for verbose troubleshooting outputDeveloper Experience
One-click setup: Open the repository in VS Code and select "Reopen in Container" - you'll have a complete development environment ready in minutes.
Complete workflow support:
Production-ready features:
This setup enables both new contributors and experienced developers to get a fully functional DocumentDB Kubernetes operator development environment with minimal effort, supporting the complete development lifecycle from coding to testing to deployment.
Fixes #8.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.