Add new infra architecture 4
This commit is contained in:
@@ -29,5 +29,4 @@ spec:
|
||||
bindings:
|
||||
- ref: bakery-ia-trigger-binding
|
||||
template:
|
||||
ref: bakery-ia-trigger-template
|
||||
replicas: 1
|
||||
ref: bakery-ia-trigger-template
|
||||
@@ -0,0 +1,46 @@
|
||||
# Tekton Task to Detect Changed Services
|
||||
# This task analyzes git changes to determine which services need to be built
|
||||
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: detect-changed-services
|
||||
namespace: {{ .Values.namespace }}
|
||||
labels:
|
||||
app.kubernetes.io/name: {{ .Values.labels.app.name }}
|
||||
app.kubernetes.io/component: detection
|
||||
spec:
|
||||
workspaces:
|
||||
- name: source
|
||||
description: Workspace containing the source code
|
||||
results:
|
||||
- name: changed-services
|
||||
description: Comma-separated list of changed services
|
||||
steps:
|
||||
- name: detect-changes
|
||||
image: alpine/git
|
||||
script: |
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
cd $(workspaces.source.path)
|
||||
|
||||
# Get the list of changed files
|
||||
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD 2>/dev/null || git diff --name-only $(git rev-parse --abbrev-ref HEAD)@{upstream} HEAD 2>/dev/null || echo "")
|
||||
|
||||
if [ -z "$CHANGED_FILES" ]; then
|
||||
# No changes detected, assume all services need building
|
||||
echo "No git changes detected, building all services"
|
||||
echo "all" > $(results.changed-services.path)
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Extract service names from changed file paths
|
||||
CHANGED_SERVICES=$(echo "$CHANGED_FILES" | grep -o 'services/[^/]*' | sed 's/services\/\//' | sort -u | tr '\n' ',' | sed 's/,$//')
|
||||
|
||||
if [ -z "$CHANGED_SERVICES" ]; then
|
||||
# Changes are in infrastructure or other non-service files
|
||||
echo "infrastructure" > $(results.changed-services.path)
|
||||
else
|
||||
echo "$CHANGED_SERVICES" > $(results.changed-services.path)
|
||||
fi
|
||||
@@ -34,14 +34,28 @@ spec:
|
||||
env:
|
||||
- name: DOCKER_CONFIG
|
||||
value: /tekton/home/.docker
|
||||
command:
|
||||
- /kaniko/executor
|
||||
args:
|
||||
- --dockerfile=$(workspaces.source.path)/Dockerfile
|
||||
- --destination=$(params.registry)/$(params.service):$(params.git-revision)
|
||||
- --context=$(workspaces.source.path)
|
||||
- --cache=true
|
||||
- --cache-repo=$(params.registry)/cache
|
||||
script: |
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Split services parameter by comma
|
||||
IFS=',' read -ra SERVICES <<< "$(params.services)"
|
||||
|
||||
# Build each service
|
||||
for service in "${SERVICES[@]}"; do
|
||||
service=$(echo "$service" | xargs) # Trim whitespace
|
||||
if [ -n "$service" ] && [ "$service" != "none" ]; then
|
||||
echo "Building service: $service"
|
||||
/kaniko/executor \
|
||||
--dockerfile="$(workspaces.source.path)/services/$service/Dockerfile" \
|
||||
--destination="$(params.registry)/$service:$(params.git-revision)" \
|
||||
--context="$(workspaces.source.path)" \
|
||||
--cache=true \
|
||||
--cache-repo="$(params.registry)/cache"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "success" > $(results.build-status.path)
|
||||
resources:
|
||||
limits:
|
||||
cpu: 2000m
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
# Tekton Task for Pipeline Summary
|
||||
# This task generates a summary of the pipeline execution
|
||||
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: pipeline-summary
|
||||
namespace: {{ .Values.namespace }}
|
||||
labels:
|
||||
app.kubernetes.io/name: {{ .Values.labels.app.name }}
|
||||
app.kubernetes.io/component: summary
|
||||
spec:
|
||||
params:
|
||||
- name: changed-services
|
||||
type: string
|
||||
description: Services that were changed
|
||||
- name: git-revision
|
||||
type: string
|
||||
description: Git revision being processed
|
||||
steps:
|
||||
- name: generate-summary
|
||||
image: alpine
|
||||
script: |
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo "=== Bakery-IA CI Pipeline Summary ==="
|
||||
echo "Git Revision: $(params.git-revision)"
|
||||
echo "Changed Services: $(params.changed-services)"
|
||||
echo "Pipeline completed successfully"
|
||||
|
||||
# Log summary to stdout for visibility
|
||||
echo "Summary generated"
|
||||
@@ -1,24 +0,0 @@
|
||||
# Test values for Tekton Helm chart
|
||||
# This file overrides default values for testing purposes
|
||||
|
||||
# Use a test namespace
|
||||
namespace: "tekton-test"
|
||||
|
||||
# Test registry URL
|
||||
global:
|
||||
registry:
|
||||
url: "localhost:5000"
|
||||
|
||||
# Test secrets
|
||||
secrets:
|
||||
webhook:
|
||||
token: "test-webhook-token"
|
||||
|
||||
registry:
|
||||
username: "test-user"
|
||||
password: "test-password"
|
||||
registryUrl: "localhost:5000"
|
||||
|
||||
git:
|
||||
username: "test-git-user"
|
||||
password: "test-git-password"
|
||||
Reference in New Issue
Block a user