{"id":28744755,"url":"https://github.com/netologist/pure","last_synced_at":"2025-06-16T12:05:16.812Z","repository":{"id":295501515,"uuid":"985899177","full_name":"netologist/pure","owner":"netologist","description":"k8s based development environment","archived":false,"fork":false,"pushed_at":"2025-05-25T21:53:25.000Z","size":2,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-25T22:31:43.171Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/netologist.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-18T18:46:12.000Z","updated_at":"2025-05-25T21:53:57.000Z","dependencies_parsed_at":"2025-05-25T22:31:46.578Z","dependency_job_id":"06c08625-ff7c-4def-8e12-85a76ce13772","html_url":"https://github.com/netologist/pure","commit_stats":null,"previous_names":["netologist/pure"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/netologist/pure","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netologist%2Fpure","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netologist%2Fpure/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netologist%2Fpure/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netologist%2Fpure/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/netologist","download_url":"https://codeload.github.com/netologist/pure/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netologist%2Fpure/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260158326,"owners_count":22967226,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-16T12:05:16.088Z","updated_at":"2025-06-16T12:05:16.791Z","avatar_url":"https://github.com/netologist.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Node.js App with Skaffold + Flux + Kustomize\n\nA complete setup demonstrating how to use the same Node.js application across local development (Skaffold) and remote environments (Flux GitOps) with Kustomize overlays.\n\n## Quick Start\n\n### 1. File Structure\nCreate the following files in your project:\n\n```\nmy-app/\n├── server.js                # Main Node.js application\n├── package.json             # Node.js dependencies\n├── Dockerfile               # Container configuration\n├── .dockerignore            # Docker ignore file\n├── skaffold.yaml            # Skaffold configuration\n└── k8s/                     # Kubernetes manifests\n    ├── base/\n    │   ├── kustomization.yaml\n    │   ├── deployment.yaml\n    │   ├── service.yaml\n    │   ├── configmap.yaml\n    │   └── hpa.yaml\n    └── overlays/\n        ├── local/\n        ├── dev/\n        ├── staging/\n        └── prod/\n```\n\n### 2. Install Dependencies\n\n```bash\n# Install Node.js dependencies\nnpm install\n\n# Install development tools\nnpm install -g skaffold\n# Or follow: https://skaffold.dev/docs/install/\n\n# Install kubectl and kustomize\n# Follow: https://kubernetes.io/docs/tasks/tools/\n```\n\n### 3. Local Development\n\n```bash\n# Start local development with live reload\nskaffold dev\n\n# Or build and deploy once\nskaffold run\n\n# Clean up local deployment\nskaffold delete\n```\n\n### 4. Test the Application\n\nOnce running, visit:\n- **Main app**: http://localhost:8080\n- **Health check**: http://localhost:8080/health  \n- **API status**: http://localhost:8080/api/status\n- **App info**: http://localhost:8080/info\n\n### 5. Docker Development (Alternative)\n\n```bash\n# Build the image\ndocker build -t my-app .\n\n# Run locally\ndocker run -p 8080:8080 -e ENV=local -e LOG_LEVEL=debug my-app\n\n# Test health endpoint\ncurl http://localhost:8080/health\n```\n\n## Application Features\n\n### Endpoints\n\n- **`/`** - Main application page with environment info\n- **`/health`** - Health check (for liveness probe)\n- **`/ready`** - Readiness check (for readiness probe)  \n- **`/info`** - Application information and metrics\n- **`/api/status`** - API status and available endpoints\n- **`/api/hello?name=World`** - Simple API example\n\n### Environment Configuration\n\nThe app reads these environment variables:\n\n- **`PORT`** - Server port (default: 8080)\n- **`ENV`** - Environment name (local/dev/staging/prod)\n- **`LOG_LEVEL`** - Logging level (error/warn/info/debug)\n- **`DATABASE_HOST`** - Database connection (from ConfigMap)\n- **`DATABASE_TIMEOUT`** - Database timeout (from ConfigMap)\n\n### Health Checks\n\n- **Liveness Probe**: `/health` - Kubernetes restarts pod if this fails\n- **Readiness Probe**: `/ready` - Kubernetes stops sending traffic if this fails\n- **Docker Health Check**: Built into Dockerfile for container health\n\n## Deployment Workflow\n\n### Local Development\n```bash\n# Start with hot reload\nskaffold dev\n\n# The app runs with:\n# - 1 replica\n# - Debug logging\n# - Reduced resource limits\n# - Port forwarding to localhost:8080\n```\n\n### Development Environment (Flux)\n```bash\n# Push to main branch\ngit add .\ngit commit -m \"Update application\"\ngit push origin main\n\n# Flux automatically:\n# - Deploys to my-app-dev namespace\n# - Uses dev image tag\n# - Applies dev configuration\n# - Enables debug logging\n```\n\n### Staging Environment (Flux)\n```bash\n# Same as dev, but:\n# - Deploys to my-app-staging namespace  \n# - Uses staging image tag\n# - Higher resource limits\n# - Info-level logging\n# - SSL/TLS enabled\n```\n\n### Production Environment (Flux)\n```bash\n# Create a release tag\ngit tag v1.0.0\ngit push origin v1.0.0\n\n# Flux automatically:\n# - Deploys only tagged releases\n# - Uses my-app-prod namespace\n# - Production resource limits\n# - Warn-level logging\n# - SSL/TLS with production certificates\n```\n\n## Configuration Per Environment\n\n| Setting | Local | Dev | Staging | Prod |\n|---------|-------|-----|---------|------|\n| Replicas | 1 | 2 | 3 | 5 |\n| Log Level | debug | debug | info | warn |\n| Resources | Minimal | Low | Medium | High |\n| HPA Min | 1 | 2 | 3 | 5 |\n| HPA Max | 1 | 10 | 10 | 20 |\n| SSL/TLS | No | No | Yes | Yes |\n| Namespace | default | my-app-dev | my-app-staging | my-app-prod |\n\n## Troubleshooting\n\n### Skaffold Issues\n\n```bash\n# Check Skaffold configuration\nskaffold config list\nskaffold diagnose\n\n# View logs\nskaffold dev --verbosity=debug\n\n# Check what would be deployed\nskaffold render\n```\n\n### Kubernetes Issues\n\n```bash\n# Check pods\nkubectl get pods -n my-app-dev\n\n# View pod logs  \nkubectl logs -f deployment/my-app -n my-app-dev\n\n# Check configuration\nkubectl get configmap my-app-config -o yaml -n my-app-dev\n\n# Test kustomize locally\nkustomize build k8s/overlays/dev\n```\n\n### Application Issues\n\n```bash\n# Check health endpoints\ncurl http://localhost:8080/health\ncurl http://localhost:8080/ready\n\n# View application info\ncurl http://localhost:8080/info\n\n# Check API status\ncurl http://localhost:8080/api/status\n```\n\n## Next Steps\n\n1. **Add Database**: Extend with PostgreSQL or MongoDB\n2. **Add Tests**: Include unit and integration tests\n3. **Add Monitoring**: Integrate Prometheus metrics\n4. **Add Secrets**: Use Kubernetes secrets for sensitive data\n5. **Add CI/CD**: Automate image building and testing\n6. **Add Ingress**: Configure external access with ingress controllers\n\n## Resources\n\n- [Skaffold Documentation](https://skaffold.dev/docs/)\n- [Flux Documentation](https://fluxcd.io/docs/)\n- [Kustomize Documentation](https://kubectl.docs.kubernetes.io/guides/introduction/kustomize/)\n- [Kubernetes Documentation](https://kubernetes.io/docs/)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetologist%2Fpure","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetologist%2Fpure","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetologist%2Fpure/lists"}