diff --git a/.github/workflows/platform-test.yml b/.github/workflows/platform-test.yml index f21b5aadb..147598f9c 100644 --- a/.github/workflows/platform-test.yml +++ b/.github/workflows/platform-test.yml @@ -30,6 +30,7 @@ jobs: run: | if [ "${{ github.event_name }}" == "pull_request" ] && [ "${{contains(github.event.pull_request.labels.*.name, 'run-platform-tests')}}" != "true" ]; then echo "Skipping platform tests" + echo "tests=[]" >> "${GITHUB_OUTPUT}" exit 0 fi diff --git a/scripts/delete-local-test-cluster.sh b/charts/k8s-monitoring-v1/scripts/delete-local-test-cluster.sh similarity index 100% rename from scripts/delete-local-test-cluster.sh rename to charts/k8s-monitoring-v1/scripts/delete-local-test-cluster.sh diff --git a/charts/k8s-monitoring-v1/scripts/setup-local-test-cluster.sh b/charts/k8s-monitoring-v1/scripts/setup-local-test-cluster.sh new file mode 100755 index 000000000..67f15dbb9 --- /dev/null +++ b/charts/k8s-monitoring-v1/scripts/setup-local-test-cluster.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash +CHART_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" + +CLUSTER_NAME="k8s-mon-test-cluster" +CLUSTER_CONFIG="${CHART_DIR}/../../.github/configs/cluster-config.yaml" +GRAFANA_ALLOY_VALUES="${CHART_DIR}/../../.github/configs/alloy-config.yaml" +GRAFANA_ALLOY_LOKI_OTLP_VALUES="${CHART_DIR}/../../.github/configs/alloy-config-loki-otlp.yaml" +GRAFANA_ALLOY_RECEIVER_SERVICE="${CHART_DIR}/../../.github/configs/receiver-service.yaml" +PROMETHEUS_VALUES="${CHART_DIR}/../../.configs/prometheus.yaml" +PROMETHEUS_WORKLOAD_VALUES="${CHART_DIR}/../../.github/configs/prometheus-workload.yaml" +CREDENTIALS="${CHART_DIR}/../../.github/configs/credentials.yaml" +LOKI_VALUES="${CHART_DIR}/../../.configs/loki.yaml" +#TEMPO_VALUES="" # No values for now +PYROSCOPE_VALUES="${CHART_DIR}/../../.github/configs/pyroscope.yaml" +GRAFANA_VALUES="${CHART_DIR}/../../.github/configs/grafana.yaml" +PODLOGS_OBJECTS="${CHART_DIR}/../../.github/configs/podlogs.yaml" +MYSQL_VALUES="${CHART_DIR}/../../.github/configs/mysql.yaml" +MYSQL_CONFIG_MANIFEST="${CHART_DIR}/../../.github/configs/mysql-config.yaml" +CERT_MANAGER_VALUES="${CHART_DIR}/../../.github/configs/cert-manager.yaml" +SECRETGEN_CONTROLLER_MANIFEST=https://github.com/carvel-dev/secretgen-controller/releases/latest/download/release.yml +CERTIFICATES_MANIFEST="${CHART_DIR}/../../.github/configs/certificates.yaml" + +K8SMON_CHART_PATH="${CHART_DIR}" +K8SMON_VALUES=$1 + +if ! kind get nodes --name "${CLUSTER_NAME}" | grep "No kind nodes found for cluster \"${CLUSTER_NAME}\"" > /dev/null 2>&1; then + echo "Creating cluster..." + kind create cluster --config "${CLUSTER_CONFIG}" --name "${CLUSTER_NAME}" +fi + +set -e + +echo "Creating SSL Certs and secrets..." +kubectl apply -f "${SECRETGEN_CONTROLLER_MANIFEST}" +kubectl apply -f "${CERTIFICATES_MANIFEST}" +kubectl apply -f "${CREDENTIALS}" + +# MySQL for integration testing +helm upgrade --install mysql oci://registry-1.docker.io/bitnamicharts/mysql -f "${MYSQL_VALUES}" -n mysql --create-namespace --wait +kubectl apply -f "${MYSQL_CONFIG_MANIFEST}" + +# Cert Manager for integration testing (service annotations) +helm repo add jetstack https://charts.jetstack.io +helm upgrade --install cert-manager jetstack/cert-manager -f "${CERT_MANAGER_VALUES}" -n cert-manager --create-namespace --wait + +# This Alloy instance is only used for generating metrics, logs, and traces that'll get +# sent to the K8s Monitoring Alloy to test ingesting MLT from receivers. +kubectl apply -f "${GRAFANA_ALLOY_RECEIVER_SERVICE}" +helm upgrade --install alloy grafana/alloy -f "${GRAFANA_ALLOY_VALUES}" -n alloy --create-namespace --wait + +# This prometheus instance is used pod annotation testing with https +helm upgrade --install prometheus-workload prometheus-community/prometheus -f "${PROMETHEUS_WORKLOAD_VALUES}" -n prometheus --create-namespace --wait + +# Deploy the Prometheus Operator CRDs, since we want to deploy Loki with a ServiceMonitor later +helm upgrade --install prom-crds prometheus-community/prometheus-operator-crds --wait + +echo "Deploying Prometheus..." +helm upgrade --install prometheus prometheus-community/prometheus -f "${PROMETHEUS_VALUES}" -n prometheus --create-namespace --wait + +echo "Deploying Loki..." +helm upgrade --install loki grafana/loki -f "${LOKI_VALUES}" -n loki --create-namespace --wait +helm upgrade --install loki-otlp grafana/alloy -f "${GRAFANA_ALLOY_LOKI_OTLP_VALUES}" -n loki --wait + +echo "Deploying Tempo..." +helm upgrade --install tempo grafana/tempo -n tempo --create-namespace --wait + +echo "Deploying Pyroscope..." +helm upgrade --install pyroscope grafana/pyroscope -f "${PYROSCOPE_VALUES}" -n pyroscope --create-namespace --wait + +echo "Deploying Grafana..." +helm upgrade --install grafana grafana/grafana -f "${GRAFANA_VALUES}" -n grafana --create-namespace --wait +kubectl apply -f "${PODLOGS_OBJECTS}" + +if [ -n "${K8SMON_VALUES}" ]; then + helm upgrade --install k8smon "${K8SMON_CHART_PATH}" -f "${K8SMON_VALUES}" -n monitoring --create-namespace --wait + helm test k8smon -n monitoring +fi