Starting and Stopping Saagie

Use these tutorials to start and stop Saagie.

Follow the orders listed below, as you will start Saagie in one order and stop it in the opposite order.

Starting Saagie

  1. Declare the variables that will be used by the scripts exactly as follows:

    declare dbs="mongo|postgresql|schema-registry"
    declare -a statefulsets=("saagie-kafka-cp-zookeeper" "saagie-kafka-cp-kafka")
  2. Start Saagie by launching the components in the following order:

    1. Start Zookeeper and Kafka, each running three pods.

      for statefulset in "${statefulsets[@]}"
      do
          echo "Starting $statefulset..."
          kubectl scale statefulset.apps -n saagie-common $statefulset --replicas=3
      done
    2. Launch database-related deployments, containing MongoDB, PostgreSQL, and schema-registry.

      for db_deployment in `kubectl get deployment.extensions -n saagie-common -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep -E $dbs | grep -Ev $excludes`
      do
          echo "Starting $db_deployment..."
          kubectl scale deployment.extensions -n saagie-common --replicas 1 $db_deployment
      done
    3. Launch product-related deployments.

      for deployment in `kubectl get deployment.extensions -n saagie-common -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep -Ev $dbs | grep -Ev $excludes`
      do
          echo "Starting $deployment..."
          kubectl scale deployment.extensions -n saagie-common --replicas 1 $deployment
      done

Stopping Saagie

When stopping Saagie, some components must be stopped before others in order to avoid unexpected behaviors.
  1. Declare the variables that will be used by the scripts exactly as follows:

    declare dbs="mongo|postgresql|schema-registry"
    declare -a statefulsets=("saagie-kafka-cp-zookeeper" "saagie-kafka-cp-kafka")
  2. Stop Saagie by stopping the components in the following order:

    1. Stop product-related deployments.

      for deployment in `kubectl get deployment.extensions -n saagie-common -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep -Ev $dbs | grep -Ev $excludes`
      do
          echo "Shutting down $deployment..."
          kubectl scale deployment.extensions -n saagie-common --replicas 0 $deployment
      done
    2. Stop database-related deployments.

      for db_deployment in `kubectl get deployment.extensions -n saagie-common -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep -E $dbs | grep -Ev $excludes`
      do
          echo "Shutting down $db_deployment..."
          kubectl scale deployment.extensions -n saagie-common --replicas 0 $db_deployment
      done
    3. Stop Kafka and Zookeeper.

      for statefulset in "${statefulsets[@]}"
      do
          echo "Shutting down $statefulset..."
          kubectl scale statefulset.apps -n saagie-common $statefulset --replicas=0
      done

Scripts to Start and Stop Saagie

  • startCluster.sh

  • stopCluster.sh

#!/bin/bash

declare dbs="mongo|postgresql|schema-registry"
declare -a statefulsets=("saagie-kafka-cp-zookeeper" "saagie-kafka-cp-kafka")

# Start kafka & zookeeper

for statefulset in "${statefulsets[@]}"
do
    echo "Starting $statefulset..."
    kubectl scale statefulset.apps -n saagie-common $statefulset --replicas=3
done

# Start every saagie-common databases deployments

for db_deployment in `kubectl get deployment.extensions -n saagie-common -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep -E $dbs | grep -Ev $excludes`
do
    echo "Starting $db_deployment..."
    kubectl scale deployment.extensions -n saagie-common --replicas 1 $db_deployment
done

# Start every saagie-common deployments (except databases & schema-registry)

for deployment in `kubectl get deployment.extensions -n saagie-common -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep -Ev $dbs | grep -Ev $excludes`
do
    echo "Starting $deployment..."
    kubectl scale deployment.extensions -n saagie-common --replicas 1 $deployment
done
#!/bin/bash

declare dbs="mongo|postgresql|schema-registry"
declare -a statefulsets=("saagie-kafka-cp-zookeeper" "saagie-kafka-cp-kafka")

# Stop every saagie-common deployments (except databases & schema-registry)

for deployment in `kubectl get deployment.extensions -n saagie-common -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep -Ev $dbs | grep -Ev $excludes`
do
    echo "Shutting down $deployment..."
    kubectl scale deployment.extensions -n saagie-common --replicas 0 $deployment
done

# Stop every saagie-common databases deployments

for db_deployment in `kubectl get deployment.extensions -n saagie-common -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep -E $dbs | grep -Ev $excludes`
do
    echo "Shutting down $db_deployment..."
    kubectl scale deployment.extensions -n saagie-common --replicas 0 $db_deployment
done

# Stop kafka & zookeeper

for statefulset in "${statefulsets[@]}"
do
    echo "Shutting down $statefulset..."
    kubectl scale statefulset.apps -n saagie-common $statefulset --replicas=0
done