-
Notifications
You must be signed in to change notification settings - Fork 0
/
start-k8s-shiny
executable file
·31 lines (24 loc) · 1.09 KB
/
start-k8s-shiny
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env bash
set -eu
# example use case: ./start-k8s-shiny production
# Set the environment variable to the first command-line argument or default to 'testing'
ENV=${1:-testing}
if [[ "$ENV" != "testing" && "$ENV" != "production" ]]; then
echo "Error: env must be either 'testing' or 'production'"
exit 1
fi
# Make the script itself executable
chmod +x "$0"
# Make the k8s directory and its contents executable
chmod +x k8s/
# Create a Kubernetes namespace named 'twinkle'
kubectl create ns twinkle
# Run the script to configure SSL (assuming it's in the k8s directory)
k8s/configure_ssl || { echo "Error: Failed to configure SSL"; exit 1; }
# Apply Kubernetes manifests from overlays based on the specified or default environment
kubectl apply -k "k8s/overlays/$ENV"
# Wait for the 'shiny-deploy' deployment to be in the 'available' condition within the 'twinkle' namespace
echo 'Waiting for pods to be ready...'
kubectl wait -n twinkle --for=condition=available --timeout=300s deployment/shiny-deploy
# Run the script for 'shiny-sync' (assuming it's in the k8s directory)
k8s/shiny-sync