github.com/m3db/m3@v1.5.0/scripts/vagrant/provision/setup_kube_bench.sh (about)

     1  #!/bin/bash
     2  
     3  set -xe
     4  
     5  # Expects the following installed:
     6  # - docker
     7  # - kubectl
     8  # - kind
     9  # - curl
    10  # - jq
    11  
    12  if [[ "$M3COORDINATOR_PRIMARY_IP" == "" ]]; then
    13      echo "M3COORDINATOR_PRIMARY_IP env var not set"
    14      exit 1
    15  fi
    16  if [[ "$M3COORDINATOR_SECONDARY_IP" == "" ]]; then
    17      echo "M3COORDINATOR_SECONDARY_IP env var not set"
    18      exit 1
    19  fi
    20  
    21  # Create cluster
    22  kind create cluster  --config ./manifests/kind-kube-cluster.yaml
    23  
    24  # Use correct kubeconfig
    25  export KUBECONFIG="$(kind get kubeconfig-path --name="kind")"
    26  
    27  # Manifests for Operator (prom, grafana, etc)
    28  set +x
    29  echo "Applying Prometheus operator manifests"
    30  while true; do
    31      if kubectl apply -f ./manifests/kube-prometheus; then
    32          printf "\n"
    33          break
    34      fi
    35      sleep 2
    36      printf "."
    37  done
    38  set -x
    39  
    40  # ServiceMonitor CRD for Promremotebench monitoring
    41  kubectl apply -f ./manifests/prometheus-servicemonitor-promremotebench.yaml
    42  
    43  # Populate m3ccord primary/secondary IPs
    44  M3COORDINATOR_PRIMARY_WRITE_ADDR="http:\/\/$M3COORDINATOR_PRIMARY_IP:7201\/api\/v1\/prom\/remote\/write"
    45  M3COORDINATOR_SECONDARY_WRITE_ADDR="http:\/\/$M3COORDINATOR_SECONDARY_IP:7201\/api\/v1\/prom\/remote\/write"
    46  perl -pi -e "s/M3COORDINATOR_WRITE_TARGETS/$M3COORDINATOR_PRIMARY_WRITE_ADDR,$M3COORDINATOR_SECONDARY_WRITE_ADDR/" ./manifests/promremotebench-multi.yaml
    47  
    48  M3COORDINATOR_PRIMARY_QUERY_ADDR="http:\/\/$M3COORDINATOR_PRIMARY_IP:7201\/api\/v1\/query_range"
    49  M3COORDINATOR_SECONDARY_QUERY_ADDR="http:\/\/$M3COORDINATOR_SECONDARY_IP:7201\/api\/v1\/query_range"
    50  perl -pi -e "s/M3COORDINATOR_QUERY_TARGETS/$M3COORDINATOR_PRIMARY_QUERY_ADDR,$M3COORDINATOR_SECONDARY_QUERY_ADDR/" ./manifests/promremotebench-multi.yaml
    51  
    52  # Ready load generator (but don't scale up yet)
    53  kubectl apply -f ./manifests/promremotebench-multi.yaml