#!/usr/bin/env bash usage() { printf "$0 usage: \n -i: interactive\n -p : Postgres version\n -s : enable SSL\n -r : API replicas\n" $0 exit 0 } interactive=false postgres_version= enable_ssl= api_replicas= fluentd=false while getopts "ifhp:s:r:" arg; do case $arg in i) interactive=true ;; p) postgres_version=${OPTARG} ;; s) enable_ssl=${OPTARG} ;; r) api_replicas=${OPTARG} ;; f) fluentd=true ;; *) usage ;; esac done if [ "$#" -gt 1 ] && [ "$1" = "-i" ]; then interactive=false fi minikube status | grep -q "Running" && START_MINIKUBE=false || START_MINIKUBE=true $START_MINIKUBE && minikube start $START_MINIKUBE && eval $(minikube docker-env) if [ "$interactive" == true ]; then read -p "Enter the Postgres version (press Enter for default 13.3): " postgres_version read -p "Do you want to enable SSL? [y/N]: " enable_ssl read -p "Enter the number of replicas for the API: " api_replicas read -p "Do you want to enable fluentd? [y/N]: " fluentd fi if [ -n "$postgres_version" ]; then ./build.sh -v "${postgres_version}" sed -ni "/repository: db/ { p; n; /tag:.*/ { s/tag:.*/tag: ${postgres_version}/; p; d; } } p;" helm/values.yaml else ./build.sh fi if [ -n "$enable_ssl" ]; then if [ "$enable_ssl" == "y" ] || [ "$enable_ssl" == "Y" ]; then sed -i "s/ssl: .*/ssl: true/" helm/values.yaml else sed -i "s/ssl: .*/ssl: false/" helm/values.yaml fi fi if [ -n "$api_replicas" ]; then sed -ni "/port: \*apiPort/ { p; n; /replicas:.*/ { s/replicas:.*/replicas: ${api_replicas}/; p; d; } } p;" helm/values.yaml fi $START_MINIKUBE && minikube addons enable ingress helm dependency list helm | grep -q "missing" && helm dependency build helm if [ "$fluentd" == true ] || [ "$fluentd" == "y" ] || [ "$fluentd" == "Y" ]; then VALUES=("-f" "helm/values.yaml" "-f" "helm/fluentd.yaml") helm status exam -n exam > /dev/null 2>&1 && helm upgrade exam ./helm -n exam ${VALUES[@]} || helm install exam ./helm -n exam ${VALUES[@]} else helm status exam -n exam > /dev/null 2>&1 && helm upgrade exam ./helm -n exam || helm install exam ./helm -n exam fi