-
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.
fix(#28): enable yugabyte deployment sandbox by adjusting script
- separate out gorm database creation - add some notes about working with yugabyte
- Loading branch information
Showing
4 changed files
with
70 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
export NAMESPACE=$1 | ||
|
||
if [ -z "$NAMESPACE" ]; then | ||
echo "Usage: $0 <namespace>" | ||
exit 1 | ||
fi | ||
|
||
hostname="yb-tserver-0.yb-tservers.$NAMESPACE" | ||
sleep_seconds=5 | ||
retries=24 | ||
attempt=1 | ||
|
||
check_connectivity() { | ||
echo "Checking DB Connectivity for $1" | ||
if kubectl exec --namespace "${NAMESPACE}" -it yb-tserver-0 -c yb-tserver -- ysqlsh -h "$1" -c '\q'; then | ||
echo "Connection successful" | ||
return 0 | ||
else | ||
echo "Connection failed" | ||
return 1 | ||
fi | ||
} | ||
|
||
while [ $attempt -le $retries ]; do | ||
if check_connectivity "$hostname"; then | ||
break | ||
fi | ||
echo "Attempt $attempt of $retries failed." | ||
if [ $attempt -eq $retries ]; then | ||
echo "All attempts failed. Exiting..." | ||
exit 1 | ||
fi | ||
sleep $sleep_seconds | ||
((attempt++)) | ||
done | ||
|
||
result=$(kubectl exec -n "${NAMESPACE}" -it yb-tserver-0 -c yb-tserver -- ysqlsh -U yugabyte -h "$hostname" -tc "SELECT 1 FROM pg_database WHERE datname = 'gorm'") | ||
exists=$(echo "$result" | tr -d '[:space:]') | ||
|
||
if [[ "$exists" == "1" ]]; then | ||
echo "Database gorm already exists" | ||
else | ||
echo "Creating database gorm" | ||
kubectl exec -n "${NAMESPACE}" -it yb-tserver-0 -c yb-tserver -- ysqlsh -U yugabyte -h "$hostname" -c "CREATE DATABASE gorm" | ||
fi |
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,15 @@ | ||
## Yugabyte deployment | ||
|
||
This directory holds the output of templating the yugabyte helm chart values | ||
from the script `scripts/yugabyte-*.sh` | ||
|
||
The `yugabyte-*.sh` scripts are used to generate the `yugabyte.yaml` file | ||
which is then used to deploy yugabyte on the kubernetes cluster. | ||
|
||
## Steps to deploy yugabyte on kubernetes manually | ||
|
||
For example, if experimenting with our sandbox cluster: | ||
|
||
1. Run the script `scripts/yugabyte-single-az.sh us-east-2 $NAMESPACE sandbox` | ||
2. check for connectivity `kubectl exec --namespace $NAMESPACE -it yb-tserver-0 -- /home/yugabyte/bin/ysqlsh -h yb-tserver-0.yb-tservers.$NAMESPACE` | ||
3. Optionally, create the gorm database `scripts/create-gorm-db.sh $NAMESPACE` |