Adding workflow for inventory microservice
All checks were successful
Deploy Promiscuity Auth API / deploy (push) Successful in 1m6s
Deploy Promiscuity Character API / deploy (push) Successful in 48s
Deploy Promiscuity Inventory API / deploy (push) Successful in 1m42s
Deploy Promiscuity Locations API / deploy (push) Successful in 47s
k8s smoke test / test (push) Successful in 7s
All checks were successful
Deploy Promiscuity Auth API / deploy (push) Successful in 1m6s
Deploy Promiscuity Character API / deploy (push) Successful in 48s
Deploy Promiscuity Inventory API / deploy (push) Successful in 1m42s
Deploy Promiscuity Locations API / deploy (push) Successful in 47s
k8s smoke test / test (push) Successful in 7s
This commit is contained in:
parent
9a7d6544ef
commit
5287ecd56f
112
.gitea/workflows/deploy-inventory.yml
Normal file
112
.gitea/workflows/deploy-inventory.yml
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
name: Deploy Promiscuity Inventory API
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
workflow_dispatch: {}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: self-hosted
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE_NAME: promiscuity-inventory:latest
|
||||||
|
IMAGE_TAR: /tmp/promiscuity-inventory.tar
|
||||||
|
# All nodes that might run the pod (control-plane + workers)
|
||||||
|
NODES: "192.168.86.72 192.168.86.73 192.168.86.74"
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repo
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# -----------------------------
|
||||||
|
# Build Docker image
|
||||||
|
# -----------------------------
|
||||||
|
- name: Build Docker image
|
||||||
|
run: |
|
||||||
|
cd microservices/InventoryApi
|
||||||
|
docker build -t "${IMAGE_NAME}" .
|
||||||
|
|
||||||
|
# -----------------------------
|
||||||
|
# Save image as TAR on runner
|
||||||
|
# -----------------------------
|
||||||
|
- name: Save Docker image to TAR
|
||||||
|
run: |
|
||||||
|
docker save "${IMAGE_NAME}" -o "${IMAGE_TAR}"
|
||||||
|
|
||||||
|
# -----------------------------
|
||||||
|
# Copy TAR to each Kubernetes node
|
||||||
|
# -----------------------------
|
||||||
|
- name: Copy TAR to nodes
|
||||||
|
run: |
|
||||||
|
for node in ${NODES}; do
|
||||||
|
echo "Copying image tar to $node ..."
|
||||||
|
scp -o StrictHostKeyChecking=no "${IMAGE_TAR}" hz@"$node":/tmp/promiscuity-inventory.tar
|
||||||
|
done
|
||||||
|
|
||||||
|
# -----------------------------
|
||||||
|
# Import image into containerd on each node
|
||||||
|
# -----------------------------
|
||||||
|
- name: Import image on nodes
|
||||||
|
run: |
|
||||||
|
for node in ${NODES}; do
|
||||||
|
echo "Importing image on $node ..."
|
||||||
|
ssh -o StrictHostKeyChecking=no hz@"$node" "sudo ctr -n k8s.io images import /tmp/promiscuity-inventory.tar"
|
||||||
|
done
|
||||||
|
|
||||||
|
# -----------------------------
|
||||||
|
# CLEANUP: delete TAR from nodes
|
||||||
|
# -----------------------------
|
||||||
|
- name: Clean TAR from nodes
|
||||||
|
run: |
|
||||||
|
for node in ${NODES}; do
|
||||||
|
echo "Removing image tar on $node ..."
|
||||||
|
ssh -o StrictHostKeyChecking=no hz@"$node" "rm -f /tmp/promiscuity-inventory.tar"
|
||||||
|
done
|
||||||
|
|
||||||
|
# -----------------------------
|
||||||
|
# CLEANUP: delete TAR from runner
|
||||||
|
# -----------------------------
|
||||||
|
- name: Clean TAR on runner
|
||||||
|
run: |
|
||||||
|
rm -f "${IMAGE_TAR}"
|
||||||
|
|
||||||
|
# -----------------------------
|
||||||
|
# Write kubeconfig from secret
|
||||||
|
# -----------------------------
|
||||||
|
- name: Write kubeconfig from secret
|
||||||
|
env:
|
||||||
|
KUBECONFIG_CONTENT: ${{ secrets.KUBECONFIG }}
|
||||||
|
run: |
|
||||||
|
mkdir -p /tmp/kube
|
||||||
|
printf '%s\n' "$KUBECONFIG_CONTENT" > /tmp/kube/config
|
||||||
|
|
||||||
|
# -----------------------------
|
||||||
|
# Ensure namespace exists
|
||||||
|
# -----------------------------
|
||||||
|
- name: Create namespace if missing
|
||||||
|
env:
|
||||||
|
KUBECONFIG: /tmp/kube/config
|
||||||
|
run: |
|
||||||
|
kubectl create namespace promiscuity-inventory --dry-run=client -o yaml | kubectl apply -f -
|
||||||
|
|
||||||
|
# -----------------------------
|
||||||
|
# Apply Kubernetes manifests
|
||||||
|
# -----------------------------
|
||||||
|
- name: Apply Inventory deployment & service
|
||||||
|
env:
|
||||||
|
KUBECONFIG: /tmp/kube/config
|
||||||
|
run: |
|
||||||
|
kubectl apply -f microservices/InventoryApi/k8s/deployment.yaml -n promiscuity-inventory
|
||||||
|
kubectl apply -f microservices/InventoryApi/k8s/service.yaml -n promiscuity-inventory
|
||||||
|
|
||||||
|
# -----------------------------
|
||||||
|
# Rollout restart & wait
|
||||||
|
# -----------------------------
|
||||||
|
- name: Restart Inventory deployment
|
||||||
|
env:
|
||||||
|
KUBECONFIG: /tmp/kube/config
|
||||||
|
run: |
|
||||||
|
kubectl rollout restart deployment/promiscuity-inventory -n promiscuity-inventory
|
||||||
|
kubectl rollout status deployment/promiscuity-inventory -n promiscuity-inventory
|
||||||
Loading…
x
Reference in New Issue
Block a user