Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra functions for automating playground installation #17

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions scripts/observability/agent.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

#######################################
# Install the Observability agent in the cluster
# Arguments:
# url (SUSE Observability)
# cluster_name
# ingestion_api_key
# Examples:
# observability_agent_install https://obs.suse.com demo xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
#######################################
observability_agent_install() {
local url=$1
local cluster_name=$2
local ingestion_api_key=$3
echo "Installing Observability agent..."
helm repo add suse-observability https://charts.rancher.com/server-charts/prime/suse-observability
helm repo update

helm upgrade --install suse-observability-agent suse-observability/suse-observability-agent \
--namespace suse-observability --create-namespace \
--set stackstate.apiKey=${ingestion_api_key} \
--set stackstate.url="${url%/}/receiver/stsAgent" \
--set stackstate.cluster.name=${cluster_name}

kubectl wait pods -n suse-observability -l app.kubernetes.io/instance=suse-observability-agent --for condition=Ready 2>/dev/null
}
45 changes: 45 additions & 0 deletions scripts/observability/stackpack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,48 @@ observability_check_stackpack() {
[[ -n "$stackpack_id" ]]
return
}

#######################################
# Install a StackPack instance in SUSE Observability
# Arguments:
# url (SUSE Observability)
# service_token (SUSE Observability)
# cluster_name
# Examples:
# observability_install_stackpack https://obs.suse.com/ xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx demo
#######################################
observability_install_stackpack() {
local url=$1
local service_token=$2
local cluster_name=$3

local stackpacks
stackpacks=$(/usr/local/bin/sts stackpack list-instances --name kubernetes-v2 -o json --url $url --service-token $service_token)
if [[ $(echo $stackpacks | jq -r '.instances[] | select(.config.kubernetes_cluster_name == "'$cluster_name'") | .id') ]]; then
echo ">>> StackPack for cluster '${cluster_name}' already exists"
else
/usr/local/bin/sts stackpack install --name kubernetes-v2 --url $url --service-token $service_token -p "kubernetes_cluster_name=$cluster_name" --unlocked-strategy fail
echo ">>> StackPack for cluster '${cluster_name}' installed"
fi
}

#######################################
# Get the status of a StackPack instance in SUSE Observability
# Arguments:
# url (SUSE Observability)
# service_token (SUSE Observability)
# cluster_name
# Output:
# The status of the StackPack instance
# Examples:
# observability_stackpack_status https://obs.suse.com/ xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx demo
#######################################
observability_stackpack_status() {
local url=$1
local service_token=$2
local cluster_name=$3

local stackpacks
stackpacks=$(/usr/local/bin/sts stackpack list-instances --name kubernetes-v2 -o json --url $url --service-token $service_token)
echo $stackpacks | jq -r '.instances[] | select(.config.kubernetes_cluster_name == "'$cluster_name'") | .status'
}
Loading