Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refafactor: Update demo script #119

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 80 additions & 5 deletions demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,84 @@

set -e

# Install egressd
helm upgrade --install --repo https://castai.github.io/helm-charts egressd egressd -n egressd --create-namespace -f ./hack/egressd-demo-values.yaml
# Default variables for components and versions
EGRESSD_REPO="https://castai.github.io/helm-charts"
GRAFANA_REPO="https://grafana.github.io/helm-charts"
VICTORIA_REPO="https://victoriametrics.github.io/helm-charts"
EGRESSD_NAME="egressd"
GRAFANA_NAME="egressd-grafana"
VICTORIA_NAME="egressd-victoria"
DEFAULT_NAMESPACE="egressd"
GRAFANA_VERSION="6.50.7"
VICTORIA_VERSION="0.8.58"

# Install grafana and victoria metrics.
helm upgrade --install --repo https://grafana.github.io/helm-charts egressd-grafana grafana --version 6.50.7 -n egressd -f ./hack/grafana-demo-values.yaml
helm upgrade --install --repo https://victoriametrics.github.io/helm-charts egressd-victoria victoria-metrics-single --version 0.8.58 -n egressd -f ./hack/victoria-demo-values.yaml
# Function to print components and versions
print_components() {
echo "Components to be installed:"
echo "1. $EGRESSD_NAME from $EGRESSD_REPO"
echo "2. $GRAFANA_NAME from $GRAFANA_REPO, version $GRAFANA_VERSION"
echo "3. $VICTORIA_NAME from $VICTORIA_REPO, version $VICTORIA_VERSION"
}

# Function to install components
install_components() {
print_components
# Install egressd
helm upgrade --install --repo $EGRESSD_REPO $EGRESSD_NAME $EGRESSD_NAME -n $NAMESPACE --create-namespace -f ./hack/egressd-demo-values.yaml

# Install grafana and victoria metrics
helm upgrade --install --repo $GRAFANA_REPO $GRAFANA_NAME grafana --version $GRAFANA_VERSION -n $NAMESPACE -f ./hack/grafana-demo-values.yaml
helm upgrade --install --repo $VICTORIA_REPO $VICTORIA_NAME victoria-metrics-single --version $VICTORIA_VERSION -n $NAMESPACE -f ./hack/victoria-demo-values.yaml
}

# Function to uninstall components and delete namespace
uninstall_components() {
echo "Uninstalling components and deleting namespace $NAMESPACE..."
helm uninstall $EGRESSD_NAME -n $NAMESPACE || true
helm uninstall $GRAFANA_NAME -n $NAMESPACE || true
helm uninstall $VICTORIA_NAME -n $NAMESPACE || true
kubectl delete namespace $NAMESPACE || true
echo "Uninstallation completed."
}

usage() {
echo "Usage: $0 [--uninstall] [--namespace <namespace>]"
echo ""
echo "Options:"
echo " --uninstall Uninstall all components and delete the namespace."
echo " --namespace <name> Specify a custom namespace for installation. Default is 'egressd'."
echo ""
echo "Examples:"
echo " $0 Install components in the default namespace 'egressd'."
echo " $0 --namespace test Install components in the 'test' namespace."
echo " $0 --uninstall Uninstall all components from the default namespace 'egressd'."
exit 1
}

# Default namespace
NAMESPACE=$DEFAULT_NAMESPACE

# Check parameters
while [[ $# -gt 0 ]]; do
case $1 in
--uninstall)
UNINSTALL=true
shift
;;
--namespace)
NAMESPACE=$2
shift 2
;;
*)
echo "Unknown parameter $1"
usage
;;
esac
done

# Execute based on parameters
if [[ $UNINSTALL == true ]]; then
uninstall_components
else
install_components
fi