Understanding the Demo Application
The skeleton includes:- Backend (
app/backend/): Minimal Express.js server with health check endpoints - Frontend (
app/frontend/): React + Vite placeholder application - Database: PostgreSQL (local via Docker Compose, RDS in production)
Replacing the Backend
The backend is located inapp/backend/ and uses Express.js by default.
app/backend/
src/
app.js # Express app configuration
server.js # Server entry point
package.json # Dependencies
Dockerfile # Container build configuration
Add your routes
Add your routes
Create your API routes in Import in
app/backend/src/routes/:app.js:Add business logic
Add business logic
Add your services in
app/backend/src/services/:Update dependencies
Update dependencies
Update
app/backend/package.json with your dependencies:GET /api/health - Basic health checkGET /api/health/database - Database connectivity checkGET /api/health/cloud - Cloud provider credentials check// Required for Kubernetes liveness probe
app.get('/api/health', (req, res) => {
res.json({
status: 'healthy',
timestamp: new Date().toISOString(),
provider: process.env.CLOUD_PROVIDER,
uptime: process.uptime(),
});
});
// Required for Kubernetes readiness probe
app.get('/api/health/database', async (req, res) => {
// Implement actual database check
const db = require('./services/factory').getDatabaseService();
const result = await db.ping();
res.json(result);
});
// Cloud provider health check
app.get('/api/health/cloud', (req, res) => {
res.json({
status: 'healthy',
provider: process.env.CLOUD_PROVIDER,
region: process.env.AWS_REGION || process.env.OCI_REGION || 'not-set',
});
});
Replacing the Frontend
The frontend is located inapp/frontend/ and uses React + Vite by default.
app/frontend/
src/
App.jsx # Main component (placeholder)
main.jsx # Entry point
package.json # Dependencies
Dockerfile # Nginx-based container
React/Vite (existing)
Copy your React application code to
app/frontend/src/: Vue.js
Replace the build configuration in Create
app/frontend/package.json:vite.config.js: Angular
Update Update
app/frontend/package.json:app/frontend/Dockerfile: Next.js
Update Update
app/frontend/package.json:app/frontend/Dockerfile:# Build stage
FROM node:18-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
# Production stage
FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
Testing Your Changes Locally
After customizing the application, test locally with Docker Compose:Updating Kubernetes Manifests
After replacing the demo app, update the Kubernetes deployment manifests:# kubernetes/backend/deployment.yaml
spec:
template:
spec:
containers:
- name: backend
image: your-registry/backend:v1.0 # REEMPLAZAR: your image
resources:
requests:
memory: "256Mi" # Adjust based on your app
cpu: "250m"
limits:
memory: "512Mi"
cpu: "500m"