From 911f8d28a136bf483b81e8c35e18879df75979e5 Mon Sep 17 00:00:00 2001 From: Vaibhav Pathak Date: Mon, 5 Jan 2026 17:48:21 +0530 Subject: [PATCH] Fix sync wave ordering - dbinit wave 0, deployment wave 1 - Removed hook: Sync annotation from dbinit (was causing it to run before MySQL) - dbinit Job: wave 0 (same as MySQL, wait-for-db handles timing) - Deployment: wave 1 (starts after dbinit completes) - Fixes: db init job starting before mysql pod --- .gitignore | 42 +++++++ README.md | 288 ++++++++++++++++++++++++++++++++++++++++++++++ catalog-info.yaml | 123 ++++++++++++++++++++ helm | 1 + mkdocs.yml | 4 + 5 files changed, 458 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 catalog-info.yaml create mode 160000 helm create mode 100644 mkdocs.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..521af85 --- /dev/null +++ b/.gitignore @@ -0,0 +1,42 @@ +# Build outputs +build/ +target/ +*.class +*.jar +*.war +*.ear + +# IDE +.idea/ +*.iml +.vscode/ +.settings/ +.project +.classpath + +# OS +.DS_Store +Thumbs.db + +# Logs +*.log + +# Temporary files +*.tmp +*.bak +*.swp +*~ + +# Helm +*.tgz +charts/*.tgz + +# Environment +.env +.env.local + +# Secrets (never commit) +secrets/ +*.pem +*.key +*-credentials.json diff --git a/README.md b/README.md new file mode 100644 index 0000000..c1c89b0 --- /dev/null +++ b/README.md @@ -0,0 +1,288 @@ +# Hades V2 - Authentication & Authorization Service + +Hades is a Java-based authentication and authorization service providing: +- User authentication (username/password, OAuth, SAML) +- Token-based authorization with ACL +- User and entity management +- Multi-tenant context management +- Integration with external identity providers + +## Quick Start + +### Deploy with Backstage + +1. **Create Test Environment:** + - Navigate to Backstage → Environments (`/environment`) + - Click "Create Environment" + - Select `hades-service` + - Choose resource size and TTL + - Click "Create Environment" + +2. **Access the Service:** + ```bash + # Get the service URL + kubectl get service -n + + # Health check + curl http:///schedulerService/jobTrigger?jsonQuery=%7B%22application%22%3A%22nagios%22%2C%22jobName%22%3A%22monitoring_scheduler_svc%22%7D + ``` + +### Deploy with Helm + +```bash +# Add Helm repository (if using a chart repository) +helm repo add hades https://charts.company.com + +# Install Hades +helm install hades ./helm/hades \ + --namespace hades \ + --create-namespace \ + --set image.tag=1764243003606 + +# Upgrade +helm upgrade hades ./helm/hades \ + --namespace hades \ + --set image.tag=latest + +# Uninstall +helm uninstall hades --namespace hades +``` + +### Deploy with ArgoCD + +```bash +# Create ArgoCD Application +kubectl apply -f - < +``` + +### Environment Variables + +The service supports the following environment variables: + +- `JAVA_OPTS`: JVM options (default: `-Xms512m -Xmx2048m`) +- `CATALINA_OPTS`: Tomcat options (default: `-Dconfig.path=/app/config`) +- `DB_HOST`: Database host +- `DB_PORT`: Database port +- `DB_NAME`: Database name +- `DB_USERNAME`: Database username +- `DB_PASSWORD`: Database password + +## API Endpoints + +### Authentication + +```bash +# Authenticate user +POST /authenticate +Content-Type: application/json + +{ + "username": "user@example.com", + "password": "password123" +} +``` + +### Authorization + +```bash +# Authorize token +POST /authorize +Content-Type: application/json + +{ + "token": "your-auth-token" +} +``` + +### Health Check + +```bash +# Health check +GET /schedulerService/jobTrigger?jsonQuery=%7B%22application%22%3A%22nagios%22%2C%22jobName%22%3A%22monitoring_scheduler_svc%22%7D +``` + +## Development + +### Local Development + +```bash +# Build the application +cd /path/to/hades/source +ant setup + +# Build Docker image +docker build -t hades:local . + +# Run locally +docker run -p 8080:8080 hades:local +``` + +### Testing + +```bash +# Run unit tests +ant unittest + +# Test deployment +helm lint helm/hades + +# Dry run +helm install hades ./helm/hades --dry-run --debug +``` + +## Monitoring + +### Metrics + +The service exposes metrics at: +- Health: `/schedulerService/jobTrigger` +- Application logs: Container stdout/stderr + +### Grafana Dashboards + +View metrics in Grafana: +- [Hades Service Dashboard](https://grafana.company.com/d/hades) + +### Alerts + +Key alerts configured: +- Service unavailable (5xx errors) +- High response time (> 2s) +- Database connection failures +- Memory usage > 80% + +## Troubleshooting + +### Pod not starting + +```bash +# Check pod status +kubectl get pods -n + +# Check logs +kubectl logs -f -n + +# Describe pod +kubectl describe pod -n +``` + +### Database connection issues + +```bash +# Check database connectivity +kubectl exec -it -n -- curl mysql:3306 + +# Check database credentials +kubectl get secret -n -o yaml +``` + +### Health check failing + +```bash +# Test health endpoint +kubectl exec -it -n -- curl localhost:8080/schedulerService/jobTrigger?jsonQuery=%7B%22application%22%3A%22nagios%22%2C%22jobName%22%3A%22monitoring_scheduler_svc%22%7D +``` + +## Architecture + +``` +┌─────────────────┐ +│ Load Balancer │ +└────────┬────────┘ + │ + ▼ +┌─────────────────┐ +│ Ingress/Service│ +└────────┬────────┘ + │ + ▼ +┌─────────────────┐ +│ Hades Pods │ +│ (Tomcat 9) │ +└────────┬────────┘ + │ + ▼ +┌─────────────────┐ +│ MySQL Database │ +└─────────────────┘ +``` + +## Security + +- Passwords hashed with BCrypt +- Token-based authentication +- ACL-based authorization +- CAPTCHA support for brute-force protection +- IP-based access control +- SAML/OAuth integration + +## Support + +- **Documentation**: https://wiki.company.com/hades +- **Issues**: https://github.com/yourorg/hades-service/issues +- **Slack**: #hades-support +- **Email**: platform-team@company.com + +## License + +Proprietary - © Your Company diff --git a/catalog-info.yaml b/catalog-info.yaml new file mode 100644 index 0000000..11507fa --- /dev/null +++ b/catalog-info.yaml @@ -0,0 +1,123 @@ +apiVersion: backstage.io/v1alpha1 +kind: Component +metadata: + name: hades-service + title: Hades V2 Authentication Service + description: Authentication and Authorization Service providing user management, OAuth/SAML integration, ACL-based access control, and multi-tenant context management + annotations: + backstage.io/techdocs-ref: dir:. + github.com/project-slug: yourorg/hades-service + # Argo Workflows annotation for environment provisioning + argo-workflows.cnoe.io/label-selector: "service=hades-service" + # ArgoCD annotations + argocd/app-name: hades-service + # Kubernetes annotations - Using kubernetes-id with commonLabels + backstage.io/kubernetes-id: hades-service + # Helm chart annotations for environment provisioning + helm.cnoe.io/git-repo: https://gitea.cnoe.localtest.me:8443/giteaAdmin/hades-chart.git + helm.cnoe.io/chart-path: hades + helm.cnoe.io/values-file: values-dev.yaml + helm.cnoe.io/available-values-files: '["values.yaml", "values-dev.yaml", "values-local.yaml"]' + helm.cnoe.io/dependencies: '{"mysql": {"name": "MySQL Database", "required": false, "default": true}}' + tags: + - java + - authentication + - authorization + - servlet + - tomcat + - oauth + - saml + - acl + links: + - url: https://wiki.company.com/hades + title: Documentation + icon: docs + - url: https://grafana.company.com/d/hades + title: Grafana Dashboard + icon: dashboard + - url: https://sentry.io/hades + title: Error Tracking + icon: alert +spec: + type: service + lifecycle: experimental + owner: user1 + dependsOn: + - resource:default/hades-database + providesApis: + - hades-api + consumesApis: [] + +--- +apiVersion: backstage.io/v1alpha1 +kind: API +metadata: + name: hades-api + title: Hades Authentication API + description: REST API for authentication and authorization operations + tags: + - rest + - authentication + links: + - url: https://api-docs.company.com/hades + title: API Documentation +spec: + type: openapi + lifecycle: experimental + owner: user1 + definition: | + openapi: 3.0.0 + info: + title: Hades V2 API + version: 3.0.0 + description: Authentication and Authorization Service + paths: + /authenticate: + post: + summary: Authenticate user + description: Authenticate a user with username/password + operationId: authenticate + tags: + - Authentication + /authorize: + post: + summary: Authorize token + description: Validate and authorize an authentication token + operationId: authorize + tags: + - Authorization + /users: + get: + summary: List users + description: Get list of users + operationId: listUsers + tags: + - Users + post: + summary: Create user + description: Create a new user + operationId: createUser + tags: + - Users + /schedulerService/jobTrigger: + get: + summary: Health check + description: Service health check endpoint + operationId: healthCheck + tags: + - Monitoring + +--- +apiVersion: backstage.io/v1alpha1 +kind: Resource +metadata: + name: hades-database + title: Hades Database + description: MySQL database for Hades service + tags: + - database + - mysql +spec: + type: database + owner: user1 + dependsOn: [] diff --git a/helm b/helm new file mode 160000 index 0000000..f52bd12 --- /dev/null +++ b/helm @@ -0,0 +1 @@ +Subproject commit f52bd12a9af6b44277d1277b505691511e92eca6 diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 0000000..a5509b0 --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,4 @@ +site_name: Hades V2 Authentication Service +docs_dir: docs +plugins: + - techdocs-core