github.com/verrazzano/verrazzano-monitoring-operator@v0.0.30/run-vmo.sh (about)

     1  #!/bin/bash
     2  # Copyright (c) 2020, 2022, Oracle and/or its affiliates.
     3  # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
     4  #
     5  # This script will run the verrazzano-monitoring-operator outside of the cluster, for local debugging/testing
     6  # purposes.
     7  #
     8  # Pre-requisites:
     9  # - golang is installed as described in the README
    10  # - the verrazzano installer is cloned from github in a parallel directory named to this repo (https://github.com/verrazzano/verrazzano)
    11  # - kubectl is installed
    12  # - KUBECONFIG is pointing to a valid Kubernetes cluster
    13  # - If on corporate network set proxy environment variables
    14  #
    15  # Simply run
    16  #
    17  #    sh run-vmo.sh
    18  #
    19  # When executed, the script will
    20  #
    21  # - build the operator
    22  # - set up the required environment variables for the operator
    23  # - scale down the in-cluster monitoring operator to 0
    24  # - Execute the local operator
    25  # - Once the local operator is terminated (hit Ctrl-C), scale up the in-cluster operator to 1 replica again
    26  
    27  # Customize these to provide the location of your verrazzano and verrazzano repos
    28  export THIS_REPO=$(pwd)
    29  export VERRAZZANO_INSTALLER_REPO=${THIS_REPO}/../verrazzano/platform-operator/helm_config/charts/verrazzano
    30    
    31  echo "Building and installing the verrazzano-monitoring-operator."
    32  cd ${THIS_REPO}
    33  make go-install
    34  echo ""
    35  
    36  echo "Stopping the in-cluster verrazzano-monitoring-operator."
    37  set -x
    38  kubectl scale deployment verrazzano-monitoring-operator --replicas=0 -n verrazzano-system
    39  set +x
    40  echo ""
    41    
    42  # Extract the images required by verrazzano-operator from values.yaml into environment variables.
    43  export ISTIO_PROXY_IMAGE=$(grep istioProxyImage ${VERRAZZANO_INSTALLER_REPO}//values.yaml | cut -d':' -f2,3 | sed -e 's/^[[:space:]]*//')
    44  export GRAFANA_IMAGE=$(grep grafanaImage ${VERRAZZANO_INSTALLER_REPO}//values.yaml | cut -d':' -f2,3 | sed -e 's/^[[:space:]]*//')
    45  export ELASTICSEARCH_WAIT_TARGET_VERSION=7.6.1
    46  export ELASTICSEARCH_WAIT_IMAGE=$(grep esWaitImage ${VERRAZZANO_INSTALLER_REPO}/values.yaml | cut -d':' -f2,3 | sed -e 's/^[[:space:]]*//')
    47  export KIBANA_IMAGE=$(grep kibanaImage ${VERRAZZANO_INSTALLER_REPO}/values.yaml | cut -d':' -f2,3 | sed -e 's/^[[:space:]]*//')
    48  export ELASTICSEARCH_IMAGE=$(grep esImage ${VERRAZZANO_INSTALLER_REPO}/values.yaml | cut -d':' -f2,3 | sed -e 's/^[[:space:]]*//')
    49  export ELASTICSEARCH_INIT_IMAGE=$(grep esInitImage ${VERRAZZANO_INSTALLER_REPO}/values.yaml | cut -d':' -f2,3 | sed -e 's/^[[:space:]]*//')
    50  export VERRAZZANO_MONITORING_INSTANCE_API_IMAGE=$(grep monitoringInstanceApiImage ${VERRAZZANO_INSTALLER_REPO}/values.yaml | cut -d':' -f2,3 | sed -e 's/^[[:space:]]*//')
    51  export OIDC_PROXY_IMAGE=$(grep oidcProxyImage ${VERRAZZANO_INSTALLER_REPO}/values.yaml | head -1 | cut -d':' -f2,3 | sed -e 's/^[[:space:]]*//')
    52  
    53  # Extract the API server realm from values.yaml.
    54  export API_SERVER_REALM=$(grep apiServerRealm ${VERRAZZANO_INSTALLER_REPO}/values.yaml | cut -d':' -f2 | sed -e 's/^[[:space:]]*//')
    55    
    56  # Extract the Verrazzano system ingress IP from the NGINX ingress controller status.
    57  export VERRAZZANO_SYSTEM_INGRESS_IP=$(kubectl get svc -n ingress-nginx ingress-controller-nginx-ingress-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
    58  
    59  export WATCH_VMI=${WATCH_VMI:-""}
    60  export WATCH_NAMESPACE=${WATCH_NAMESPACE:-""}
    61  
    62  cat <<EOF
    63  Variables:
    64  
    65  ISTIO_PROXY_IMAGE=${ISTIO_PROXY_IMAGE}
    66  GRAFANA_IMAGE=${GRAFANA_IMAGE}
    67  ELASTICSEARCH_WAIT_TARGET_VERSION=${ELASTICSEARCH_WAIT_TARGET_VERSION}
    68  ELASTICSEARCH_WAIT_IMAGE=${ELASTICSEARCH_WAIT_IMAGE}
    69  KIBANA_IMAGE=${KIBANA_IMAGE}
    70  ELASTICSEARCH_IMAGE=${ELASTICSEARCH_IMAGE}
    71  ELASTICSEARCH_INIT_IMAGE=${ELASTICSEARCH_INIT_IMAGE}
    72  VERRAZZANO_MONITORING_INSTANCE_API_IMAGE=${VERRAZZANO_MONITORING_INSTANCE_API_IMAGE}
    73  OIDC_PROXY_IMAGE=${OIDC_PROXY_IMAGE}
    74  
    75  WATCH_VMI=${WATCH_VMI}
    76  WATCH_NAMESPACE=${WATCH_NAMESPACE}
    77  EOF
    78  
    79  # Run the out-of-cluster Verrazzano operator.
    80  cmd="verrazzano-monitoring-ctrl \
    81   --zap-log-level=debug \
    82   --namespace=verrazzano-system \
    83   --watchNamespace=${WATCH_NAMESPACE} \
    84   --watchVmi=${WATCH_VMI} \
    85   --kubeconfig=${KUBECONFIG:-${HOME}/.kube/config}"
    86  
    87  echo "Command"
    88  echo "${cmd}"
    89  eval ${cmd}
    90  
    91  echo "Re-starting the in-cluster verrazzano-monitoring-operator."
    92  set -x
    93  kubectl scale deployment verrazzano-monitoring-operator --replicas=1 -n verrazzano-system
    94  set +x
    95  echo ""