Skip to content

Commit

Permalink
WIP: Working example, just need to get the credentials figured out
Browse files Browse the repository at this point in the history
Signed-off-by: Pete Wall <[email protected]>
  • Loading branch information
petewall committed Jan 9, 2025
1 parent ab3b909 commit fb405a5
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 32 deletions.
2 changes: 2 additions & 0 deletions charts/k8s-monitoring/tests/platform/aks/.envrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export AZURE_SUBSCRIPTION_ID=$(op --account grafana.1password.com read "op://Kubernetes Monitoring/Azure/subscription id")
export AZURE_TENANT_ID=$(op --account grafana.1password.com read "op://Kubernetes Monitoring/Azure/tenant id")
export AZURE_CLIENT_ID=$(op --account grafana.1password.com read "op://Kubernetes Monitoring/Azure/client id")
export AZURE_DEFAULT_GROUP=$(op --account grafana.1password.com read "op://Kubernetes Monitoring/Azure/resource group")
az config set defaults.group="$AZURE_DEFAULT_GROUP"

export GRAFANA_CLOUD_METRICS_USERNAME=$(op --account grafana.1password.com read "op://Kubernetes Monitoring/helmchart Prometheus/username")
export GRAFANA_CLOUD_LOGS_USERNAME=$(op --account grafana.1password.com read "op://Kubernetes Monitoring/helmchart Loki/username")
Expand Down
3 changes: 3 additions & 0 deletions charts/k8s-monitoring/tests/platform/aks/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ deployments/grafana-cloud-credentials.yaml:
--from-literal=LOKI_USER="$$GRAFANA_CLOUD_LOGS_USERNAME" \
--from-literal=LOKI_PASS="$$GRAFANA_CLOUD_RW_POLICY_TOKEN" \
-o yaml --dry-run=client >> $@

run-test:
../../../../../scripts/run-cluster-test.sh .
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
args:
node-count: 1
tier: free
enable-managed-identity:
generate-ssh-keys:
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ spec:
- secretRef: {name: grafana-cloud-credentials}
- configMapRef: {name: test-variables}
queries:
# Metrics are being delivered
- query: alloy_build_info{cluster="$CLUSTER"}
type: promql
# Cluster events
- query: count_over_time({cluster="$CLUSTER", job="integrations/kubernetes/eventhandler"}[1h])
type: logql
19 changes: 0 additions & 19 deletions charts/k8s-monitoring/tests/platform/aks/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,8 @@ destinations:
name: grafana-cloud-credentials
namespace: default

clusterMetrics:
enabled: true

clusterEvents:
enabled: true

podLogs:
enabled: true

integrations:
alloy:
instances:
- name: alloy-metrics
- name: alloy-singleton
- name: alloy-logs

selfReporting: {scrapeInterval: 1m} # Force self-report to be generated within test time

alloy-metrics:
enabled: true
alloy-singleton:
enabled: true
alloy-logs:
enabled: true
20 changes: 13 additions & 7 deletions scripts/includes/cluster/aks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@ createAKSCluster() {
local clusterName=$1
local clusterConfig=$2

if ! az does cluster exist; then
echo az create cluster "${clusterName}" --config "${clusterConfig}"...
az create cluster "${clusterName}" --config "${clusterConfig}"...
if ! az aks list --query '[].name' | grep -q "${clusterName}"; then
args=$(yq eval -r -o=json '[.args | to_entries | .[] | select(.value != null)] | map("--" + .key + "=" + (.value | tostring)) | join(" ")' "${clusterConfig}")
args=$(yq eval -r -o=json '[.args | to_entries | .[] | select(.value == null)] | map("--" + .key) | join(" ")' "${clusterConfig}")
bashCommand="az aks create --yes --name \"${clusterName}\" ${args}"
echo "${bashCommand}"
eval "${bashCommand}"
fi
}

deleteAKSCluster() {
local clusterName=$1
if az does cluster exist; then
echo az delete cluster "${clusterName}" ...
az delete cluster "${clusterName}" ...
local clusterConfig=$2

if az aks list --query '[].name' | grep -q "${clusterName}"; then
bashCommand="az aks delete --yes --name \"${clusterName}\""
echo "${bashCommand}"
eval "${bashCommand}"
fi
}
}
6 changes: 3 additions & 3 deletions scripts/run-cluster-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
PARENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
source "${PARENT_DIR}/scripts/includes/utils.sh"
source "${PARENT_DIR}/scripts/includes/logging.sh"
#source "${PARENT_DIR}/scripts/includes/cluster/aks.sh"
source "${PARENT_DIR}/scripts/includes/cluster/aks.sh"
source "${PARENT_DIR}/scripts/includes/cluster/eks.sh"
source "${PARENT_DIR}/scripts/includes/cluster/gke.sh"
source "${PARENT_DIR}/scripts/includes/cluster/kind.sh"
Expand Down Expand Up @@ -51,7 +51,7 @@ if [ "${CREATE_CLUSTER}" == "true" ]; then
if [ -f "${TEST_DIRECTORY}/kind-cluster-config.yaml" ]; then
createKindCluster "${clusterName}" "${TEST_DIRECTORY}/kind-cluster-config.yaml"
elif [ -f "${TEST_DIRECTORY}/aks-cluster-config.yaml" ]; then
createAKSCluster "${clusterName}" "${TEST_DIRECTORY}/eks-cluster-config.yaml"
createAKSCluster "${clusterName}" "${TEST_DIRECTORY}/aks-cluster-config.yaml"
elif [ -f "${TEST_DIRECTORY}/eks-cluster-config.yaml" ]; then
createEKSCluster "${clusterName}" "${TEST_DIRECTORY}/eks-cluster-config.yaml"
elif [ -f "${TEST_DIRECTORY}/gke-cluster-config.yaml" ]; then
Expand All @@ -67,7 +67,7 @@ deleteCluster() {
if [ -f "${TEST_DIRECTORY}/kind-cluster-config.yaml" ]; then
deleteKindCluster "${clusterName}" "${TEST_DIRECTORY}/kind-cluster-config.yaml"
elif [ -f "${TEST_DIRECTORY}/aks-cluster-config.yaml" ]; then
deleteAKSCluster "${clusterName}" "${TEST_DIRECTORY}/eks-cluster-config.yaml"
deleteAKSCluster "${clusterName}" "${TEST_DIRECTORY}/aks-cluster-config.yaml"
elif [ -f "${TEST_DIRECTORY}/eks-cluster-config.yaml" ]; then
deleteEKSCluster "${clusterName}" "${TEST_DIRECTORY}/eks-cluster-config.yaml"
elif [ -f "${TEST_DIRECTORY}/gke-cluster-config.yaml" ]; then
Expand Down

0 comments on commit fb405a5

Please sign in to comment.