Skip to content

Commit

Permalink
trying again
Browse files Browse the repository at this point in the history
this time with exit code strategy though deploy script
  • Loading branch information
EvilGenius13 committed Sep 17, 2024
1 parent 9c1dd5e commit c90bceb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 33 deletions.
4 changes: 1 addition & 3 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ steps:
- cd Anonymoose
- scripts/deploy.sh
- |
EXIT_STATUS=$?
echo "Buildkite command exit status: $EXIT_STATUS"
if [ "$EXIT_STATUS" -eq 0 ]; then
if [ $? -eq 0 ]; then
curl -X POST "${DISCORD_WEBHOOK_URL}" \
-H "Content-Type: application/json" \
-d '{"content": "Deployment successful :rocket:"}'
Expand Down
43 changes: 13 additions & 30 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,26 @@ export KUBECONFIG=/home/ubuntu/.kube/config
if [ -d "$REPO_DIR" ]; then
echo "Repository already exists. Pulling the latest changes..."
cd $REPO_DIR
git pull origin main
git pull origin main || exit 1
else
echo "Cloning the repository..."
git clone $REPO_URL
git clone $REPO_URL || exit 1
cd $REPO_DIR
fi

# Debugging and clarity
pwd
ls -R

# Print the contents of the KUBECONFIG file
echo "Contents of KUBECONFIG ($KUBECONFIG):"
cat $KUBECONFIG

# Debugging step to ensure KUBECONFIG is set correctly
echo "Using KUBECONFIG: $KUBECONFIG"
kubectl config view

# Print the current context
echo "Current context:"
kubectl config current-context

# Verify kubectl can connect to the cluster
echo "Getting nodes:"
kubectl get nodes

# Apply Kubernetes manifests regardless of changes
# Apply Kubernetes manifests
echo "Applying Kubernetes manifests..."
kubectl apply -f deployment/production/minio-pv-pvc.yml -n ${NAMESPACE}
kubectl apply -f deployment/production/memcache_deployment.yml -n ${NAMESPACE}
kubectl apply -f deployment/production/minio_deployment.yml -n ${NAMESPACE}
kubectl apply -f deployment/production/app_deployment.yml -n ${NAMESPACE}
kubectl apply -f deployment/production/minio-pv-pvc.yml -n ${NAMESPACE} || exit 1
kubectl apply -f deployment/production/memcache_deployment.yml -n ${NAMESPACE} || exit 1
kubectl apply -f deployment/production/minio_deployment.yml -n ${NAMESPACE} || exit 1
kubectl apply -f deployment/production/app_deployment.yml -n ${NAMESPACE} || exit 1

# Always set the image to the latest version
# Update the deployment image
echo "Updating deployment image..."
kubectl set image deployment/${DEPLOYMENT_NAME} ${CONTAINER_NAME}=${IMAGE} -n ${NAMESPACE}
kubectl set image deployment/${DEPLOYMENT_NAME} ${CONTAINER_NAME}=${IMAGE} -n ${NAMESPACE} || exit 1

# Optional: restart the deployment to ensure it picks up the new image
kubectl rollout restart deployment/${DEPLOYMENT_NAME} -n ${NAMESPACE}
kubectl rollout restart deployment/${DEPLOYMENT_NAME} -n ${NAMESPACE} || exit 1

echo "Deployment successful!"
exit 0

0 comments on commit c90bceb

Please sign in to comment.