Added second webhook to separate deploy repo
This commit is contained in:
109
argo-workflows/deploy-sensor.yaml
Normal file
109
argo-workflows/deploy-sensor.yaml
Normal file
@ -0,0 +1,109 @@
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: Sensor
|
||||
metadata:
|
||||
name: webhook-deploy
|
||||
namespace: argo-events
|
||||
spec:
|
||||
template:
|
||||
serviceAccountName: operate-workflow-sa
|
||||
dependencies:
|
||||
- name: gitea-push
|
||||
eventSourceName: webhook
|
||||
eventName: user-microservice-deploy
|
||||
triggers:
|
||||
- template:
|
||||
name: deploy-user-microservice
|
||||
k8s:
|
||||
operation: create
|
||||
source:
|
||||
resource:
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: Workflow
|
||||
metadata:
|
||||
generateName: deploy-user-microservice-
|
||||
spec:
|
||||
entrypoint: main
|
||||
serviceAccountName: operate-workflow-sa
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: workspace
|
||||
spec:
|
||||
accessModes: ["ReadWriteOnce"]
|
||||
resources:
|
||||
requests:
|
||||
storage: 128Mi
|
||||
templates:
|
||||
- name: main
|
||||
steps:
|
||||
- - name: checkout
|
||||
template: checkout
|
||||
- - name: deploy
|
||||
template: deploy
|
||||
|
||||
- name: checkout
|
||||
container:
|
||||
image: alpine/git
|
||||
command: [sh, -c]
|
||||
workingDir: /workspace
|
||||
env:
|
||||
- name: REPO_URL
|
||||
value: https://gitea.marcin00.pl/pikram/user-microservice-deploy.git
|
||||
- name: REPO_BRANCH
|
||||
value: argo-deploy
|
||||
args:
|
||||
- |
|
||||
git clone --depth 1 --branch "${REPO_BRANCH}" --single-branch "${REPO_URL}" repo
|
||||
volumeMounts:
|
||||
- name: workspace
|
||||
mountPath: /workspace
|
||||
|
||||
- name: deploy
|
||||
container:
|
||||
image: marcin00.azurecr.io/azure-cli-kubectl:latest
|
||||
command: [sh, -c]
|
||||
workingDir: /workspace/repo
|
||||
env:
|
||||
- name: CLIENT_ID
|
||||
value: "c302726f-fafb-4143-94c1-67a70975574a"
|
||||
- name: CLUSTER_NAME
|
||||
value: "build"
|
||||
- name: RESOURCE_GROUP
|
||||
value: "tst-aks-rg"
|
||||
- name: DEPLOY_FILES
|
||||
value: "namespace.yaml secret-store.yaml deploy.yaml ingress.yaml"
|
||||
- name: DEPLOYMENT
|
||||
value: "api"
|
||||
- name: NAMESPACE
|
||||
value: "user-microservice"
|
||||
- name: HEALTHCHECK_URL
|
||||
value: "https://user-microservice.marcin00.pl/health"
|
||||
args:
|
||||
- |
|
||||
echo "===> Logging in to Azure"
|
||||
az login --identity --client-id $CLIENT_ID
|
||||
az aks get-credentials --resource-group $RESOURCE_GROUP --name $CLUSTER_NAME --overwrite-existing
|
||||
kubelogin convert-kubeconfig -l azurecli
|
||||
|
||||
echo "===> Applying Kubernetes manifests"
|
||||
for file in $DEPLOY_FILES; do
|
||||
kubectl apply -f "$file"
|
||||
done
|
||||
|
||||
echo "===> Waiting for deployment to complete"
|
||||
kubectl rollout status deployment/$DEPLOYMENT -n $NAMESPACE --timeout=60s
|
||||
|
||||
echo "===> Running health check"
|
||||
for i in $(seq 1 120); do
|
||||
if curl -sf $HEALTHCHECK_URL; then
|
||||
echo "Health check OK"
|
||||
exit 0
|
||||
else
|
||||
echo "Health check failed. Retry $i..."
|
||||
sleep 5
|
||||
fi
|
||||
done
|
||||
echo "Health check failed"
|
||||
exit 1
|
||||
volumeMounts:
|
||||
- name: workspace
|
||||
mountPath: /workspace
|
Reference in New Issue
Block a user