Skip to content

Commit 7580e68

Browse files
committed
Added conditional PVC
1 parent 65ee5fc commit 7580e68

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

.github/workflows/deploy-azure.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,19 +115,33 @@ jobs:
115115
cat infra/k8s/memgraph.yaml | \
116116
sed "s/\${CREDENTIALS_HASH}/$CREDENTIALS_HASH/g" | \
117117
sed "s/\${ENVIRONMENT}/${{ env.ENVIRONMENT }}/g" > memgraph_deploy.yaml
118-
119-
# Apply the updated deployment manifest
120-
kubectl apply -f memgraph_deploy.yaml
121-
118+
119+
# Split the manifest into PVC and non-PVC resources
120+
csplit -z -f part_ memgraph_deploy.yaml "/^---$/" '{*}'
121+
122+
# Apply PVCs only if they do not exist
123+
for f in part_*; do
124+
if grep -q 'kind: PersistentVolumeClaim' "$f"; then
125+
PVC_NAME=$(grep 'name:' "$f" | head -1 | awk '{print $2}')
126+
if kubectl get pvc "$PVC_NAME" &>/dev/null; then
127+
echo "PVC $PVC_NAME already exists, skipping creation."
128+
else
129+
kubectl apply -f "$f"
130+
fi
131+
else
132+
kubectl apply -f "$f"
133+
fi
134+
done
135+
122136
# Force restart if the deployment already exists
123137
POD_NAME=$(kubectl get pods -l app=memgraph -o jsonpath="{.items[0].metadata.name}" 2>/dev/null || echo "")
124138
if [[ -n "$POD_NAME" ]]; then
125139
echo "Forcing restart of existing Memgraph pod..."
126140
kubectl delete pod $POD_NAME
127141
fi
128-
129-
# Remove the temporary file
130-
rm memgraph_deploy.yaml
142+
143+
# Remove the temporary files
144+
rm memgraph_deploy.yaml part_*
131145
132146
- name: Verify Deployment
133147
run: |

0 commit comments

Comments
 (0)