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
|
@ -9,7 +9,7 @@ spec:
|
|||||||
dependencies:
|
dependencies:
|
||||||
- name: gitea-push
|
- name: gitea-push
|
||||||
eventSourceName: webhook
|
eventSourceName: webhook
|
||||||
eventName: test-hook
|
eventName: user-microservice
|
||||||
triggers:
|
triggers:
|
||||||
- template:
|
- template:
|
||||||
name: trigger-build-workflow
|
name: trigger-build-workflow
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
apiVersion: argoproj.io/v1alpha1
|
apiVersion: argoproj.io/v1alpha1
|
||||||
kind: EventSource
|
kind: EventSource
|
||||||
metadata:
|
metadata:
|
||||||
name: webhook
|
name: webhook-build
|
||||||
namespace: argo-events
|
namespace: argo-events
|
||||||
spec:
|
spec:
|
||||||
service:
|
service:
|
||||||
@ -9,7 +9,11 @@ spec:
|
|||||||
- port: 12000
|
- port: 12000
|
||||||
targetPort: 12000
|
targetPort: 12000
|
||||||
webhook:
|
webhook:
|
||||||
test-hook:
|
user-microservice:
|
||||||
endpoint: /gitea-hook
|
endpoint: /user-microservice
|
||||||
method: POST
|
method: POST
|
||||||
port: "12000"
|
port: "12000"
|
||||||
|
user-microservice-deploy:
|
||||||
|
endpoint: /user-microservice-deploy
|
||||||
|
method: POST
|
||||||
|
port: "12000"
|
@ -11,7 +11,14 @@ spec:
|
|||||||
- host: argo-hook.marcin00.pl
|
- host: argo-hook.marcin00.pl
|
||||||
http:
|
http:
|
||||||
paths:
|
paths:
|
||||||
- path: /gitea-hook
|
- path: /user-microservice
|
||||||
|
pathType: Prefix
|
||||||
|
backend:
|
||||||
|
service:
|
||||||
|
name: webhook-eventsource-svc
|
||||||
|
port:
|
||||||
|
number: 12000
|
||||||
|
- path: /user-microservice-deploy
|
||||||
pathType: Prefix
|
pathType: Prefix
|
||||||
backend:
|
backend:
|
||||||
service:
|
service:
|
||||||
|
Reference in New Issue
Block a user