Skip to content

Commit 185cf9e

Browse files
authored
Merge pull request #20 from scalyr/k8s_explorer_additional_support
Add support for installing Kubernetes Explorer dependencies / prerequisites
2 parents cad1192 + 0079a21 commit 185cf9e

File tree

25 files changed

+706
-101
lines changed

25 files changed

+706
-101
lines changed

.github/actions/install-helm-chart/action.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,18 @@ inputs:
2121
required: true
2222
default: "buster"
2323

24-
2524
runs:
2625
using: "composite"
2726
steps:
2827
- name: Install Helm chart
29-
uses: nick-fields/retry@7f8f3d9f0f62fe5925341be21c2e8314fd4f7c7c # v2.6.0
28+
uses: nick-fields/retry@b4fa57557dda8c2f30bcb2d19372cc3237190f7f # v2.8.1
3029
with:
3130
shell: bash
3231
timeout_seconds: 100
3332
max_attempts: 3
3433
command: |
34+
set -e
35+
3536
# Set write API key
3637
sed -i "s#REPLACE_ME#${{ inputs.scalyr_api_key }}#g" "${{ inputs.values_file_path }}"
3738
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: "Install Scalyr CLI tool"
2+
description: "Action which installs Scalyr CLI tool into /usr/local/bin/scalyr"
3+
4+
inputs:
5+
version:
6+
description: "Version / github ref (e.g. branch or tag) to use"
7+
required: true
8+
default: "master"
9+
10+
runs:
11+
using: "composite"
12+
steps:
13+
- name: Install Scalyr Tool
14+
uses: nick-fields/retry@b4fa57557dda8c2f30bcb2d19372cc3237190f7f # v2.8.1
15+
with:
16+
shell: bash
17+
timeout_seconds: 100
18+
max_attempts: 3
19+
command: |
20+
set -e
21+
curl https://raw.githubusercontent.com/scalyr/scalyr-tool/${{ inputs.version }}/scalyr > scalyr
22+
chmod +x scalyr
23+
sudo mv scalyr /usr/local/bin

.github/actions/setup-chart-testing-environment/action.yml

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,47 +19,39 @@ runs:
1919
steps:
2020
- name: Set up Helm
2121
id: setup-helm
22-
uses: azure/setup-helm@18bc76811624f360dbd7f18c2d4ecb32c7b87bab # v1.1
22+
uses: azure/setup-helm@b5b231a831f96336bbfeccc1329990f0005c5bb1 # v3.3
2323
with:
24-
version: v3.8.1
24+
version: "latest"
2525

26-
- uses: actions/setup-python@v2
26+
- uses: actions/setup-python@v4
2727
id: setup-python
2828
with:
29-
python-version: 3.7
29+
python-version: 3.8
3030

3131
- name: Set up chart-testing
3232
id: setup-chart-testing
33-
uses: helm/chart-testing-action@5f16c27cf7a4fa9c776ff73734df3909b2b65127 # v2.1.0
33+
uses: helm/chart-testing-action@09ed88797198755e5031f25be13da255e7e33aad # v2.3.0
3434
with:
3535
version: v3.5.0
3636

3737
- name: Create minikube Kubernetes ${{ inputs.k8s_version }} Cluster
3838
id: create-minikube-cluster
39-
# TODO: Workaround until conditions are supported natively
40-
# See https://github.com/actions/runner/issues/834
41-
uses: ChristopherHX/conditional@b4a9649204f81002ec9a4ef7d4bf7d6b2ab7fa55
39+
if: ${{ inputs.k8s_version != '' }}
40+
uses: manusa/actions-setup-minikube@a36e52547d6fb013f8873758b695ae97a353377b # v2.7.0
4241
with:
43-
if: ${{ inputs.k8s_version != '' }}
44-
step: |
45-
uses: manusa/actions-setup-minikube@a36e52547d6fb013f8873758b695ae97a353377b # v2.7.0
46-
with:
47-
minikube version: '${{ inputs.minikube_version }}'
48-
kubernetes version: '${{ inputs.k8s_version }}'
49-
github token: '${{ inputs.github_token }}'
42+
minikube version: '${{ inputs.minikube_version }}'
43+
kubernetes version: '${{ inputs.k8s_version }}'
44+
github token: '${{ inputs.github_token }}'
5045

5146
- name: Print minikube environment info
5247
id: print-k8s-cluster-info
53-
uses: ChristopherHX/conditional@b4a9649204f81002ec9a4ef7d4bf7d6b2ab7fa55
54-
with:
55-
if: ${{ inputs.k8s_version != '' }}
56-
step: |
57-
shell: bash
58-
run: |
59-
# Workaround for occasional DNS issues
60-
# kubectl -n kube-system rollout restart deployment coredns
61-
kubectl version
62-
minikube addons list
63-
kubectl get nodes
64-
kubectl cluster-info
65-
kubectl get pods -A
48+
if: ${{ inputs.k8s_version != '' }}
49+
shell: bash
50+
run: |
51+
# Workaround for occasional DNS issues
52+
# kubectl -n kube-system rollout restart deployment coredns
53+
kubectl version
54+
minikube addons list
55+
kubectl get nodes
56+
kubectl cluster-info
57+
kubectl get pods -A
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: "Verify Kubernetes Explorer Logs"
2+
description: "Action which verifies that Kubernetes and Kubernetes Explorer logs have been correctly ingested."
3+
4+
inputs:
5+
scalyr_readlog_token:
6+
description: "Scalyr readlogs API key to use"
7+
required: true
8+
scalyr_agent_pod_name:
9+
description: "Name of the scalyr agent pod."
10+
required: true
11+
12+
runs:
13+
using: "composite"
14+
steps:
15+
- name: Verify Agent Logs are Ingested
16+
shell: bash
17+
env:
18+
scalyr_readlog_token: "${{ inputs.scalyr_readlog_token}}"
19+
SCALYR_AGENT_POD_NAME: "${{ inputs.scalyr_agent_pod_name }}"
20+
run: |
21+
# Verify agent and kubernetes monitor has been started
22+
./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" $logfile="/var/log/scalyr-agent-2/agent.log" "Starting scalyr agent..."'
23+
./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" $logfile="/var/log/scalyr-agent-2/agent.log" "No checkpoints were found. All logs will be copied starting at their current end"'
24+
25+
./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" $logfile="/var/log/scalyr-agent-2/agent.log" "Cluster name detected, enabling k8s metric reporting"'
26+
./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" $logfile="/var/log/scalyr-agent-2/agent.log" "kubernetes_monitor parameters: "'
27+
28+
#./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" $logfile="/var/log/scalyr-agent-2/agent.log" "Config option '\'stop_agent_on_failure\'' is enabled"'
29+
./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" $logfile="/var/log/scalyr-agent-2/agent.log" "stop_agent_on_failure"'
30+
31+
- name: Verify Kubernetes Metrics are Ingested
32+
shell: bash
33+
env:
34+
scalyr_readlog_token: "${{ inputs.scalyr_readlog_token}}"
35+
SCALYR_AGENT_POD_NAME: "${{ inputs.scalyr_agent_pod_name }}"
36+
run: |
37+
# Verify Kubernetes metrics are being ingested
38+
./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" $logfile="/var/log/scalyr-agent-2/kubernetes_monitor.log" "k8s-daemon-set=\"scalyr-agent\""'
39+
40+
# Verify Kubernetes events are being ingested
41+
./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" $logfile="/var/log/scalyr-agent-2/kubernetes_events.log" "event="'
42+
43+
- name: Verify Kubernetes Explorer Logs and Metrics are Ingested
44+
shell: bash
45+
env:
46+
scalyr_readlog_token: "${{ inputs.scalyr_readlog_token}}"
47+
SCALYR_AGENT_POD_NAME: "${{ inputs.scalyr_agent_pod_name }}"
48+
run: |
49+
# Verify Kubernetes Explorer logs are there
50+
./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" $logfile="/var/log/scalyr-agent-2/agent.log" "monitor:openmetrics_monitor"'
51+
./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" $logfile="/var/log/scalyr-agent-2/agent.log" "Starting monitor openmetrics_monitor"'
52+
./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" $logfile="/var/log/scalyr-agent-2/agent_debug.log" "Adding new monitor with config:"'
53+
54+
# Assert that Kubernetes Explorer metrics which we scrape from 2 annotated pods are there
55+
./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" logfile contains "node-exporter" k8s-cluster="k8s-explorer-e2e-tests" k8s-daemon-set="node-exporter" "level=info collector=cpu"'
56+
57+
./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" monitor="openmetrics_monitor" logfile contains "kubernetes-api-cadvisor-metrics.log" k8s-cluster="k8s-explorer-e2e-tests"'
58+
./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" monitor="openmetrics_monitor" logfile contains "kubernetes-api-cadvisor-metrics.log" k8s-cluster="k8s-explorer-e2e-tests" "container_start_time_seconds "'
59+
./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" monitor="openmetrics_monitor" logfile contains "kubernetes-api-cadvisor-metrics.log" k8s-cluster="k8s-explorer-e2e-tests" "container_spec_memory_limit_bytes "'
60+
61+
# Verify metrics scraped from node-exporter and kube-state-metrics are available
62+
./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" monitor="openmetrics_monitor" logfile contains "node-exporter" k8s-cluster="k8s-explorer-e2e-tests"'
63+
./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" monitor="openmetrics_monitor" logfile contains "node-exporter" k8s-cluster="k8s-explorer-e2e-tests" "process_resident_memory_bytes"'
64+
65+
./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" monitor="openmetrics_monitor" $logfile contains "kube-state-metrics" k8s-cluster="k8s-explorer-e2e-tests" "kube_storageclass_labels 1 "'
66+
./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" monitor="openmetrics_monitor" $logfile contains "kube-state-metrics" k8s-cluster="k8s-explorer-e2e-tests" "namespace=\"default\" secret=\"scalyr-agent-scalyr-api-key\" type=\"Opaque\""'
67+
68+
# Assert that Java app metrics are there
69+
./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" monitor="openmetrics_monitor" $logfile contains "java-hello-world" k8s-cluster="k8s-explorer-e2e-tests" "java_lang_threading_objectmonitorusagesupported "'
70+
./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" monitor="openmetrics_monitor" $logfile contains "java-hello-world" k8s-cluster="k8s-explorer-e2e-tests" "jvm_memory_pool_bytes_committed "'

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"

0 commit comments

Comments
 (0)