github.com/verrazzano/verrazzano@v1.7.0/platform-operator/thirdparty/charts/prometheus-community/kube-prometheus-stack/hack/minikube/cmd.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  HELM_RELEASE_NAME=prom-op
     4  CHART=./
     5  NAMESPACE=monitoring
     6  VALUES_FILES=./hack/minikube/values.yaml
     7  
     8  if [ "$1" = "reset-minikube" ]; then
     9    minikube delete
    10    minikube start  \
    11      #--vm-driver hyperv --hyperv-virtual-switch "Default Switch" \
    12      --kubernetes-version=v1.13.3 \
    13      --memory=4096 --bootstrapper=kubeadm \
    14      --extra-config=kubelet.authentication-token-webhook=true \
    15      --extra-config=kubelet.authorization-mode=Webhook \
    16      --extra-config=scheduler.address=0.0.0.0 \
    17      --extra-config=controller-manager.address=0.0.0.0
    18    exit 0
    19  fi
    20  
    21  if [ "$1" = "init-helm" ]; then
    22    helm init
    23    helm repo update
    24    exit 0
    25  fi
    26  
    27  if [ "$1" = "init-etcd-secret" ]; then
    28    kubectl create namespace monitoring
    29    kubectl delete secret etcd-certs -nmonitoring
    30    kubectl create secret generic etcd-certs -nmonitoring \
    31    --from-literal=ca.crt="$(kubectl exec kube-apiserver-minikube -nkube-system -- cat /var/lib/minikube/certs/etcd/ca.crt)" \
    32    --from-literal=client.crt="$(kubectl exec kube-apiserver-minikube -nkube-system -- cat /var/lib/minikube/certs/apiserver-etcd-client.crt)" \
    33    --from-literal=client.key="$(kubectl exec kube-apiserver-minikube -nkube-system -- cat /var/lib/minikube/certs/apiserver-etcd-client.key)"
    34  
    35    exit 0
    36  fi
    37  
    38  
    39  if [ "$1" = "upgrade-install" ]; then
    40    helm upgrade $HELM_RELEASE_NAME $CHART \
    41      --namespace $NAMESPACE     \
    42      --values    $VALUES_FILES  \
    43      --set       grafana.podAnnotations.redeploy-hack="$(cat /proc/sys/kernel/random/uuid)" \
    44      --install --debug
    45    exit 0
    46  fi
    47  
    48  if [ "$1" = "port-forward" ]; then
    49    killall kubectl &>/dev/null
    50    kubectl port-forward service/prom-op-prometheus-operato-prometheus 9090 &>/dev/null &
    51    kubectl port-forward service/prom-op-prometheus-operato-alertmanager 9093 &>/dev/null &
    52    kubectl port-forward service/prom-op-grafana 3000:80 &>/dev/null &
    53    echo "Started port-forward commands"
    54    echo "localhost:9090 - prometheus"
    55    echo "localhost:9093 - alertmanager"
    56    echo "localhost:3000 - grafana"
    57    exit 0
    58  fi
    59  
    60  cat << EOF
    61  Usage:
    62    install.sh <COMMAND>
    63  
    64  Commands:
    65    reset-minikube      - resets minikube with values suitable for running prometheus operator
    66                          the normal installation will not allow scraping of the kubelet,
    67                          scheduler or controller-manager components
    68    init-helm           - initialize helm and update repository so that we can install
    69                          the kube-prometheus-stack chart. This has to be run only once after
    70                          a minikube installation is done
    71    init-etcd-secret    - pulls the certs used to access etcd from the api server and creates
    72                          a secret in the monitoring namespace with them. The values files
    73                          in the install command assume that this secret exists and is valid.
    74                          If not, then prometheus will not start
    75    upgrade-install     - install or upgrade the kube-prometheus-stack chart in the cluster
    76    port-forward        - starts port-forwarding for prometheus, alertmanager, grafana
    77                          localhost:9090 - prometheus
    78                          localhost:9093 - alertmanager
    79                          localhost:3000 - grafana
    80  EOF
    81  
    82  exit 0
    83  }
    84