diff --git a/config/observability/README.md b/config/observability/README.md index fdcd31fc4..a55125d82 100644 --- a/config/observability/README.md +++ b/config/observability/README.md @@ -2,10 +2,6 @@ ## Deploying the observabilty stack -If you run the `quickstart-setup.sh` script, the observability stack should already be set up. -In that case, you can skip the below commands. -If however you have run `make local-setup` and would like to install the observability stack, these commands will install the stack and example dashboards & alerts. - ```bash ./bin/kustomize build ./config/observability/| docker run --rm -i docker.io/ryane/kfilt -i kind=CustomResourceDefinition | kubectl apply --server-side -f - ./bin/kustomize build ./config/observability/| docker run --rm -i docker.io/ryane/kfilt -x kind=CustomResourceDefinition | kubectl apply -f - diff --git a/hack/quickstart-setup.sh b/hack/quickstart-setup.sh deleted file mode 100755 index 83ed629fa..000000000 --- a/hack/quickstart-setup.sh +++ /dev/null @@ -1,511 +0,0 @@ -#!/bin/bash - -# -# Copyright 2021 Red Hat, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -set -e pipefail - -containerRuntime() { - local container_runtime="" - if command -v docker &>/dev/null; then - container_runtime="docker" - elif command -v podman &>/dev/null; then - container_runtime="podman" - else - echo "Neither Docker nor Podman is installed. Exiting..." - exit 1 - fi - echo "$container_runtime" -} - -dockerBinCmd() { - local network="" - if [ ! -z "${KIND_CLUSTER_DOCKER_NETWORK}" ]; then - network=" --network ${KIND_CLUSTER_DOCKER_NETWORK}" - fi - - echo "$CONTAINER_RUNTIME_BIN run -i --rm -u $UID -v ${TMP_DIR}:${TMP_DIR}${network} -e ADDRESS -e KUBECONFIG=${TMP_DIR}/kubeconfig --entrypoint=$1 $TOOLS_IMAGE" -} - -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -NC='\033[0m' # No Color -BOLD='\033[1m' -INFO="${BOLD}${YELLOW}INFO:${NC}" -SUCCESS="${GREEN}✓${NC}" -FAILURE="${RED}✗${NC}" - -if [ -z $KUADRANT_ORG ]; then - KUADRANT_ORG=${KUADRANT_ORG:="kuadrant"} -fi -if [ -z $KUADRANT_REF ]; then - KUADRANT_REF=${KUADRANT_REF:="main"} -fi -if [ -z $MGC_REF ]; then - MGC_REF=${MGC_REF:="main"} -fi - -if [ -z $ISTIO_INSTALL_SAIL ]; then - ISTIO_INSTALL_SAIL=${ISTIO_INSTALL_SAIL:=true} -fi - -if [ -z "$SAIL_VERSION" ] && [ "$ISTIO_INSTALL_SAIL" = "true" ]; then - SAIL_VERSION=${SAIL_VERSION:="0.1.0"} -fi - -export TOOLS_IMAGE=quay.io/kuadrant/mgc-tools:latest -SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" -export TMP_DIR=$SCRIPT_DIR/tmp/mgc -export CONTAINER_RUNTIME_BIN=$(containerRuntime) -export KIND_BIN=kind -export HELM_BIN=helm -export SUBNET_OFFSET=1 -export HUB=1 - -YQ_BIN=$(dockerBinCmd "yq") - -KUADRANT_REPO="github.com/${KUADRANT_ORG}/kuadrant-operator.git" -KUADRANT_REPO_RAW="https://raw.githubusercontent.com/${KUADRANT_ORG}/kuadrant-operator/${KUADRANT_REF}" -KUADRANT_DEPLOY_KUSTOMIZATION="${KUADRANT_REPO}/config/deploy?ref=${KUADRANT_REF}" -KUADRANT_GATEWAY_API_KUSTOMIZATION="${KUADRANT_REPO}/config/dependencies/gateway-api?ref=${KUADRANT_REF}" -KUADRANT_ISTIO_KUSTOMIZATION="${KUADRANT_REPO}/config/dependencies/istio/sail?ref=${KUADRANT_REF}" -KUADRANT_ISTIO_GATEWAY_EXAMPLE="${KUADRANT_REPO}/config/dependencies/istio/gateway?ref=${KUADRANT_REF}" -KUADRANT_CERT_MANAGER_KUSTOMIZATION="${KUADRANT_REPO}/config/dependencies/cert-manager?ref=${KUADRANT_REF}" -KUADRANT_METALLB_KUSTOMIZATION="${KUADRANT_REPO}/config/metallb?ref=${KUADRANT_REF}" -KUADARNT_THANOS_KUSTOMIZATION="${KUADRANT_REPO}/config/thanos?ref=${KUADRANT_REF}" -KUADARNT_OBSERVABILITY_KUSTOMIZATION="${KUADRANT_REPO}/config/observability?ref=${KUADRANT_REF}" -KUADARNT_OBSERVABILITY_ISTIO_KUSTOMIZATION="${KUADRANT_REPO}/config/observability/prometheus/monitors/istio?ref=${KUADRANT_REF}" -KUADRANT_DASHBOARDS_KUSTOMIZATION="${KUADRANT_REPO}/examples/dashboards?ref=${KUADRANT_REF}" -KUADRANT_ALERTS_KUSTOMIZATION="${KUADRANT_REPO}/examples/alerts?ref=${KUADRANT_REF}" -MGC_REPO="github.com/${KUADRANT_ORG}/multicluster-gateway-controller.git" -MGC_ISTIO_KUSTOMIZATION="${MGC_REPO}/config/istio?ref=${MGC_REF}" - -# Make temporary directory -mkdir -p ${TMP_DIR} - -KUADRANT_CLUSTER_NAME_BASE=kuadrant-local -KUADRANT_CLUSTER_NAME="${KUADRANT_CLUSTER_NAME_BASE}" -KUADRANT_NAMESPACE=kuadrant-system - -info() { - echo -e "${INFO} $1" -} - -success() { - echo -e "${SUCCESS} $1" -} - -error() { - echo -e "${FAILURE} $1" -} - -check_dependencies() { - # Check for Docker or Podman - if ! command -v docker &>/dev/null && ! command -v podman &>/dev/null; then - error "Neither docker nor podman could be found. Please install Docker or Podman." - exit 1 - fi - - # Check for other dependencies - for cmd in kind kubectl; do - if ! command -v $cmd &>/dev/null; then - error "Error: $cmd could not be found. Please install $cmd." - exit 1 - fi - done - - success "All dependencies are installed." -} - -cluster_exists() { - local cluster_name=$1 - ${KIND_BIN} get clusters -q | grep -q "^${cluster_name}$" -} - -# Generate MetalLB IpAddressPool for a given network -generate_ip_address_pool() { - local network_name="$1" - local yq="$2" - local subnet_offset="$3" - local script_path="${SCRIPT_DIR}/../utils/docker-network-ipaddresspool.sh" - - # interactively or piped - if [ -t 0 ]; then - # interactively - if [ -f "$script_path" ]; then - bash "$script_path" "$network_name" "$yq" "$subnet_offset" - else - echo "Script file not found at $script_path" >&2 - return 1 - fi - else - # piped - curl -s "${KUADRANT_REPO_RAW}/utils/docker-network-ipaddresspool.sh" | bash -s -- "$network_name" "$yq" "$subnet_offset" - fi -} - -requiredENV() { - info "Configuring DNS provider environment variables... 🛰️" - info "You have chosen to set up a DNS provider, which is required for using Kuadrant's DNSPolicy API." - info "Supported DNS providers are AWS Route 53 and Google Cloud DNS." - - # Read directly from the terminal, ensuring it can handle piped script execution - read -r -p "Please enter 'aws' for AWS Route 53, or 'gcp' for Google Cloud DNS: " DNS_PROVIDER /dev/null 2>&1; then - echo "Credentials provided is not in JSON format" - exit 1 - fi - - if [[ -z "${PROJECT_ID}" ]]; then - echo "Enter the project id for your GCP Cloud DNS:" - read -r PROJECT_ID ${TMP_DIR}/doctmp - success "Istio configuration generated." - ${YQ_BIN} 'select(.kind == "CustomResourceDefinition")' ${TMP_DIR}/doctmp | kubectl apply -f - - kubectl -n istio-system wait --for=condition=established crd/istiooperators.install.istio.io --timeout=60s - cat ${TMP_DIR}/doctmp | kubectl apply -f - - kubectl -n istio-operator wait --for=condition=Available deployment istio-operator --timeout=300s -fi -success "Istio installed successfully." - -# Install cert-manager -info "Installing cert-manager... 🛡️" -kubectl apply -k ${KUADRANT_CERT_MANAGER_KUSTOMIZATION} -info "Waiting for cert-manager deployments to be ready" -kubectl -n cert-manager wait --for=condition=Available deployments --all --timeout=300s -setupClusterIssuer -success "cert-manager installed successfully." - -# Install metallb -info "Installing MetalLB... 🏗️" -{ - kubectl apply -k ${KUADRANT_METALLB_KUSTOMIZATION} 2>&1 -} | grep -v "Warning: .* deprecated" || true -kubectl -n metallb-system wait --for=condition=Available deployments controller --timeout=300s -kubectl -n metallb-system wait --for=condition=ready pod --selector=app=metallb --timeout=60s -info "Generating IP address pool for MetalLB..." -generate_ip_address_pool "kind" "${YQ_BIN}" "${SUBNET_OFFSET}" | kubectl apply -n metallb-system -f - -success "MetalLB installed and IP address pool generated successfully." - -# Install kuadrant -info "Installing Kuadrant in ${KUADRANT_CLUSTER_NAME}..." -{ - kubectl apply -k ${KUADRANT_DEPLOY_KUSTOMIZATION} --server-side --validate=false 2>&1 -} | grep -v "Warning: .* deprecated" || true - -info "Kuadrant installation applied, configuring DNS provider if set..." -if [ ! -z "$DNS_PROVIDER" ]; then - postSetup ${KUADRANT_CLUSTER_NAME} ${KUADRANT_NAMESPACE} -fi - -# Deploy kuadrant -info "Deploying Kuadrant sample configuration..." -kubectl -n ${KUADRANT_NAMESPACE} apply -f ${KUADRANT_REPO_RAW}/config/samples/kuadrant_v1beta1_kuadrant.yaml -success "Kuadrant sample configuration deployed." - -# Deploy gateway -info "Deploying example gateway ..." -kubectl apply -k ${KUADRANT_ISTIO_GATEWAY_EXAMPLE} -success "Kuadrant sample gateway deployed." - -# Install thanos on hub cluster -if [ "$HUB" -eq 1 ]; then - info "Installing thanos in ${KUADRANT_CLUSTER_NAME}... (as hub cluster)" - kubectl apply -k ${KUADARNT_THANOS_KUSTOMIZATION} - success "thanos installed successfully." -fi - -# Install observability stack -info "Installing observability stack in ${KUADRANT_CLUSTER_NAME}..." -kubectl kustomize ${KUADARNT_OBSERVABILITY_KUSTOMIZATION} | $CONTAINER_RUNTIME_BIN run --rm -i docker.io/ryane/kfilt -i kind=CustomResourceDefinition | kubectl apply --server-side -f - -kubectl kustomize ${KUADARNT_OBSERVABILITY_KUSTOMIZATION} | $CONTAINER_RUNTIME_BIN run --rm -i docker.io/ryane/kfilt -x kind=CustomResourceDefinition | kubectl apply -f - -kubectl kustomize ${KUADARNT_OBSERVABILITY_ISTIO_KUSTOMIZATION} | kubectl apply --server-side -f - -kubectl kustomize ${KUADRANT_DASHBOARDS_KUSTOMIZATION} | kubectl apply --server-side -f - -kubectl kustomize ${KUADRANT_ALERTS_KUSTOMIZATION} | kubectl apply --server-side -f - -success "observability stack installed successfully." - -# Patch prometheus to remote write metrics to thanos in hub -info "Patching prometheus remote write config in ${KUADRANT_CLUSTER_NAME}..." -THANOS_RECEIVE_ROUTER_IP=$(kubectl --context="kind-$KUADRANT_CLUSTER_NAME_BASE" -n monitoring get svc thanos-receive-router-lb -o jsonpath='{.status.loadBalancer.ingress[0].ip}') -kubectl -n monitoring patch prometheus k8s --type='merge' -p '{"spec":{"remoteWrite":[{"url":"http://'"$THANOS_RECEIVE_ROUTER_IP"':19291/api/v1/receive", "writeRelabelConfigs":[{"action":"replace", "replacement":"'"$KUADRANT_CLUSTER_NAME"'", "targetLabel":"cluster_id"}]}]}}' -success "prometheus remote write config patched successfully." - -info "✨🌟 Setup Complete! Your Kuadrant Quick Start environment has been successfully created. 🌟✨" - -info "Here's what has been configured:" -info " - Kubernetes cluster with name '${KUADRANT_CLUSTER_NAME}'" -info " - a Kuadrant namespace 'kuadrant-system'" -info " - Gateway API" -info " - Istio installed $([ "$ISTIO_INSTALL_SAIL" = true ] && echo "via Sail" || echo "without Sail") as a Gateway API provider" -info " - cert-manager" -info " - MetalLB with configured IP address pool" -info " - Kuadrant components and a sample configuration" -if [ ! -z "$DNS_PROVIDER" ]; then - info " - DNS provider set to '${DNS_PROVIDER}'" -fi - -info "Next steps:" -info " - Explore your new Kuadrant environment using 'kubectl get all -n kuadrant-system'." -info " - Head over to the Kuadrant quick start guide for further instructions on how to use Kuadrant with this environment:" -info " 🔗 https://docs.kuadrant.io/latest/kuadrant-operator/doc/user-guides/secure-protect-connect/" - -echo "" -info "Thank you for using Kuadrant! If you have any questions or feedback, please reach out to our community." -info "🔗 https://github.com/Kuadrant/"