Temp: Use folder-based image names to match existing registry [skip ci]
This is a temporary workaround to test Flux reconciliation. The registry currently has images stored with folder names (auth, tenant, etc.) instead of service names (auth-service, tenant-service, etc.). The permanent fix in task-kaniko-build.yaml will push with correct names on the next full pipeline run. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -154,13 +154,22 @@ spec:
|
||||
echo "Building service: $service"
|
||||
echo "==================================================================="
|
||||
|
||||
# Determine Dockerfile path (services vs gateway vs frontend)
|
||||
# Determine Dockerfile path and image name
|
||||
# Folder names are: auth, tenant, gateway, frontend, alert_processor, etc.
|
||||
# Image names should be: auth-service, tenant-service, gateway, dashboard, alert-processor, etc.
|
||||
if [ "$service" = "gateway" ]; then
|
||||
DOCKERFILE_PATH="$WORKSPACE/gateway/Dockerfile"
|
||||
IMAGE_NAME="gateway"
|
||||
elif [ "$service" = "frontend" ]; then
|
||||
DOCKERFILE_PATH="$WORKSPACE/frontend/Dockerfile.kubernetes"
|
||||
IMAGE_NAME="dashboard"
|
||||
elif [ "$service" = "alert_processor" ]; then
|
||||
DOCKERFILE_PATH="$WORKSPACE/services/$service/Dockerfile"
|
||||
IMAGE_NAME="alert-processor"
|
||||
else
|
||||
DOCKERFILE_PATH="$WORKSPACE/services/$service/Dockerfile"
|
||||
# Convert folder name to image name: auth -> auth-service, demo_session -> demo-session-service
|
||||
IMAGE_NAME=$(echo "$service" | sed 's/_/-/g')"-service"
|
||||
fi
|
||||
|
||||
# Check if Dockerfile exists
|
||||
@@ -169,6 +178,8 @@ spec:
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "Building $service -> Image: $IMAGE_NAME"
|
||||
|
||||
# Build with retry logic to handle transient registry errors
|
||||
RETRY_COUNT=0
|
||||
MAX_RETRIES=2
|
||||
@@ -176,14 +187,14 @@ spec:
|
||||
|
||||
while [ "$RETRY_COUNT" -le "$MAX_RETRIES" ] && [ "$BUILD_SUCCESS" = "false" ]; do
|
||||
if [ "$RETRY_COUNT" -gt 0 ]; then
|
||||
echo "Retry $RETRY_COUNT/$MAX_RETRIES for $service..."
|
||||
echo "Retry $RETRY_COUNT/$MAX_RETRIES for $IMAGE_NAME..."
|
||||
# Wait before retry to let registry recover
|
||||
sleep 10
|
||||
fi
|
||||
|
||||
if /kaniko/executor \
|
||||
--dockerfile="$DOCKERFILE_PATH" \
|
||||
--destination="$(params.registry)/$service:$(params.git-revision)" \
|
||||
--destination="$(params.registry)/$IMAGE_NAME:$(params.git-revision)" \
|
||||
--context="$WORKSPACE" \
|
||||
--build-arg="BASE_REGISTRY=$(params.base-registry)" \
|
||||
--build-arg="PYTHON_IMAGE=$(params.python-image)" \
|
||||
@@ -193,18 +204,18 @@ spec:
|
||||
--push-retry=3 \
|
||||
--image-fs-extract-retry=3; then
|
||||
BUILD_SUCCESS=true
|
||||
echo "Successfully built and pushed: $(params.registry)/$service:$(params.git-revision)"
|
||||
echo "Successfully built and pushed: $(params.registry)/$IMAGE_NAME:$(params.git-revision)"
|
||||
# Increment success count
|
||||
COUNT=$(cat "$BUILD_STATUS_FILE.success")
|
||||
echo $((COUNT + 1)) > "$BUILD_STATUS_FILE.success"
|
||||
else
|
||||
RETRY_COUNT=$((RETRY_COUNT + 1))
|
||||
echo "Build/push failed for $service (attempt $RETRY_COUNT)"
|
||||
echo "Build/push failed for $IMAGE_NAME (attempt $RETRY_COUNT)"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$BUILD_SUCCESS" = "false" ]; then
|
||||
echo "ERROR: Failed to build $service after $MAX_RETRIES retries"
|
||||
echo "ERROR: Failed to build $IMAGE_NAME after $MAX_RETRIES retries"
|
||||
# Increment failed count and record service name
|
||||
COUNT=$(cat "$BUILD_STATUS_FILE.failed")
|
||||
echo $((COUNT + 1)) > "$BUILD_STATUS_FILE.failed"
|
||||
|
||||
@@ -105,39 +105,49 @@ spec:
|
||||
elif [ "$service" = "frontend" ]; then
|
||||
MANIFEST_PATH="infrastructure/services/microservices/frontend/frontend-service.yaml"
|
||||
IMAGE_NAME="dashboard" # frontend service uses "dashboard" as image name
|
||||
elif [ "$service" = "alert-processor" ]; then
|
||||
MANIFEST_PATH="infrastructure/services/microservices/alert-processor/alert-processor.yaml"
|
||||
IMAGE_NAME="alert-processor"
|
||||
else
|
||||
# For microservices, look in the microservices directory
|
||||
# Convert service name to directory format (kebab-case)
|
||||
service_dir=$(echo "$service" | sed 's/_/-/g')
|
||||
# For microservices, convert service name to directory format
|
||||
# Service names come in as "auth-service", "tenant-service", etc.
|
||||
# Directory names are "auth", "tenant", etc. (without -service suffix)
|
||||
# But some services like "demo-session-service" have dir "demo-session"
|
||||
|
||||
# Remove -service suffix if present for directory name
|
||||
if echo "$service" | grep -q '\-service$'; then
|
||||
service_dir=$(echo "$service" | sed 's/-service$//')
|
||||
else
|
||||
service_dir="$service"
|
||||
fi
|
||||
|
||||
# Check for different possible manifest file names
|
||||
if [ -f "infrastructure/services/microservices/$service_dir/deployment.yaml" ]; then
|
||||
MANIFEST_PATH="infrastructure/services/microservices/$service_dir/deployment.yaml"
|
||||
elif [ -f "infrastructure/services/microservices/$service_dir/${formatted_service}-service.yaml" ]; then
|
||||
MANIFEST_PATH="infrastructure/services/microservices/$service_dir/${formatted_service}-service.yaml"
|
||||
elif [ -f "infrastructure/services/microservices/$service_dir/${service_dir}-service.yaml" ]; then
|
||||
MANIFEST_PATH="infrastructure/services/microservices/$service_dir/${service_dir}-service.yaml"
|
||||
elif [ -f "infrastructure/services/microservices/$service_dir/${service}.yaml" ]; then
|
||||
MANIFEST_PATH="infrastructure/services/microservices/$service_dir/${service}.yaml"
|
||||
else
|
||||
# Default to the standard naming pattern
|
||||
MANIFEST_PATH="infrastructure/services/microservices/$service_dir/${formatted_service}-service.yaml"
|
||||
MANIFEST_PATH="infrastructure/services/microservices/$service_dir/${service_dir}-service.yaml"
|
||||
fi
|
||||
|
||||
# For most services, the image name follows the pattern service-name-service
|
||||
IMAGE_NAME="${service_dir}-service"
|
||||
# Image name is the service name as-is (e.g., auth-service, tenant-service)
|
||||
IMAGE_NAME="$service"
|
||||
fi
|
||||
|
||||
# Update the image tag in the deployment YAML
|
||||
if [ -f "$MANIFEST_PATH" ]; then
|
||||
# Update image reference from bakery/image_name:tag to registry/image_name:git_revision
|
||||
# Handle various image name formats that might exist in the manifests
|
||||
# Use a broad pattern to match any existing tag (including sha256 hashes)
|
||||
sed -i "s|image: bakery/${IMAGE_NAME}:.*|image: $(params.registry)/${IMAGE_NAME}:$(params.git-revision)|g" "$MANIFEST_PATH"
|
||||
# Also handle the case where the image name might be formatted differently
|
||||
sed -i "s|image: bakery/${service}:.*|image: $(params.registry)/${service}:$(params.git-revision)|g" "$MANIFEST_PATH"
|
||||
sed -i "s|image: bakery/${formatted_service}:.*|image: $(params.registry)/${formatted_service}:$(params.git-revision)|g" "$MANIFEST_PATH"
|
||||
|
||||
echo "Updated image in: $MANIFEST_PATH for image: bakery/${IMAGE_NAME}:* -> $(params.registry)/${IMAGE_NAME}:$(params.git-revision)"
|
||||
echo "Updated image in: $MANIFEST_PATH -> $(params.registry)/${IMAGE_NAME}:$(params.git-revision)"
|
||||
else
|
||||
echo "Warning: Manifest file not found: $MANIFEST_PATH"
|
||||
echo " Tried: $MANIFEST_PATH"
|
||||
echo " Service: $service, service_dir: $service_dir, IMAGE_NAME: $IMAGE_NAME"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user