Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 39 additions & 13 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,21 @@ jobs:

- name: 🔑 Configure Kubernetes context
run: |
# Note: In real deployment, kubeconfig would be stored as GitHub secret
echo "Setting up Kubernetes context for TUM cluster"
echo "KUBECONFIG would be loaded from secrets in production"
echo "🔧 Setting up TUM Kubernetes cluster access..."

# Create .kube directory
mkdir -p ~/.kube

# Write kubeconfig from GitHub secret
echo "${{ secrets.TUM_KUBECONFIG }}" | base64 -d > ~/.kube/config
chmod 600 ~/.kube/config

# Verify connection
kubectl config current-context
kubectl version --client

echo "✅ Connected to TUM Kubernetes cluster"

- name: 🌍 Set deployment environment
id: env
run: |
Expand Down Expand Up @@ -396,6 +407,13 @@ jobs:
export POSTGRES_PASSWORD="${{ secrets.POSTGRES_PASSWORD }}"
export GRAFANA_ADMIN_PASSWORD="${{ secrets.GRAFANA_ADMIN_PASSWORD }}"

# Email alerts (optional)
export ALERT_EMAIL_FROM="${{ secrets.ALERT_EMAIL_FROM || 'hakanduranyt@gmail.com' }}"
export ALERT_EMAIL_TO="${{ secrets.ALERT_EMAIL_TO || 'hakanduranyt@gmail.com' }}"
export ALERT_EMAIL_USERNAME="${{ secrets.ALERT_EMAIL_USERNAME || 'hakanduranyt@gmail.com' }}"
export ALERT_EMAIL_PASSWORD="${{ secrets.ALERT_EMAIL_PASSWORD || 'your_gmail_app_password_here' }}"
export SMTP_HOST="${{ secrets.SMTP_HOST || 'smtp.gmail.com:587' }}"

# Set IMAGE_TAG based on branch
if [[ "${{ needs.setup.outputs.is_main }}" == "true" ]]; then
export IMAGE_TAG="main"
Expand All @@ -412,6 +430,11 @@ jobs:
echo " - CHAIR_API_KEY"
echo " - POSTGRES_PASSWORD"
echo " - GRAFANA_ADMIN_PASSWORD"
echo ""
echo "📋 Optional TUM Kubernetes secrets:"
echo " - TUM_KUBECONFIG (base64 encoded kubeconfig)"
echo " - TUM_NAMESPACE (e.g., ge85zat-devops25)"
echo " - TUM_INGRESS_HOST (e.g., ge85zat-devops25.student.k8s.aet.cit.tum.de)"
exit 1
fi

Expand Down Expand Up @@ -448,21 +471,24 @@ jobs:
echo "- $line" >> $GITHUB_STEP_SUMMARY
done

# Job 6: Summary (Updated dependencies)
# Job 6: Pipeline Summary
summary:
name: 📊 Pipeline Summary
name: 📊 Pipeline Summary
runs-on: ubuntu-latest
needs: [setup, unit-tests, integration-tests, build-and-push-ghcr, deploy-to-kubernetes]
if: always()
steps:
- name: 📊 Display Results Summary
- name: 📊 Pipeline Results
run: |
echo "🔍 ==========================="
echo "📊 FLEXFIT CI/CD SUMMARY"
echo "🔍 ==========================="
echo " 📋 Setup: ${{ needs.setup.result }}"
echo " 🧪 Unit Tests: ${{ needs.unit-tests.result }}"
echo " 🔧 Integration Tests: ${{ needs.integration-tests.result || 'skipped' }}"
echo "📊 FlexFit CI/CD Pipeline Results"
echo "=================================="
echo "Event: ${{ github.event_name }}"
echo "Branch: ${{ needs.setup.outputs.target_branch }}"
echo "Is PR: ${{ needs.setup.outputs.is_pr }}"
echo ""
echo "Test Results:"
echo " 🧪 Unit Tests: ${{ needs.unit-tests.result || 'skipped' }}"
echo " 🔗 Integration Tests: ${{ needs.integration-tests.result || 'skipped' }}"
echo " 🐳 GHCR Push: ${{ needs.build-and-push-ghcr.result || 'skipped' }}"
echo " 🚀 Kubernetes Deploy: ${{ needs.deploy-to-kubernetes.result || 'skipped' }}"
echo "🔍 ==========================="
echo ""
77 changes: 77 additions & 0 deletions docs/TUM_KUBERNETES_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# TUM Kubernetes Cluster Setup Guide

## 🎯 **Overview**
This guide shows how to deploy FlexFit to the **TUM Student Kubernetes Cluster** using the same process described in W05.

## 📋 **Prerequisites**
- TUM ID (e.g., `ge85zat`)
- Access to TUM VPN/network
- GitHub repository with CI/CD setup

## 🚀 **Step 1: Access TUM Rancher**

1. **Open Rancher**: https://rancher.ase.cit.tum.de
2. **Login** with your TUM ID credentials
3. **Access** the Student Cluster

## 🔑 **Step 2: Download Kubeconfig**

1. In Rancher, **download** the `student.yaml` kubeconfig file
2. **Save** it securely (this gives access to the TUM cluster)

## 🏗️ **Step 3: Create Your Namespace**

1. Go to **Projects/Namespaces** in Rancher
2. **Create Namespace**: `<your-tum-id>-devops25`
- Example: `ge85zat-devops25`
3. This will be your **team's deployment space**

## 📦 **Step 4: Add to GitHub Secrets**

Go to your GitHub repository → **Settings** → **Secrets and variables** → **Actions**

Add these secrets:

```
TUM_KUBECONFIG = <content of student.yaml file>
TUM_NAMESPACE = <your-tum-id>-devops25
TUM_INGRESS_HOST = <your-tum-id>-devops25.student.k8s.aet.cit.tum.de
```

## 🔧 **Step 5: Update CI/CD Pipeline**

The pipeline should:
1. ✅ **Build & Push** Docker images to GHCR
2. ✅ **Deploy to TUM** Kubernetes using Helm
3. ✅ **Use your namespace** for isolation

## 🌐 **Step 6: Access Your Application**

After deployment:
- **URL**: `https://<your-tum-id>-devops25.student.k8s.aet.cit.tum.de`
- **Monitoring**: Check pods in Rancher dashboard
- **Logs**: Use `kubectl logs` or Rancher UI

## 📊 **Points Breakdown**
- ✅ **CI Pipeline** (8 points): Build, test, Docker images ✅
- ✅ **CD Pipeline** (6 points): Auto-deploy to Kubernetes ✅
- ✅ **TUM Infrastructure**: Works on Rancher cluster ✅

## 🛠️ **Local Testing**
```bash
# Test with your local kubectl
export KUBECONFIG=student.yaml
kubectl config current-context # Should return "student"
kubectl get namespaces | grep <your-tum-id>

# Deploy locally to test
helm upgrade --install flexfit helm/flexfit/ \
--namespace <your-tum-id>-devops25 \
-f helm/flexfit/values-tum-production.yaml
```

## 🔍 **Troubleshooting**
- **Access denied**: Check VPN connection to TUM
- **Namespace not found**: Create namespace in Rancher first
- **Image pull errors**: Verify GHCR images are public/accessible
- **Ingress issues**: Check TUM_INGRESS_HOST matches your namespace
4 changes: 2 additions & 2 deletions monitoring/prometheus/prometheus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ scrape_configs:
scrape_interval: 5s
scrape_timeout: 5s

# Cloud GenAI Worker metrics
# GenAI Worker Cloud metrics
- job_name: 'genai-worker-cloud'
static_configs:
- targets: ['genai-workout-worker:8083']
- targets: ['genai-workout-worker:8000']
metrics_path: '/metrics'
scrape_interval: 10s
scrape_timeout: 5s
Expand Down
9 changes: 9 additions & 0 deletions server/service-registry/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down
23 changes: 20 additions & 3 deletions server/service-registry/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,30 @@ spring:
name: service-registry

server:
port: ${PORT:8761}
port: 8761

eureka:
instance:
hostname: localhost
client:
register-with-eureka: false
fetch-registry: false
service-url:
defaultZone: http://localhost:8761/eureka/
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
server:
enable-self-preservation: false
enable-self-preservation: false

management:
endpoints:
web:
exposure:
include: health,info,prometheus
endpoint:
health:
show-details: always
prometheus:
enabled: true
metrics:
export:
prometheus:
enabled: true
Loading