Skip to content

Commit d57f235

Browse files
authored
Merge pull request #1571 from snyk/chore/remove-dead-code-staging
chore: remove dead code
2 parents 3a5ca52 + 4e97fc4 commit d57f235

File tree

10 files changed

+76
-1623
lines changed

10 files changed

+76
-1623
lines changed

.circleci/config.yml

Lines changed: 5 additions & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -26,33 +26,6 @@ jobs:
2626
mode: auto
2727
release-branch: master
2828
open-source-additional-arguments: --exclude=test
29-
aks_integration_tests:
30-
docker:
31-
- image: cimg/node:18.19.1
32-
resource_class: large
33-
steps:
34-
- checkout
35-
- setup_remote_docker
36-
- run:
37-
command: npm ci
38-
- install_python_requests
39-
- azure-cli/install
40-
- run:
41-
command: mkdir -p /tmp/logs/test/integration/aks
42-
name: Create temp dir for logs
43-
- run:
44-
command: |
45-
export KUBERNETES_MONITOR_IMAGE_NAME_AND_TAG=$(./scripts/circleci-jobs/setup-integration-tests.py)
46-
.circleci/do-exclusively --branch staging --job ${CIRCLE_JOB} npm run test:integration:aks:yaml
47-
name: Integration tests AKS
48-
- run:
49-
command: |
50-
./scripts/slack/notify_failure_on_branch.py "${CIRCLE_BRANCH}" "${CIRCLE_JOB}" "${CIRCLE_BUILD_URL}" "${CIRCLE_PULL_REQUEST}" "${SLACK_WEBHOOK}"
51-
name: Notify Slack on failure
52-
when: on_fail
53-
- store_artifacts:
54-
path: /tmp/logs/test/integration/aks
55-
working_directory: ~/kubernetes-monitor
5629
build_image:
5730
docker:
5831
- image: cimg/base:current
@@ -143,150 +116,6 @@ jobs:
143116
name: Notify Slack on failure
144117
when: on_fail
145118
working_directory: ~/kubernetes-monitor
146-
deploy_to_sysdig_integration_cluster:
147-
docker:
148-
- image: cimg/base:stable
149-
steps:
150-
- checkout
151-
- run:
152-
command: |
153-
LATEST_KUBECTL_VERSION=$(curl -L -s https://dl.k8s.io/release/stable.txt)
154-
curl -LO "https://dl.k8s.io/release/${LATEST_KUBECTL_VERSION}/bin/linux/amd64/kubectl"
155-
curl -LO "https://dl.k8s.io/${LATEST_KUBECTL_VERSION}/bin/linux/amd64/kubectl.sha256"
156-
echo "$(<kubectl.sha256) kubectl" | sha256sum --check
157-
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
158-
# Ensure the kubectl command is runnable
159-
kubectl version --client
160-
# Prepare kubeconfig to point to the cluster
161-
mkdir ~/.kube || true
162-
printf "%s" "${SYSDIG_KUBECONFIG}" | base64 -d > ~/.kube/config
163-
name: Install and prepare kubectl
164-
- run:
165-
command: |
166-
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
167-
chmod 700 get_helm.sh
168-
./get_helm.sh
169-
# Ensure the Helm command is runnable
170-
helm version
171-
name: Install Helm
172-
- run:
173-
command: |
174-
LATEST_TAG_WITH_V=`git describe --abbrev=0 --tags ${CIRCLE_SHA1}`
175-
LATEST_TAG=${LATEST_TAG_WITH_V:1}-approved
176-
./scripts/slack/notify_deploy.py $LATEST_TAG sysdig-integration-cluster
177-
helm upgrade --install snyk-monitor ./snyk-monitor --namespace snyk-monitor --set image.tag=${LATEST_TAG} --set clusterName="Sysdig cluster" --set sysdig.enabled=true
178-
name: Deploy to shared Sysdig cluster
179-
- run:
180-
command: ./scripts/slack/notify_failure.py "${CIRCLE_BRANCH}" "${CIRCLE_JOB}" "${CIRCLE_BUILD_URL}" "${CIRCLE_PULL_REQUEST}" "${SLACK_WEBHOOK}"
181-
name: Notify Slack on failure
182-
when: on_fail
183-
working_directory: ~/kubernetes-monitor
184-
eks_integration_tests:
185-
docker:
186-
- image: cimg/node:18.19.1
187-
resource_class: large
188-
steps:
189-
- checkout
190-
- setup_remote_docker
191-
- run:
192-
command: npm ci
193-
- install_python_requests
194-
- aws-cli/install:
195-
override-installed: true
196-
- run:
197-
command: mkdir -p /tmp/logs/test/integration/eks
198-
name: Create temp dir for logs
199-
- run:
200-
command: |
201-
export KUBERNETES_MONITOR_IMAGE_NAME_AND_TAG=$(./scripts/circleci-jobs/setup-integration-tests.py)
202-
.circleci/do-exclusively --branch staging --job ${CIRCLE_JOB} npm run test:integration:eks:yaml
203-
name: Integration tests EKS
204-
- run:
205-
command: |
206-
./scripts/slack/notify_failure_on_branch.py "${CIRCLE_BRANCH}" "${CIRCLE_JOB}" "${CIRCLE_BUILD_URL}" "${CIRCLE_PULL_REQUEST}" "${SLACK_WEBHOOK}"
207-
name: Notify Slack on failure
208-
when: on_fail
209-
- store_artifacts:
210-
path: /tmp/logs/test/integration/eks
211-
working_directory: ~/kubernetes-monitor
212-
integration_tests:
213-
docker:
214-
- image: cimg/node:18.19.1
215-
resource_class: large
216-
steps:
217-
- checkout
218-
- setup_remote_docker
219-
- run:
220-
command: npm ci
221-
- install_python_requests
222-
- run:
223-
command: mkdir -p /tmp/logs/test/integration/kind
224-
name: create temp dir for logs
225-
- run:
226-
command: |
227-
export KUBERNETES_MONITOR_IMAGE_NAME_AND_TAG=$(./scripts/circleci-jobs/setup-integration-tests.py)
228-
npm run test:integration:kind:yaml
229-
name: Integration tests
230-
- run:
231-
command: |
232-
./scripts/slack/notify_failure_on_branch.py "${CIRCLE_BRANCH}" "${CIRCLE_JOB}" "${CIRCLE_BUILD_URL}" "${CIRCLE_PULL_REQUEST}" "${SLACK_WEBHOOK}"
233-
name: Notify Slack on failure
234-
when: on_fail
235-
- store_artifacts:
236-
path: /tmp/logs/test/integration/kind
237-
working_directory: ~/kubernetes-monitor
238-
integration_tests_helm:
239-
docker:
240-
- image: cimg/node:18.19.1
241-
resource_class: large
242-
steps:
243-
- checkout
244-
- setup_remote_docker
245-
- run:
246-
command: npm ci
247-
- install_python_requests
248-
- run:
249-
command: mkdir -p /tmp/logs/test/integration/kind-helm
250-
name: Create temporary directory for logs
251-
- run:
252-
command: |
253-
export KUBERNETES_MONITOR_IMAGE_NAME_AND_TAG=$(./scripts/circleci-jobs/setup-integration-tests.py)
254-
npm run test:integration:kind:helm
255-
name: Integration tests with Helm deployment
256-
- run:
257-
command: |
258-
./scripts/slack/notify_failure_on_branch.py "${CIRCLE_BRANCH}" "${CIRCLE_JOB}" "${CIRCLE_BUILD_URL}" "${CIRCLE_PULL_REQUEST}" "${SLACK_WEBHOOK}"
259-
name: Notify Slack on failure
260-
when: on_fail
261-
- store_artifacts:
262-
path: /tmp/logs/test/integration/kind-helm
263-
working_directory: ~/kubernetes-monitor
264-
integration_tests_proxy:
265-
docker:
266-
- image: cimg/node:18.19.1
267-
resource_class: large
268-
steps:
269-
- checkout
270-
- setup_remote_docker
271-
- run:
272-
command: npm ci
273-
- install_python_requests
274-
- run:
275-
command: mkdir -p /tmp/logs/test/integration/proxy
276-
name: Create temporary directory for logs
277-
- run:
278-
command: |
279-
export KUBERNETES_MONITOR_IMAGE_NAME_AND_TAG=$(./scripts/circleci-jobs/setup-integration-tests.py)
280-
npm run test:integration:kind:proxy
281-
name: Integration tests with proxy
282-
- run:
283-
command: |
284-
./scripts/slack/notify_failure_on_branch.py "${CIRCLE_BRANCH}" "${CIRCLE_JOB}" "${CIRCLE_BUILD_URL}" "${CIRCLE_PULL_REQUEST}" "${SLACK_WEBHOOK}"
285-
name: Notify Slack on failure
286-
when: on_fail
287-
- store_artifacts:
288-
path: /tmp/logs/test/integration/proxy
289-
working_directory: ~/kubernetes-monitor
290119
lint:
291120
docker:
292121
- image: cimg/node:18.19.1
@@ -479,6 +308,7 @@ workflows:
479308
- deploy_to_prod:
480309
context:
481310
- team-container-integration-circleci
311+
- kubernetes-monitor
482312
filters:
483313
branches:
484314
only:
@@ -517,7 +347,10 @@ workflows:
517347
- unit_tests
518348
- system_tests
519349
- prepare_to_deploy:
520-
context: team-container-integration
350+
context:
351+
- team-container-integration
352+
- team-container-integration-circleci
353+
- kubernetes-monitor
521354
filters:
522355
branches:
523356
only:

.circleci/do-exclusively

Lines changed: 0 additions & 89 deletions
This file was deleted.

Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ RUN --mount=type=secret,id=gh_token,required=true \
1717
FROM --platform=linux/amd64 node:18-alpine3.20
1818

1919
LABEL name="Snyk Controller" \
20-
maintainer="[email protected]" \
21-
vendor="Snyk Ltd" \
22-
summary="Snyk integration for Kubernetes" \
23-
description="Snyk Controller enables you to import and test your running workloads and identify vulnerabilities in their associated images and configurations that might make those workloads less secure."
20+
maintainer="[email protected]" \
21+
vendor="Snyk Ltd" \
22+
summary="Snyk integration for Kubernetes" \
23+
description="Snyk Controller enables you to import and test your running workloads and identify vulnerabilities in their associated images and configurations that might make those workloads less secure."
2424

2525
COPY LICENSE /licenses/LICENSE
2626

README.md

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,64 @@
1+
# Testing the Kubernetes-Monitor
12

2-
[![Known Vulnerabilities](https://snyk.io/test/github/snyk/kubernetes-monitor/badge.svg)](https://snyk.io/test/github/snyk/kubernetes-monitor)
3+
- [Testing the Kubernetes-Monitor](#testing-the-kubernetes-monitor)
4+
- [Unit Tests](#unit-tests)
5+
- [System Tests](#system-tests)
6+
- [Debugging with Tilt](#debugging-with-tilt)
7+
- [Start a debugging session](#start-a-debugging-session)
8+
- [Errors with read-only file system](#errors-with-read-only-file-system)
9+
- [Cleaning up](#cleaning-up)
310

4-
# snyk/kubernetes-monitor #
11+
The Kubernetes-Monitor has different testing suites, each with different purposes and requirements.
12+
All our tests prefer a blackbox approach whenever possible.
513

6-
## Summary ##
14+
Different tests have different requirements in terms of software and environment variables. Requirements specific to one test suite will be described in each section, but the requirements shared by all of them are:
715

8-
A containerized application that is deployed with Helm. Monitors the security of a Kubernetes cluster by analyzing container images.
16+
1. npm
17+
2. Node (v10 or higher)
918

10-
## Prerequisites ##
19+
In order to run the Kubernetes-Monitor's tests, please run
20+
`npm test`.
1121

12-
* 50 GiB of storage in the form of [emptyDir](https://kubernetes.io/docs/concepts/storage/volumes/#emptydir) or a [PersistentVolumeClaim](https://kubernetes.io/docs/concepts/storage/persistent-volumes/).
13-
* External internet access from the Kubernetes cluster to `api.snyk.io`.
14-
* 1 CPU, 2 GiB RAM
15-
* 1 Kubernetes worker node of type `linux/amd64` - supported and tested only on the AMD64 CPU architecture
22+
## Unit Tests
1623

17-
Supported Kubernetes distributions:
24+
These tests aim to check a single function, class or module.
25+
Our unit tests aren't thoroughly mocked, resulting in some tests' code reaching the Kubernetes client library we're using, adding noise and/or failures to some unit tests.
26+
Until this is fixed, one workaround is setting one's KUBECONFIG environment variable to a valid kubeconfig file.
1827

19-
* Any *Generally Available* Kubernetes Certified distribution, for example: GKE, AKS, EKS, OCP.
28+
Run with `npm run test:unit`.
2029

21-
Tested with the following [Security Context Constraint](scc.txt) on OCP.
30+
## System Tests
2231

23-
## Installation with Helm ##
32+
System tests are supposed to test the Kubernetes-Monitor as a stand-alone component with as little external dependencies as possible. They are also supposed to completely cover the core functionality, so mocking or ignoring the Kubernetes API is out of the question.
33+
The resulting infrastructure is comprised of a local KinD cluster (like our integration tests) but does not install the Kubernetes-Monitor inside it. Rather, it runs the Kubernetes-Monitor's code as part of the test, and configures it against the KinD cluster.
34+
This means we're not running in the real runtime environment we expect to run (a Kubernetes cluster), but it's much easier to test the Monitor's outgoing requests or even internal state if we choose to, instead of relying on the Upstream service's state and API.
2435

25-
Please refer to the [Helm chart installation instructions](./snyk-monitor/README.md).
36+
This test requires Skopeo for MacOS machines, but will install it for Linux machines that don't have it.
2637

27-
## Documentation ##
38+
Run with `npm run test:system`.
2839

29-
For detailed documentation and support, please refer to the [Snyk Kubernetes integration documentation](https://docs.snyk.io/products/snyk-container/kubernetes-workload-and-image-scanning).
40+
## Debugging with Tilt
41+
42+
Tilt allows you to run and debug the snyk-monitor while it is running in a container. Tilt deploys the snyk-monitor using the same Helm chart that we publish to users.
43+
44+
You can download Tilt from the [Tilt GitHub repository](https://github.com/tilt-dev/tilt#install-tilt).
45+
46+
### Start a debugging session
47+
48+
First, ensure you have the snyk-monitor namespace set up and the snyk-monitor Secret with your integration ID and dockercfg (as per the prerequisites for installing snyk-monitor).
49+
50+
Finally, put breakpoints in the code and run `tilt up`.
51+
52+
### Errors with read-only file system
53+
54+
If you see an error like the following...
55+
56+
```shell
57+
Error: EROFS: read-only file system, mkdir '/srv/app/.npm/_npx'
58+
```
59+
60+
... it means that the `readOnlyRootFilesystem` protection on the snyk-monitor Helm Deployment causes issues with Tilt. This can be fixed by removing the `readOnlyRootFilesystem: true` value from the Helm chart located in `snyk-monitor/templates/deployment.yaml`.
61+
62+
### Cleaning up
63+
64+
Run `tilt down` to tear down the debugging session.

0 commit comments

Comments
 (0)