{"id":30559342,"url":"https://github.com/danielfbm/knative-demo","last_synced_at":"2025-08-28T09:34:14.367Z","repository":{"id":298324709,"uuid":"997312444","full_name":"danielfbm/knative-demo","owner":"danielfbm","description":"Basic knative eventing demo","archived":false,"fork":false,"pushed_at":"2025-07-09T07:29:07.000Z","size":68,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-09T08:47:25.105Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","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/danielfbm.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":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-06T10:08:30.000Z","updated_at":"2025-06-25T07:36:26.000Z","dependencies_parsed_at":"2025-06-10T14:47:34.637Z","dependency_job_id":"09e3b537-fbdb-4cee-b978-92f63a43a0a7","html_url":"https://github.com/danielfbm/knative-demo","commit_stats":null,"previous_names":["danielfbm/knative-demo"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/danielfbm/knative-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielfbm%2Fknative-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielfbm%2Fknative-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielfbm%2Fknative-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielfbm%2Fknative-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielfbm","download_url":"https://codeload.github.com/danielfbm/knative-demo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielfbm%2Fknative-demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272476784,"owners_count":24940919,"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","status":"online","status_checked_at":"2025-08-28T02:00:10.768Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-08-28T09:34:13.303Z","updated_at":"2025-08-28T09:34:14.354Z","avatar_url":"https://github.com/danielfbm.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Knative Color Demo\n\nA Spring Boot application that demonstrates Knative eventing capabilities with a color timeline and CloudEvents integration.\n\n## Features\n\n- **Color Timeline UI**: Visual timeline showing color changes over time\n- **CloudEvents Sink**: Receives color change events from Knative eventing\n- **REST APIs**:\n  - `/api/colors/current` - Get current color with timestamp\n  - `/api/colors/history` - Get color change history\n  - `/api/events` - List all received CloudEvents\n- **Manual Color Control**: Web UI for manually changing colors\n- **Real-time Updates**: Auto-refreshing timeline and event list\n\n## Supported Colors\n\n- RED, GREEN, BLUE, YELLOW, PURPLE, ORANGE, BLACK, WHITE\n\n## Platform Compatibility\n\nThis application supports multiple deployment scenarios:\n\n- **Knative Serving + Eventing**: Full featured deployment with auto-scaling and event-driven architecture\n- **Knative Serving only**: Serverless deployment without eventing (manual color changes only)\n- **Standard Kubernetes**: Traditional deployment with port-forwarding for local access\n- **Local Development**: Spring Boot application with embedded H2 database\n\nThe deployment scripts automatically detect available platform features and adapt accordingly.\n\n## Quick Start\n\n### Prerequisites\n\n- Java 17+\n- Maven 3.6+\n- Docker\n- Kubernetes cluster with Knative installed\n- kubectl configured\n\n### Local Development\n\n1. **Build and run locally:**\n   ```bash\n   ./mvnw spring-boot:run\n   ```\n\n2. **Access the application:**\n   - Open http://localhost:8080 in your browser\n   - Use the timeline to see color changes\n   - Use the manual controls to change colors\n   - Monitor received CloudEvents on the right panel\n\n### Deploy to Knative\n\n1. **Install Knative components (if needed):**\n   ```bash\n   ./scripts/install-cert-manager.sh\n   ./scripts/install.sh\n   ```\n\n2. **Deploy the application:**\n   ```bash\n   # Quick deployment (requires Knative Serving)\n   ./scripts/deploy.sh\n\n   # Smart deployment (adapts to available platform)\n   ./scripts/deploy-k8s.sh\n\n   # Complete deployment with full monitoring\n   ./scripts/deploy-complete.sh\n   ```\n\n3. **Test the deployment:**\n   ```bash\n   # Basic CloudEvents testing\n   ./scripts/test-cloudevents.sh\n\n   # Comprehensive test suite\n   ./scripts/test-complete.sh\n   ```\n\n4. **Send test CloudEvents:**\n   ```bash\n   # Get the service URL (for Knative)\n   SERVICE_URL=$(kubectl get ksvc color-demo-app -n eventing-demo -o jsonpath='{.status.url}')\n\n   # Or use localhost for standard K8s deployment\n   SERVICE_URL=\"http://localhost:8080\"\n\n   # Send a color change event\n   curl -X POST ${SERVICE_URL}/cloudevents \\\n     -H 'Content-Type: application/json' \\\n     -H 'Ce-Id: test-123' \\\n     -H 'Ce-Source: manual-test' \\\n     -H 'Ce-Type: com.example.color.change' \\\n     -H 'Ce-Specversion: 1.0' \\\n     -d '{\"color\": \"BLUE\"}'\n   ```\n\n## CloudEvent Format\n\nThe application expects CloudEvents with the following format:\n\n```json\n{\n  \"specversion\": \"1.0\",\n  \"type\": \"com.example.color.change\",\n  \"source\": \"your-source\",\n  \"id\": \"unique-id\",\n  \"data\": {\n    \"color\": \"RED\"\n  }\n}\n```\n\n## API Endpoints\n\n### Color APIs\n- `GET /api/colors/current` - Current color and timestamp\n- `GET /api/colors/history` - All color changes (newest first)\n- `GET /api/colors/available` - List of supported colors\n- `POST /api/colors/set` - Manually set color\n\n### Event APIs\n- `GET /api/events` - All received CloudEvents (newest first)\n\n### CloudEvents Sink\n- `POST /cloudevents` - Knative CloudEvents sink endpoint\n- `GET /cloudevents/health` - Health check for Knative\n\n## Architecture\n\n```\n┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐\n│   Event Source  │───▶│  Knative Broker │───▶│  Color Demo App │\n└─────────────────┘    └─────────────────┘    └─────────────────┘\n                                                        │\n                                               ┌─────────────────┐\n                                               │   Web Browser   │\n                                               │  (Timeline UI)  │\n                                               └─────────────────┘\n```\n\n## Development\n\n### Project Structure\n\n```\nknative-demo/\n├── README.md                           # This file\n├── IMPLEMENTATION_SUMMARY.md           # Technical implementation details\n├── K8S_DEPLOYMENT.md                   # Kubernetes deployment guide\n├── Dockerfile                          # Container build configuration\n├── pom.xml                            # Maven build configuration\n├── mvnw / mvnw.cmd                    # Maven wrapper scripts\n│\n├── src/                               # Source code\n│   └── main/\n│       ├── java/com/example/knativecolordemo/\n│       │   ├── KnativeColorDemoApplication.java    # Main Spring Boot application\n│       │   ├── controller/\n│       │   │   ├── ColorController.java            # Color REST API\n│       │   │   ├── EventController.java            # Events REST API\n│       │   │   ├── CloudEventSinkController.java   # CloudEvents sink\n│       │   │   └── WebController.java              # Web UI controller\n│       │   ├── model/\n│       │   │   ├── ColorChange.java                # Color change entity\n│       │   │   └── CloudEventRecord.java           # CloudEvent record entity\n│       │   ├── repository/\n│       │   │   ├── ColorChangeRepository.java      # Color change data access\n│       │   │   └── CloudEventRepository.java       # CloudEvent data access\n│       │   └── service/\n│       │       ├── ColorService.java               # Color business logic\n│       │       └── CloudEventService.java          # CloudEvent business logic\n│       └── resources/\n│           ├── application.properties              # Spring Boot configuration\n│           ├── templates/\n│           │   └── index.html                      # Main web UI template\n│           └── static/\n│               ├── css/style.css                   # UI styles\n│               └── js/app.js                       # Frontend JavaScript\n│\n├── config/                            # Kubernetes manifests\n│   ├── namespace.yaml                 # Namespace definition\n│   ├── broker.yaml                    # Knative Broker configuration\n│   ├── auth/                          # RBAC configurations\n│   │   ├── sa.yaml                    # Service Account\n│   │   ├── role.yaml                  # Role definition\n│   │   └── rolebinding.yaml           # Role binding\n│   ├── colors/                        # Color demo specific configs\n│   │   ├── color-change-trigger.yaml  # Knative Trigger for color events\n│   │   ├── color-event-producer.yaml  # Test event producer\n│   │   ├── k8s-deployment.yaml        # Standard Kubernetes deployment\n│   │   └── serving/\n│   │       └── color-demo-service.yaml # Knative Service definition\n│   ├── cloudevents-player/            # CloudEvents testing tool\n│   │   ├── cloudevents-player.yaml    # CloudEvents Player deployment\n│   │   └── trigger.yaml               # Trigger for CloudEvents Player\n│   └── eventdisplay/                  # Event display utility\n│       ├── event-display.yaml         # Event display deployment\n│       └── trigger.yaml               # Event display trigger\n│\n└── scripts/                           # Deployment and testing scripts\n    ├── README.md                      # Scripts documentation\n    ├── library.sh                     # Common functions library\n    ├── install-cert-manager.sh        # Install cert-manager\n    ├── install.sh                     # Install Knative Eventing\n    ├── deploy.sh                      # Basic Knative deployment\n    ├── deploy-k8s.sh                  # Smart deployment (Knative or K8s)\n    ├── deploy-complete.sh             # Complete deployment with monitoring\n    ├── test-cloudevents.sh            # Basic CloudEvents testing\n    └── test-complete.sh               # Comprehensive test suite\n```\n\n### Database\n\nUses H2 in-memory database for simplicity. Data is stored in two tables:\n- `color_changes` - Tracks color changes over time\n- `cloud_events` - Stores all received CloudEvents\n\n### Scripts Organization\n\nAll deployment and testing scripts are located in the `scripts/` directory and use a common library (`library.sh`) for shared functionality:\n\n- **Installation Scripts**: Install Knative components and dependencies\n- **Deployment Scripts**: Deploy the application with different strategies\n- **Testing Scripts**: Test CloudEvents functionality and endpoints\n- **Library Functions**: Common utilities for path resolution, Kubernetes operations, and colored output\n\nSee `scripts/README.md` for detailed documentation on each script.\n\n### Configuration Files\n\nThe `config/` directory contains all Kubernetes manifests organized by function:\n\n- **Core**: namespace, broker, and RBAC configurations\n- **Application**: Knative Service and standard Kubernetes deployments\n- **Events**: Triggers and event producers for testing\n- **Testing Tools**: CloudEvents Player and Event Display utilities\n\n## Monitoring\n\n- **Timeline**: Visual representation of color changes over time\n- **Events Panel**: Real-time list of received CloudEvents\n- **Auto-refresh**: UI updates every 5 seconds automatically\n- **Manual Refresh**: Ctrl+R or refresh buttons\n\n## Testing Tools\n\n### CloudEvents Player\n\nThe project includes configuration for the [CloudEvents Player](https://github.com/ruromero/cloudevents-player), a useful tool for testing CloudEvents:\n\n```bash\n# Deploy CloudEvents Player\nkubectl apply -f config/cloudevents-player/\n\n# Access via port-forward\nkubectl port-forward -n eventing-demo service/cloudevents-player 8081:80\n\n# Open http://localhost:8081 to use the web interface\n```\n\n### Event Display\n\nFor debugging CloudEvents, you can deploy the event display utility:\n\n```bash\n# Deploy Event Display\nkubectl apply -f config/eventdisplay/\n\n# View logs to see all events\nkubectl logs -l app=event-display -n eventing-demo -f\n```\n\n### Manual Testing\n\nThe `test-complete.sh` script provides comprehensive testing of all endpoints and functionality:\n\n- Health checks\n- API endpoint validation\n- CloudEvent sending and verification\n- Color change validation\n- Event recording verification\n\n## Troubleshooting\n\n1. **Service not accessible**:\n   - Check Knative serving installation: `kubectl get pods -n knative-serving`\n   - Verify service status: `kubectl get ksvc -n eventing-demo`\n   - For standard K8s: Check port-forwarding is active\n\n2. **Events not received**:\n   - Verify broker configuration: `kubectl get brokers -n eventing-demo`\n   - Check trigger setup: `kubectl get triggers -n eventing-demo`\n   - Test with CloudEvents Player for debugging\n\n3. **UI not loading**:\n   - Check if static resources are properly served\n   - Verify application is running: `curl http://localhost:8080/cloudevents/health`\n\n4. **Database issues**:\n   - H2 console available at `/h2-console` (dev only)\n   - Check application logs for SQL errors\n\n5. **Scripts not working**:\n   - Ensure all scripts are executable: `chmod +x scripts/*.sh`\n   - Check that kubectl is configured correctly\n   - Verify Docker is running (for image builds)\n\n### Common Commands\n\n```bash\n# Check application status\nkubectl get all -n eventing-demo\n\n# View application logs\nkubectl logs -l app=color-demo-app -n eventing-demo -f\n\n# Test health endpoint\ncurl http://localhost:8080/cloudevents/health\n\n# Send manual CloudEvent\n./scripts/test-cloudevents.sh\n\n# Run comprehensive tests\n./scripts/test-complete.sh\n```\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Test locally and in Knative\n5. Submit a pull request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielfbm%2Fknative-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielfbm%2Fknative-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielfbm%2Fknative-demo/lists"}