Skip to content

Commit a4a75bf

Browse files
authored
Merge pull request #22 from scalyr/e2e_tests_k8s_image_cache
Various chart improvements
2 parents 95c3cbe + 8dba1fc commit a4a75bf

File tree

19 files changed

+127
-52
lines changed

19 files changed

+127
-52
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ inputs:
1111
start_sleep_delay:
1212
description: "How many seconds to sleep / wait after installing the chart for the pod to start up"
1313
required: true
14-
default: 20
14+
default: 30
1515
ingest_sleep_delay:
1616
description: "How many seconds to sleep / wait after the pod has been started up for initial ingestion"
1717
required: true
@@ -28,7 +28,7 @@ runs:
2828
uses: nick-fields/retry@b4fa57557dda8c2f30bcb2d19372cc3237190f7f # v2.8.1
2929
with:
3030
shell: bash
31-
timeout_seconds: 100
31+
timeout_seconds: 130
3232
max_attempts: 3
3333
command: |
3434
set -e
@@ -42,7 +42,9 @@ runs:
4242
# Install chart
4343
helm install --debug --wait --values "${{ inputs.values_file_path }}" scalyr-agent charts/scalyr-agent
4444
45-
# Verify deployment is either there or not there - depending on the controller type
45+
# Verify damonset / deployment is there - it depends on the run type
46+
kubectl get daemonset
47+
kubectl get daemonset scalyr-agent || true
4648
kubectl get deployments
4749
kubectl get deployment scalyr-agent || true
4850

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ runs:
3232
id: setup-chart-testing
3333
uses: helm/chart-testing-action@09ed88797198755e5031f25be13da255e7e33aad # v2.3.0
3434
with:
35-
version: v3.5.0
35+
version: v3.7.0
3636

3737
- name: Create minikube Kubernetes ${{ inputs.k8s_version }} Cluster
3838
id: create-minikube-cluster
@@ -41,6 +41,7 @@ runs:
4141
with:
4242
minikube version: '${{ inputs.minikube_version }}'
4343
kubernetes version: '${{ inputs.k8s_version }}'
44+
start args: '--wait=all'
4445
github token: '${{ inputs.github_token }}'
4546

4647
- name: Print minikube environment info

.github/actions/verify-k8s-explorer-logs/action.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,15 @@ runs:
5252
./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" $logfile="/var/log/scalyr-agent-2/agent_debug.log" "Adding new monitor with config:"'
5353
5454
# 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"'
55+
56+
./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" monitor="openmetrics_monitor" logfile contains "kubernetes-api-metrics.log" k8s-cluster="k8s-explorer-e2e-tests" "kubelet_runtime_operations_total "'
5657
5758
./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"'
5859
./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 "'
5960
./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 "'
6061
6162
# Verify metrics scraped from node-exporter and kube-state-metrics are available
63+
./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"'
6264
./ci/scripts/scalyr-query.sh '$serverHost="'${SCALYR_AGENT_POD_NAME}'" monitor="openmetrics_monitor" logfile contains "node-exporter" k8s-cluster="k8s-explorer-e2e-tests"'
6365
./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"'
6466

.github/workflows/end_to_end_tests.yaml

Lines changed: 67 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# Those tests verify that the chart can be installed and that it correctly configured agent
33
# ingestion for various options (daemonset mode, deployment mode, k8s cluster metrics are ingested,
44
# pod logs are ingested, etc.)
5+
# NOTE: To reduce the size of the build matrix and speed up test run, we only run single set of tests using both Buster
6+
# and Alpine Linux based Docker image. Rest of the tests only exercise single image.
57
name: "End to End Tests"
68

79
on:
@@ -38,6 +40,7 @@ jobs:
3840
runs-on: ubuntu-latest
3941

4042
needs: pre_job
43+
timeout-minutes: 15
4144
# NOTE: We always want to run job on main branch
4245
if: ${{ needs.pre_job.outputs.should_skip != 'true' || github.ref == 'refs/heads/main' }}
4346

@@ -55,7 +58,7 @@ jobs:
5558
- name: Checkout Repository
5659
uses: actions/checkout@v3
5760
with:
58-
fetch-depth: 0
61+
fetch-depth: 1
5962

6063
- name: Set up Chart Testing Environment and Kubernetes Cluster
6164
uses: ./.github/actions/setup-chart-testing-environment/
@@ -136,6 +139,7 @@ jobs:
136139
runs-on: ubuntu-latest
137140

138141
needs: pre_job
142+
timeout-minutes: 15
139143
# NOTE: We always want to run job on main branch
140144
if: ${{ needs.pre_job.outputs.should_skip != 'true' || github.ref == 'refs/heads/main' }}
141145

@@ -147,13 +151,12 @@ jobs:
147151
- 'v1.24.3'
148152
image_type:
149153
- "buster"
150-
- "alpine"
151154

152155
steps:
153156
- name: Checkout Repository
154157
uses: actions/checkout@v3
155158
with:
156-
fetch-depth: 0
159+
fetch-depth: 1
157160

158161
- name: Set up Chart Testing Environment and Kubernetes Cluster
159162
uses: ./.github/actions/setup-chart-testing-environment/
@@ -207,6 +210,7 @@ jobs:
207210
runs-on: ubuntu-latest
208211

209212
needs: pre_job
213+
timeout-minutes: 15
210214
# NOTE: We always want to run job on main branch
211215
if: ${{ needs.pre_job.outputs.should_skip != 'true' || github.ref == 'refs/heads/main' }}
212216

@@ -215,16 +219,17 @@ jobs:
215219
matrix:
216220
k8s_version:
217221
- 'v1.22.2'
218-
- 'v1.24.3'
222+
# Started randomly failing without any changes on our side. Looks like weird DNS /
223+
# networking issue inside minikube when running on GHA (runs fine locally)
224+
#- 'v1.24.3'
219225
image_type:
220226
- "buster"
221-
- "alpine"
222227

223228
steps:
224229
- name: Checkout Repository
225230
uses: actions/checkout@v3
226231
with:
227-
fetch-depth: 0
232+
fetch-depth: 1
228233

229234
- name: Set up Chart Testing Environment and Kubernetes Cluster
230235
uses: ./.github/actions/setup-chart-testing-environment/
@@ -242,21 +247,39 @@ jobs:
242247
values_file_path: "ci/daemonset-agent-values-with-k8s-explorer.yaml"
243248
image_type: "${{ matrix.image_type }}"
244249

250+
- name: Checkout Agent Repository
251+
uses: actions/checkout@v3
252+
with:
253+
repository: "scalyr/scalyr-agent-2"
254+
path: "scalyr-agent-2"
255+
fetch-depth: 1
256+
257+
- name: Set up Docker Buildx
258+
uses: docker/setup-buildx-action@v2
259+
260+
# Here we build the dummy Java app image which exposes JMX metrics via exporter
261+
# TODO: Cache this dummy / test image for faster builds
262+
- name: Build Mock Java App Docker Image
263+
uses: docker/build-push-action@v3
264+
with:
265+
context: scalyr-agent-2/tests/e2e/k8s_om_monitor/java-hello-world/
266+
tags: java-hello-world:latest
267+
# load image into docker
268+
load: true
269+
push: false
270+
#push: true
271+
#tags: localhost:5000/java-hello-world:latest
272+
cache-from: type=gha
273+
cache-to: type=gha,mode=max
274+
245275
# Create mock pods and exporters which will be scrapped by the monitor
246276
# (step taken from scalyr-agent-2 repo)
247277
- name: Create mock pods and exporters
248278
run: |
249279
set -e
250280
251-
git clone --depth 1 https://github.com/scalyr/scalyr-agent-2.git
252281
pushd scalyr-agent-2/
253282
254-
# Here we build the dummy Java app image which exposes JMX metrics via exporter
255-
# TODO: Cache this dummy / test image for faster builds
256-
pushd tests/e2e/k8s_om_monitor/java-hello-world
257-
docker build -t java-hello-world .
258-
popd
259-
260283
docker image ls
261284
minikube image load java-hello-world:latest
262285
@@ -305,6 +328,7 @@ jobs:
305328
runs-on: ubuntu-latest
306329

307330
needs: pre_job
331+
timeout-minutes: 15
308332
# NOTE: We always want to run job on main branch
309333
if: ${{ needs.pre_job.outputs.should_skip != 'true' || github.ref == 'refs/heads/main' }}
310334

@@ -313,16 +337,17 @@ jobs:
313337
matrix:
314338
k8s_version:
315339
- 'v1.22.2'
316-
- 'v1.24.3'
340+
# Started randomly failing without any changes on our side. Looks like weird DNS /
341+
# networking issue inside minikube when running on GHA (runs fine locally)
342+
#- 'v1.24.3'
317343
image_type:
318344
- "buster"
319-
- "alpine"
320345

321346
steps:
322347
- name: Checkout Repository
323348
uses: actions/checkout@v3
324349
with:
325-
fetch-depth: 0
350+
fetch-depth: 1
326351

327352
- name: Set up Chart Testing Environment and Kubernetes Cluster
328353
uses: ./.github/actions/setup-chart-testing-environment/
@@ -340,30 +365,42 @@ jobs:
340365
values_file_path: "ci/daemonset-agent-values-with-k8s-explorer-with-deps.yaml"
341366
image_type: "${{ matrix.image_type }}"
342367

368+
- name: Checkout Agent Repository
369+
uses: actions/checkout@v3
370+
with:
371+
repository: "scalyr/scalyr-agent-2"
372+
path: "scalyr-agent-2"
373+
fetch-depth: 1
374+
375+
- name: Set up Docker Buildx
376+
uses: docker/setup-buildx-action@v2
377+
378+
# Here we build the dummy Java app image which exposes JMX metrics via exporter
379+
# TODO: Cache this dummy / test image for faster builds
380+
- name: Build Mock Java App Docker Image
381+
uses: docker/build-push-action@v3
382+
with:
383+
context: scalyr-agent-2/tests/e2e/k8s_om_monitor/java-hello-world/
384+
tags: java-hello-world:latest
385+
# load image into docker
386+
load: true
387+
push: false
388+
#push: true
389+
#tags: localhost:5000/java-hello-world:latest
390+
cache-from: type=gha
391+
cache-to: type=gha,mode=max
392+
343393
- name: Create mock pods and exporters
344394
run: |
345395
set -e
346396
347-
git clone --depth 1 https://github.com/scalyr/scalyr-agent-2.git
348397
pushd scalyr-agent-2/
349398
350-
# Here we build the dummy Java app image which exposes JMX metrics via exporter
351-
# TODO: Cache this dummy / test image for faster builds
352-
pushd tests/e2e/k8s_om_monitor/java-hello-world
353-
docker build -t java-hello-world .
354-
popd
355-
356399
docker image ls
357400
minikube image load java-hello-world:latest
358401
359402
kubectl create namespace monitoring
360403
361-
# 1. node exporter pod
362-
kubectl apply -f tests/e2e/k8s_om_monitor/node_exporter.yaml
363-
364-
# 2. kube state metrics deployment
365-
kubectl apply -k tests/e2e/k8s_om_monitor/kube-state-metrics/
366-
367404
# 3. Install dummy java app container with jmx exporter side
368405
kubectl apply -f tests/e2e/k8s_om_monitor/java_app_deployment.yaml
369406
popd
@@ -372,7 +409,7 @@ jobs:
372409
kubectl get pods -A
373410
374411
# Verify dependencies have been installed and are running
375-
echo "Verifying node-exporter and kube-state-metrics pods are running"
412+
echo "Verifying node-exporter and kube-state-metrics pods are running"
376413
kubectl get pods -A | grep node-exporter
377414
kubectl get pods -A | grep kube-state-metrics
378415

.github/workflows/lint_tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
- name: Checkout Repository
4444
uses: actions/checkout@v3
4545
with:
46-
fetch-depth: 0
46+
fetch-depth: 1
4747

4848
- name: Set up Chart Testing Environment
4949
uses: ./.github/actions/setup-chart-testing-environment/
@@ -104,7 +104,7 @@ jobs:
104104
run: |
105105
# Write test values to a file which is used by ct install
106106
mkdir -p charts/scalyr-agent/ci/
107-
echo -e 'controllerType: "daemonset"\nscalyr:\n apiKey: "${API_KEY}"' > charts/scalyr-agent/ci/test-values.yaml
107+
echo -e 'controllerType: "daemonset"\nscalyr:\n apiKey: "${API_KEY}"\n k8s:\n clusterName: "k8s-explorer-e2e-tests"' > charts/scalyr-agent/ci/test-values.yaml
108108
109109
ct install --debug --config ci/ct.yaml
110110
@@ -116,7 +116,7 @@ jobs:
116116
run: |
117117
# Write test values to a file which is used by ct install
118118
mkdir -p charts/scalyr-agent/ci/
119-
echo -e 'controllerType: "deployment"\nscalyr:\n apiKey: "${API_KEY}"' > charts/scalyr-agent/ci/test-values.yaml
119+
echo -e 'controllerType: "deployment"\nscalyr:\n apiKey: "${API_KEY}"\n k8s:\n clusterName: "k8s-explorer-e2e-tests"' > charts/scalyr-agent/ci/test-values.yaml
120120
121121
ct install --debug --config ci/ct.yaml
122122

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
- name: Checkout
3232
uses: actions/checkout@v3
3333
with:
34+
# here we want to check out all the branches
3435
fetch-depth: 0
3536

3637
- name: Configure Git

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
For actual scalyr agent changelog, please see https://github.com/scalyr/scalyr-agent-2/blob/release/CHANGELOG.md
44

5+
## 0.2.19
6+
7+
- Update chart to throw an error if required ``scalyr.k8s.clusterName`` value is not specified.
8+
9+
- Update Kubernetes Explorer config to make sure we also scrape Kubernetes API metrics.
10+
511
## 0.2.18
612

713
- Add new ``scalyr.k8s.installExplorerDependencies`` chart config option.

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ database service etc.).
1616
Use
1717

1818
```bash
19-
helm install <name of release> scalyr-agent --repo https://scalyr.github.io/helm-scalyr/
19+
helm install <name of release> scalyr-agent --repo https://scalyr.github.io/helm-scalyr/ --set scalyr.apiKey="<your write logs api key>" --set scalyr.k8s.clusterName="<your-k8s-cluster-name>"
2020
```
2121

2222
to install this chart.
@@ -85,7 +85,7 @@ This chart also supports configuring the agent for the Kubernetes Explorer funct
8585
To install the chart enabling Kubernetes Explorer functionality, you can use the following command:
8686

8787
```bash
88-
helm install <name of release> scalyr-agent --repo https://scalyr.github.io/helm-scalyr/ --set scalyr.k8s.enableExplorer=true
88+
helm install <name of release> scalyr-agent --repo https://scalyr.github.io/helm-scalyr/ --set scalyr.apiKey="<your write logs api key>" --set scalyr.k8s.clusterName="<your-k8s-cluster-name>" --set scalyr.k8s.enableExplorer=true
8989
```
9090

9191
This command will enable Kubernetes Explorer functionality, but it won't install additional
@@ -101,7 +101,7 @@ components for you.
101101
You can do that using the command below:
102102

103103
```bash
104-
helm install <name of release> scalyr-agent --repo https://scalyr.github.io/helm-scalyr/ --set scalyr.k8s.enableExplorer=true --set scalyr.k8s.installExplorerDependencies=true
104+
helm install <name of release> scalyr-agent --repo https://scalyr.github.io/helm-scalyr/ --set scalyr.apiKey="<your write logs api key>" --set scalyr.k8s.clusterName="<your-k8s-cluster-name>" --set scalyr.k8s.enableExplorer=true --set scalyr.k8s.installExplorerDependencies=true
105105
```
106106

107107
This functionality is primarily meant to be used for Kubernetes Explorer evaluation purposes when
@@ -118,7 +118,7 @@ very good reason for it, you should never disable certificate validation in prod
118118
For example:
119119

120120
```bash
121-
helm install <name of release> scalyr-agent --repo https://scalyr.github.io/helm-scalyr/ --set scalyr.k8s.enableExplorer=true --set scalyr.k8s.verifyKubeletQueries=false --set scalyr.k8s.eventsIgnoreMaster=false
121+
helm install <name of release> scalyr-agent --repo https://scalyr.github.io/helm-scalyr/ --set scalyr.apiKey="<your write logs api key>" --set scalyr.k8s.clusterName="<your-k8s-cluster-name>" --set scalyr.k8s.enableExplorer=true --set scalyr.k8s.verifyKubeletQueries=false --set scalyr.k8s.eventsIgnoreMaster=false
122122
```
123123

124124
This command also sets ``scalyr.k8s.eventsIgnoreMaster`` option to ``false``. This is needed when
@@ -130,6 +130,8 @@ default.
130130

131131
For chart changelog, please see <https://github.com/scalyr/helm-scalyr/blob/main/CHANGELOG.md>.
132132

133+
For agent changelog, please see <https://github.com/scalyr/scalyr-agent-2/blob/release/CHANGELOG.md>.
134+
133135
## Maintainers
134136

135137
| Name | Email | Url |
@@ -256,7 +258,7 @@ minikube start
256258
ct lint --debug --config ci/ct.yaml
257259

258260
# To use valid API key
259-
echo -e 'scalyr:\n apiKey: "SCALYR_TEST_WRITE_API_KEY"' > charts/scalyr-agent/ci//test-values.yaml
261+
echo -e 'scalyr:\n apiKey: "SCALYR_TEST_WRITE_API_KEY"' > charts/scalyr-agent/ci/test-values.yaml
260262
261263
ct install --debug --config ci/ct.yaml
262264
```

README.md.gotmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ minikube start
100100
ct lint --debug --config ci/ct.yaml
101101

102102
# To use valid API key
103-
echo -e 'scalyr:\n apiKey: "SCALYR_TEST_WRITE_API_KEY"' > charts/scalyr-agent/ci//test-values.yaml
103+
echo -e 'scalyr:\n apiKey: "SCALYR_TEST_WRITE_API_KEY"' > charts/scalyr-agent/ci/test-values.yaml
104104

105105
ct install --debug
106106
```

0 commit comments

Comments
 (0)