Skip to content
Open
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
2 changes: 2 additions & 0 deletions .shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
external-sources=true
source-path=SCRIPTDIR
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ set -e

# Get Keycloak URL from kubectl
KEYCLOAK_SERVICE=$(kubectl get svc -n default -l app.kubernetes.io/name=keycloak -o jsonpath='{.items[0].metadata.name}')
KEYCLOAK_PORT=$(kubectl get svc -n default ${KEYCLOAK_SERVICE} -o jsonpath='{.spec.ports[?(@.name=="http")].port}')
KEYCLOAK_PORT=$(kubectl get svc -n default "${KEYCLOAK_SERVICE}" -o jsonpath='{.spec.ports[?(@.name=="http")].port}')
KEYCLOAK_URL="http://${KEYCLOAK_SERVICE}.default.svc.cluster.local:${KEYCLOAK_PORT}"

# Get admin credentials from inference config
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#!/bin/bash
# Copyright (C) 2025-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

set -e

# Get the absolute path of the finetuning-service root directory
# buildkit is 1 level deep from root
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
export BUILD_CONTEXT="$(cd "$SCRIPT_DIR/.." && pwd)"
BUILD_CONTEXT="$(cd "$SCRIPT_DIR/.." && pwd)"
export BUILD_CONTEXT
export REGISTRY_URL="${REGISTRY_URL:-registry.kube-system.svc.cluster.local:5000}"
export IMAGE_TAG="${IMAGE_TAG:-latest}"
export NAMESPACE="${NAMESPACE:-finetuning}"
Expand Down Expand Up @@ -49,7 +52,7 @@ sleep 3

# Show logs
POD_NAME=""
for i in {1..30}; do
for _ in {1..30}; do
POD_NAME=$(kubectl get pods -n "$NAMESPACE" -l job-name=buildkit-finetuning-service -o jsonpath='{.items[0].metadata.name}' 2>/dev/null || echo "")
if [ -n "$POD_NAME" ]; then
break
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#!/bin/bash
# Copyright (C) 2025-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

set -e

# Get the absolute path of the finetuning-service root directory
# kaniko is 1 level deep from root
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
export BUILD_CONTEXT="$(cd "$SCRIPT_DIR/.." && pwd)"
BUILD_CONTEXT="$(cd "$SCRIPT_DIR/.." && pwd)"
export BUILD_CONTEXT
export REGISTRY_URL="${REGISTRY_URL:-registry.kube-system.svc.cluster.local:5000}"
export IMAGE_TAG="${IMAGE_TAG:-latest}"
export NAMESPACE="${NAMESPACE:-finetuning}"
Expand Down Expand Up @@ -59,7 +62,7 @@ sleep 3

# Show logs
POD_NAME=""
for i in {1..30}; do
for _ in {1..30}; do
POD_NAME=$(kubectl get pods -n "$NAMESPACE" -l job-name=kaniko-finetuning-service -o jsonpath='{.items[0].metadata.name}' 2>/dev/null || echo "")
if [ -n "$POD_NAME" ]; then
break
Expand Down
38 changes: 20 additions & 18 deletions blueprints/finetuning_service/src/api/scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
# Copyright (C) 2025-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
set -e

# Get the directory where this script is located and go to project root
Expand All @@ -25,6 +27,7 @@ if [ ! -f .env ]; then
fi

# Load environment variables
# shellcheck source=/dev/null # generated at runtime by setup.sh
source .env

# Set defaults
Expand Down Expand Up @@ -75,7 +78,7 @@ echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "📦 Step 1: Creating namespace..."
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
kubectl create namespace $NAMESPACE --dry-run=client -o yaml | kubectl apply -f -
kubectl create namespace "$NAMESPACE" --dry-run=client -o yaml | kubectl apply -f -
echo "✓ Namespace ready"
echo ""

Expand All @@ -86,7 +89,7 @@ echo "━━━━━━━━━━━━━━━━━━━━━━━━
if kubectl get secret finetuning-backend-secret -n default >/dev/null 2>&1; then
kubectl get secret finetuning-backend-secret -n default -o yaml \
| sed "s/namespace: default/namespace: $NAMESPACE/" \
| kubectl apply -n $NAMESPACE -f -
| kubectl apply -n "$NAMESPACE" -f -
echo "✓ OIDC secret copied from default namespace"
else
echo "⚠️ Warning: finetuning-backend-secret not found in default namespace"
Expand Down Expand Up @@ -142,17 +145,17 @@ else
echo "Found key: $KEY_FILE"

# Check if secret already exists
if kubectl get secret finetuning-api-tls -n $NAMESPACE >/dev/null 2>&1; then
if kubectl get secret finetuning-api-tls -n "$NAMESPACE" >/dev/null 2>&1; then
echo "Updating existing TLS secret..."
kubectl delete secret finetuning-api-tls -n $NAMESPACE
kubectl delete secret finetuning-api-tls -n "$NAMESPACE"
else
echo "Creating new TLS secret..."
fi

kubectl create secret tls finetuning-api-tls \
--cert="$CERT_FILE" \
--key="$KEY_FILE" \
-n $NAMESPACE
-n "$NAMESPACE"

echo "✓ TLS secret created successfully"
fi
Expand All @@ -172,8 +175,7 @@ export REGISTRY_URL="${REGISTRY_URL:-registry.kube-system.svc.cluster.local:5000
# Run kaniko build
if [ -f ./kaniko/deploy-finetuning.sh ]; then
echo "Building image: $REGISTRY_URL/finetuning-service:$IMAGE_TAG"
./kaniko/deploy-finetuning.sh
if [ $? -ne 0 ]; then
if ! ./kaniko/deploy-finetuning.sh; then
echo "❌ Build failed!"
exit 1
fi
Expand All @@ -189,7 +191,7 @@ echo "🚀 Step 3: Deploying PostgreSQL..."
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"

# Check if PostgreSQL release exists
if helm list -n $NAMESPACE | grep -q "^finetuning-service-postgresql\s"; then
if helm list -n "$NAMESPACE" | grep -q "^finetuning-service-postgresql\s"; then
echo "Upgrading existing PostgreSQL..."
HELM_PG_CMD="upgrade"
else
Expand All @@ -199,7 +201,7 @@ fi

# Deploy PostgreSQL
helm $HELM_PG_CMD finetuning-service-postgresql ./helm-charts/postgresql \
--namespace $NAMESPACE \
--namespace "$NAMESPACE" \
--set auth.password="$POSTGRES_PASSWORD" \
--wait --timeout 5m

Expand All @@ -211,7 +213,7 @@ echo "🚀 Step 4: Deploying Application..."
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"

# Check if release exists
if helm list -n $NAMESPACE | grep -q "^finetuning-service\s"; then
if helm list -n "$NAMESPACE" | grep -q "^finetuning-service\s"; then
echo "Upgrading existing deployment..."
HELM_CMD="upgrade"
else
Expand All @@ -221,7 +223,7 @@ fi

# Deploy with Helm
helm $HELM_CMD finetuning-service ./helm-charts/finetuning-api \
--namespace $NAMESPACE \
--namespace "$NAMESPACE" \
--set secrets.databaseUrl="postgresql://finetuning:$POSTGRES_PASSWORD@finetuning-service-postgresql:5432/finetuning" \
--set secrets.nvidiaApiKey="$NVIDIA_API_KEY" \
--set app.config.nvidiaApiUrl="$NVIDIA_API_URL" \
Expand All @@ -241,18 +243,18 @@ echo "━━━━━━━━━━━━━━━━━━━━━━━━
echo "Waiting for PostgreSQL..."
kubectl wait --for=condition=ready pod \
-l app=postgres \
-n $NAMESPACE \
-n "$NAMESPACE" \
--timeout=300s || true

# Check if database is initialized
POD_NAME=$(kubectl get pods -n $NAMESPACE -l app=postgres -o jsonpath='{.items[0].metadata.name}')
POD_NAME=$(kubectl get pods -n "$NAMESPACE" -l app=postgres -o jsonpath='{.items[0].metadata.name}')
if [ ! -z "$POD_NAME" ]; then
echo "Checking database schema..."
TABLE_COUNT=$(kubectl exec -n $NAMESPACE $POD_NAME -- psql -U finetuning -d finetuning -tAc "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema='public';" 2>/dev/null || echo "0")
TABLE_COUNT=$(kubectl exec -n "$NAMESPACE" "$POD_NAME" -- psql -U finetuning -d finetuning -tAc "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema='public';" 2>/dev/null || echo "0")

if [ "$TABLE_COUNT" = "0" ]; then
echo "Initializing database schema..."
cat "$PROJECT_ROOT/init-db.sql" | kubectl exec -n $NAMESPACE -i $POD_NAME -- psql -U finetuning -d finetuning
cat "$PROJECT_ROOT/init-db.sql" | kubectl exec -n "$NAMESPACE" -i "$POD_NAME" -- psql -U finetuning -d finetuning
echo "✓ Database initialized"
else
echo "✓ Database already initialized ($TABLE_COUNT tables found)"
Expand All @@ -266,7 +268,7 @@ echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "⏳ Step 6: Waiting for application to be ready..."
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
kubectl rollout status deployment/finetuning-service -n $NAMESPACE --timeout=5m
kubectl rollout status deployment/finetuning-service -n "$NAMESPACE" --timeout=5m

echo "✓ Application is ready"
echo ""
Expand All @@ -276,9 +278,9 @@ echo "━━━━━━━━━━━━━━━━━━━━━━━━
echo "📊 Deployment Status"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
kubectl get pods -n $NAMESPACE
kubectl get pods -n "$NAMESPACE"
echo ""
kubectl get ingress -n $NAMESPACE
kubectl get ingress -n "$NAMESPACE"
echo ""

echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
Expand Down
20 changes: 11 additions & 9 deletions blueprints/finetuning_service/src/api/scripts/setup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
# Copyright (C) 2025-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
set -e

# Get the directory where this script is located and go to project root
Expand Down Expand Up @@ -42,28 +44,28 @@ echo ""
echo "🎯 Training Backend Configuration"
echo "This is the URL of your training backend service (e.g., Nvidia GPU server)."
echo ""
read -p "Training Backend URL (e.g., https://training.example.com:8443): " NVIDIA_API_URL
read -r -p "Training Backend URL (e.g., https://training.example.com:8443): " NVIDIA_API_URL
while [ -z "$NVIDIA_API_URL" ]; do
echo "❌ Training Backend URL is required!"
read -p "Training Backend URL: " NVIDIA_API_URL
read -r -p "Training Backend URL: " NVIDIA_API_URL
done

echo ""
read -p "Training Backend API Key: " NVIDIA_API_KEY
read -r -p "Training Backend API Key: " NVIDIA_API_KEY
while [ -z "$NVIDIA_API_KEY" ]; do
echo "❌ Training Backend API Key is required!"
read -p "Training Backend API Key: " NVIDIA_API_KEY
read -r -p "Training Backend API Key: " NVIDIA_API_KEY
done

# Domain Configuration
echo ""
echo "🌐 Domain Configuration"
echo "The API will be accessible at: https://YOUR_DOMAIN/enterprise-ai"
echo ""
read -p "Your domain name (e.g., example.com): " BASE_DOMAIN
read -r -p "Your domain name (e.g., example.com): " BASE_DOMAIN
while [ -z "$BASE_DOMAIN" ]; do
echo "❌ Domain name is required!"
read -p "Your domain name: " BASE_DOMAIN
read -r -p "Your domain name: " BASE_DOMAIN
done

# TLS Certificates Path
Expand All @@ -72,7 +74,7 @@ echo "🔒 TLS Certificates Configuration"
echo "Provide the path to directory containing your TLS certificates."
echo "Expected files: tls.crt (or cert.pem) and tls.key (or key.pem)"
echo ""
read -p "Path to certs directory (default: ../certs): " CERTS_PATH
read -r -p "Path to certs directory (default: ../certs): " CERTS_PATH
CERTS_PATH=${CERTS_PATH:-../certs}

# Validate certs path
Expand All @@ -83,14 +85,14 @@ fi

# Namespace
echo ""
read -p "Kubernetes namespace (default: finetuning): " NAMESPACE
read -r -p "Kubernetes namespace (default: finetuning): " NAMESPACE
NAMESPACE=${NAMESPACE:-finetuning}

# Optional: Dataprep API
echo ""
echo "🔧 Optional: Dataprep API"
echo "If you have a separate dataprep service, provide the URL. Otherwise, leave empty."
read -p "Dataprep API URL (optional, press Enter to skip): " DATAPREP_API_URL
read -r -p "Dataprep API URL (optional, press Enter to skip): " DATAPREP_API_URL

echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!/bin/bash
# Copyright (C) 2025-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
set -e
#sudo apt-get install gettext-base
# Get the absolute path of the dataprep directory
# buildkit/celery is 2 levels deep from dataprep root
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
export BUILD_CONTEXT="$(cd "$SCRIPT_DIR/../.." && pwd)"
BUILD_CONTEXT="$(cd "$SCRIPT_DIR/../.." && pwd)"
export BUILD_CONTEXT
export REGISTRY_URL="${REGISTRY_URL:-registry.kube-system.svc.cluster.local:5000}"

echo "Building with context: $BUILD_CONTEXT"
Expand All @@ -24,7 +27,7 @@ export DB_HOST=postgres.dataprep.svc.cluster.local
export DB_PORT=5432
export DB_NAME=dataprep
export DB_USER=postgres
export DB_PASSWORD=postgres
export DB_PASSWORD="${DB_PASSWORD:-postgres}"
export DB_POOL_SIZE=5
export DB_MAX_OVERFLOW=10

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#!/bin/bash
# Copyright (C) 2025-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

set -e

# Get the absolute path of the dataprep directory
# buildkit/data-prep is 3 levels deep from data-prep-backend root
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
export BUILD_CONTEXT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
BUILD_CONTEXT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
export BUILD_CONTEXT
export REGISTRY_URL="${REGISTRY_URL:-registry.kube-system.svc.cluster.local:5000}"

echo "Building with context: $BUILD_CONTEXT"
Expand All @@ -25,7 +28,7 @@ export DB_HOST=postgres.dataprep.svc.cluster.local
export DB_PORT=5432
export DB_NAME=dataprep
export DB_USER=postgres
export DB_PASSWORD=postgres
export DB_PASSWORD="${DB_PASSWORD:-postgres}"
export DB_POOL_SIZE=5
export DB_MAX_OVERFLOW=10

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!/bin/bash
# Copyright (C) 2025-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
set -e
#sudo apt-get install gettext-base
# Get the absolute path of the dataprep directory
# kaniko/celery is 2 levels deep from dataprep root
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
export BUILD_CONTEXT="$(cd "$SCRIPT_DIR/../.." && pwd)"
BUILD_CONTEXT="$(cd "$SCRIPT_DIR/../.." && pwd)"
export BUILD_CONTEXT
export REGISTRY_URL="${REGISTRY_URL:-registry.kube-system.svc.cluster.local:5000}"

echo "Building with context: $BUILD_CONTEXT"
Expand All @@ -24,7 +27,7 @@ export DB_HOST=postgres.dataprep.svc.cluster.local
export DB_PORT=5432
export DB_NAME=dataprep
export DB_USER=postgres
export DB_PASSWORD=postgres
export DB_PASSWORD="${DB_PASSWORD:-postgres}"
export DB_POOL_SIZE=5
export DB_MAX_OVERFLOW=10

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#!/bin/bash
# Copyright (C) 2025-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

set -e

# Get the absolute path of the dataprep directory
# kaniko/data-prep is 3 levels deep from data-prep-backend root
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
export BUILD_CONTEXT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
BUILD_CONTEXT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
export BUILD_CONTEXT
export REGISTRY_URL="${REGISTRY_URL:-registry.kube-system.svc.cluster.local:5000}"

echo "Building with context: $BUILD_CONTEXT"
Expand All @@ -25,7 +28,7 @@ export DB_HOST=postgres.dataprep.svc.cluster.local
export DB_PORT=5432
export DB_NAME=dataprep
export DB_USER=postgres
export DB_PASSWORD=postgres
export DB_PASSWORD="${DB_PASSWORD:-postgres}"
export DB_POOL_SIZE=5
export DB_MAX_OVERFLOW=10

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#!/bin/bash
# Copyright (C) 2025-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
set -e
#sudo apt-get install gettext-base
# Get the absolute path of the ui directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
export BUILD_CONTEXT="$(cd "$SCRIPT_DIR/../.." && pwd)"
BUILD_CONTEXT="$(cd "$SCRIPT_DIR/../.." && pwd)"
export BUILD_CONTEXT
export REGISTRY_URL="${REGISTRY_URL:-registry.kube-system.svc.cluster.local:5000}"

echo "Building with context: $BUILD_CONTEXT"
Expand Down Expand Up @@ -36,7 +39,7 @@ echo "Monitor with: kubectl logs -f job/buildkit-frontend -n ${NAMESPACE:-finetu

# Wait for pod to start
echo "Waiting for BuildKit pod to start..."
for i in $(seq 1 60); do
for _ in $(seq 1 60); do
POD_NAME=$(kubectl get pods -n "${NAMESPACE:-finetuning-ui}" -l job-name=buildkit-frontend -o jsonpath='{.items[0].metadata.name}' 2>/dev/null || echo "")
if [ -n "$POD_NAME" ]; then
echo "Pod started: $POD_NAME"
Expand Down
Loading
Loading