-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e7b9d01
commit 0d85a44
Showing
6 changed files
with
90 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,27 @@ | ||
kubectl apply -f deploy_nodeport.yaml | ||
|
||
get_ready_replicas() { | ||
kubectl get deployment "$DEPLOYMENT_NAME" -n "$NAMESPACE" -o jsonpath='{.status.readyReplicas}' | ||
} | ||
|
||
# Wait until all pods are ready | ||
log_with_color "Waiting for pods of deployment '$DEPLOYMENT_NAME' in namespace '$NAMESPACE' to become ready..." yellow | ||
while true; do | ||
READY_REPLICAS=$(get_ready_replicas) | ||
|
||
# Check if the ready replicas count is non-empty and greater than 0 | ||
if [[ "$READY_REPLICAS" != "" && "$READY_REPLICAS" -gt 0 ]]; then | ||
TOTAL_REPLICAS=$(kubectl get deployment "$DEPLOYMENT_NAME" -n "$NAMESPACE" -o jsonpath='{.spec.replicas}') | ||
|
||
if [[ "$READY_REPLICAS" == "$TOTAL_REPLICAS" ]]; then | ||
log_with_color "All $READY_REPLICAS pods are ready." green | ||
break | ||
else | ||
log_with_color "$READY_REPLICAS out of $TOTAL_REPLICAS pods are ready. Waiting..." yellow | ||
fi | ||
else | ||
log_with_color "No pods are ready yet. Waiting..." red | ||
fi | ||
|
||
sleep "$CHECK_INTERVAL" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
log_with_color() { | ||
local text="$1" | ||
local color="$2" | ||
local color_code="" | ||
|
||
case $color in | ||
red) | ||
color_code="0;31" # Red | ||
;; | ||
green) | ||
color_code="0;32" # Green | ||
;; | ||
blue) | ||
color_code="0;34" # Blue | ||
;; | ||
yellow) | ||
color_code="0;33" # Yellow | ||
;; | ||
light) | ||
color_code="1;37" # Light (White) | ||
;; | ||
gray) | ||
color_code="2;37" # Gray (White) | ||
;; | ||
*) | ||
color_code="0" # Default color | ||
;; | ||
esac | ||
|
||
echo -e "\e[${color_code}m${text}\e[0m" | ||
} |