Add ci/cd and fix multiple pods issues
This commit is contained in:
66
infrastructure/ci-cd/tekton/tasks/update-gitops.yaml
Normal file
66
infrastructure/ci-cd/tekton/tasks/update-gitops.yaml
Normal file
@@ -0,0 +1,66 @@
|
||||
# Tekton Update GitOps Manifests Task for Bakery-IA CI/CD
|
||||
# This task updates Kubernetes manifests with new image tags
|
||||
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
kind: Task
|
||||
metadata:
|
||||
name: update-gitops
|
||||
namespace: tekton-pipelines
|
||||
spec:
|
||||
workspaces:
|
||||
- name: source
|
||||
params:
|
||||
- name: services
|
||||
type: string
|
||||
description: Comma-separated list of services to update
|
||||
- name: registry
|
||||
type: string
|
||||
description: Container registry URL
|
||||
- name: git-revision
|
||||
type: string
|
||||
description: Git revision for image tag
|
||||
steps:
|
||||
- name: update-manifests
|
||||
image: bitnami/kubectl
|
||||
script: |
|
||||
#!/bin/sh
|
||||
set -e
|
||||
cd $(workspaces.source.path)
|
||||
|
||||
echo "Updating GitOps manifests for services: $(params.services)"
|
||||
|
||||
# Split services by comma
|
||||
IFS=',' read -ra SERVICES <<< "$(params.services)"
|
||||
|
||||
for service in "${SERVICES[@]}"; do
|
||||
echo "Processing service: $service"
|
||||
|
||||
# Find and update Kubernetes manifests
|
||||
if [ "$service" = "frontend" ]; then
|
||||
# Update frontend deployment
|
||||
if [ -f "infrastructure/kubernetes/overlays/prod/frontend-deployment.yaml" ]; then
|
||||
sed -i "s|image:.*|image: $(params.registry)/bakery/frontend:$(params.git-revision)|g" \
|
||||
"infrastructure/kubernetes/overlays/prod/frontend-deployment.yaml"
|
||||
fi
|
||||
elif [ "$service" = "gateway" ]; then
|
||||
# Update gateway deployment
|
||||
if [ -f "infrastructure/kubernetes/overlays/prod/gateway-deployment.yaml" ]; then
|
||||
sed -i "s|image:.*|image: $(params.registry)/bakery/gateway:$(params.git-revision)|g" \
|
||||
"infrastructure/kubernetes/overlays/prod/gateway-deployment.yaml"
|
||||
fi
|
||||
else
|
||||
# Update service deployment
|
||||
DEPLOYMENT_FILE="infrastructure/kubernetes/overlays/prod/${service}-deployment.yaml"
|
||||
if [ -f "$DEPLOYMENT_FILE" ]; then
|
||||
sed -i "s|image:.*|image: $(params.registry)/bakery/${service}:$(params.git-revision)|g" \
|
||||
"$DEPLOYMENT_FILE"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Commit changes
|
||||
git config --global user.name "bakery-ia-ci"
|
||||
git config --global user.email "ci@bakery-ia.local"
|
||||
git add .
|
||||
git commit -m "CI: Update image tags for $(params.services) to $(params.git-revision)"
|
||||
git push origin HEAD
|
||||
Reference in New Issue
Block a user