|
| 1 | +# Kube Bind Frontend |
| 2 | + |
| 3 | +A Vue.js + TypeScript frontend application for the Kube Bind project that provides a web interface for binding Kubernetes resources across clusters with SSO authentication. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **SSO Authentication**: OAuth2/OIDC-based authentication via `/api/authorize` endpoint |
| 8 | +- **Resource Management**: Browse and bind available Kubernetes resources |
| 9 | +- **Modern Stack**: Built with Vue.js 3, TypeScript, and Vite |
| 10 | + |
| 11 | +## Architecture |
| 12 | + |
| 13 | +The frontend integrates with the existing Go backend and provides compatibility for CLI clients through redirect handling: |
| 14 | + |
| 15 | +### API Endpoints |
| 16 | + |
| 17 | +- `/api/authorize` - SSO authentication endpoint |
| 18 | +- `/api/callback` - OAuth2 callback handler |
| 19 | +- `/api/resources` - Fetch available resources |
| 20 | +- `/api/bind` - Bind resources to cluster |
| 21 | +- `/api/clusters/{cluster}/resources` - Cluster-specific resources |
| 22 | +- `/api/clusters/{cluster}/authorize` - Cluster-specific authentication |
| 23 | +- `/api/exports` - Export binding configuration |
| 24 | +- `/api/clusters/{cluster}/exports` - Cluster-specific exports |
| 25 | + |
| 26 | +### Redirect Handling |
| 27 | + |
| 28 | +For CLI compatibility, the following routes provide HTTP 302 redirects: |
| 29 | + |
| 30 | +- `/exports` → `/api/exports` |
| 31 | +- `/clusters/{cluster}/exports` → `/api/clusters/{cluster}/exports` |
| 32 | + |
| 33 | +Frontend routes handle browser-based redirects for: |
| 34 | + |
| 35 | +- `/authorize` → `/api/authorize` |
| 36 | +- `/clusters/{cluster}/authorize` → `/api/clusters/{cluster}/authorize` |
| 37 | +- `/callback` → `/api/callback` |
| 38 | + |
| 39 | +## Development Setup |
| 40 | + |
| 41 | +### Prerequisites |
| 42 | + |
| 43 | +- Node.js 18+ and npm |
| 44 | +- Go 1.19+ for running the backend server |
| 45 | + |
| 46 | +### Development Workflow |
| 47 | + |
| 48 | +#### Development with Hot Reload (Recommended) |
| 49 | +```bash |
| 50 | +# Terminal 1: Start Go backend |
| 51 | +go run ./cmd/backend --listen-port=8080 --frontend http://localhost:3000 |
| 52 | + |
| 53 | +# Terminal 2: Start frontend dev server with hot reload |
| 54 | +cd web |
| 55 | +npm install |
| 56 | +npm run dev |
| 57 | + |
| 58 | +### Available Scripts |
| 59 | + |
| 60 | +- `npm run dev` - Start development server |
| 61 | +- `npm run build` - Build for production |
| 62 | +- `npm run preview` - Preview production build |
| 63 | +- `npm run lint` - Lint code |
| 64 | +- `npm run type-check` - Run TypeScript type checking |
| 65 | + |
| 66 | +## Authentication Flow |
| 67 | + |
| 68 | +1. User clicks "Login" or accesses protected resource |
| 69 | +2. Frontend redirects to `/api/authorize` with session parameters |
| 70 | +3. Backend handles OAuth2 flow with configured OIDC provider |
| 71 | +4. User is redirected back to frontend with authentication cookie |
| 72 | +5. Frontend can now access protected endpoints |
| 73 | + |
| 74 | +## Project Structure |
| 75 | + |
| 76 | +```text |
| 77 | +src/ |
| 78 | +├── main.ts # Application entry point and routing |
| 79 | +├── App.vue # Root component |
| 80 | +├── services/ |
| 81 | +│ └── auth.ts # Authentication and API service |
| 82 | +└── views/ |
| 83 | + └── Resources.vue # Resource management interface |
| 84 | +``` |
| 85 | + |
| 86 | +## Configuration |
| 87 | + |
| 88 | +The frontend automatically detects the backend API through Vite proxy configuration. For production deployments, ensure the frontend is served from the same domain as the backend or configure CORS appropriately. |
| 89 | + |
| 90 | +## Building for Production |
| 91 | + |
| 92 | +### Integrated Build |
| 93 | +```bash |
| 94 | +# Use the build script (builds frontend + Go binary) |
| 95 | +./scripts/build-frontend.sh |
| 96 | +``` |
| 97 | + |
| 98 | +### Frontend Only |
| 99 | +```bash |
| 100 | +cd web |
| 101 | +npm run build |
| 102 | +``` |
| 103 | + |
| 104 | +The built files will be in the `web/dist/` directory and are automatically embedded into the container image and served from there. |
0 commit comments