Skip to content

Commit b1dc9ac

Browse files
authored
Merge pull request #157 from snyk/chore/static-analysis-docs
chore: static analysis docs
2 parents 91b97b8 + 96434cd commit b1dc9ac

File tree

2 files changed

+29
-18
lines changed

2 files changed

+29
-18
lines changed

README.md

+13-14
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ Container to monitor Kubernetes clusters' security
55

66
## Prerequisites ##
77

8-
*Note that at present the monitor works only if using Docker as the container runtime.*
8+
*Note that by default the monitor uses Docker to scan your cluster and requires Docker to be your container runtime.*
9+
*Alternatively, you can enable static analysis, which allows the use of any container runtime.*
910

1011
The Snyk monitor (`kubernetes-monitor`) requires some minimal configuration items in order to work correctly.
1112

12-
As with any k8s deployment, the `kubernetes-monitor` runs within a single namespace.
13+
As with any Kubernetes deployment, the `kubernetes-monitor` runs within a single namespace.
1314
If you do not already have access to a namespace where you want to deploy the monitor, you can run the following command to create one:
1415
```shell
1516
kubectl create namespace snyk-monitor
@@ -19,29 +20,29 @@ Notice our namespace is called _snyk-monitor_ and it is used for the following c
1920

2021
The Snyk monitor relies on using your Snyk Integration ID, and using a `dockercfg` file. The `dockercfg` file is necessary to allow the monitor to look up images in private registries. Usually a copy of the `dockercfg` resides in `$HOME/.docker/config.json`.
2122

22-
Both of these items must be provided by a k8s secret. The secret must be called _snyk-monitor_. The steps to create the secret are as such:
23+
Both of these items must be provided from a Kubernetes secret. The secret must be called _snyk-monitor_. The steps to create the secret are as such:
2324

2425
1. Create a file named `dockercfg.json`. Store your `dockercfg` in there; it should look like this:
2526

2627
```json
2728
{
2829
"auths": {
2930
"gcr.io": {
30-
"auth": "<BASE64-ENCODED-AUTH-DETAILS>"
31+
"auth": "BASE64-ENCODED-AUTH-DETAILS"
3132
}
3233
// Add other registries as necessary
3334
}
3435
}
3536
```
3637

3738
2. Locate your Snyk Integration ID from the Snyk Integrations page (navigate to https://app.snyk.io/org/YOUR-ORGANIZATION-NAME/manage/integrations/kubernetes) and copy it.
38-
The Snyk Integration ID looks similar to the following:
39+
The Snyk Integration ID is a UUID and looks similar to the following:
3940
```
4041
abcd1234-abcd-1234-abcd-1234abcd1234
4142
```
4243
The Snyk Integration ID is used in the `--from-literal=integrationId=` parameter in the next step.
4344

44-
3. Finally, create the secret in k8s by running the following command:
45+
3. Finally, create the secret in Kubernetes by running the following command:
4546
```shell
4647
kubectl create secret generic snyk-monitor -n snyk-monitor --from-file=./dockercfg.json --from-literal=integrationId=abcd1234-abcd-1234-abcd-1234abcd1234
4748
```
@@ -50,7 +51,7 @@ Note that the secret _must_ be namespaced, and the namespace (which we configure
5051

5152

5253
The `kubernetes-monitor` can run in one of two modes: constrained to a single namespace, or with access to the whole cluster.
53-
In other words, the monitor can scan containers in the namespace, or it can scan all containers in your cluster.
54+
In other words, the monitor can scan containers in one particular namespace, or it can scan all containers in your cluster.
5455
The choice of which deployment to use depends on the permissions you have on your cluster.
5556

5657
For _cluster_-scoped deployment you can create the necessary `ServiceAccount`, `ClusterRole`, and `ClusterRoleBinding` required for the monitor's deployment.
@@ -75,11 +76,9 @@ Finally, to launch the Snyk monitor in your cluster, run the following:
7576
kubectl apply -f snyk-monitor-deployment.yaml
7677
```
7778

78-
## Using a local Docker image for testing ##
79+
## Enabling static analysis ##
7980

80-
If you would like to use a locally-built image, then modify the following lines in `snyk-monitor-deployment.yaml` like this:
81-
```yaml
82-
containers:
83-
- image: <your-local-image-name:tag>
84-
imagePullPolicy: Never
85-
```
81+
Static analysis works with any container runtime and does not rely on Docker to scan the images in your cluster.
82+
It works by pulling the image, unpacking it and inspecting the files directly. For this process it needs temporary storage, so the Snyk monitor uses 20 GB of storage in the form of [emptyDir](https://kubernetes.io/docs/concepts/storage/volumes/#emptydir).
83+
84+
To enable static analysis, modify one of the permissions files (`snyk-monitor-namespaced-permissions.yaml` for the Namespaced deployment or `snyk-monitor-cluster-permissions.yaml` for the Cluster-scoped deployment) and set the string value of `staticAnalysis` to `"true"`.

snyk-monitor/README.md

+16-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# snyk/kubernetes-monitor-chart #
22

33
## Summary ##
4-
A Helm chart for the Snyk Monitor
4+
A Helm chart for the Snyk monitor
55

66
## Prerequisites ##
77

8-
*Note that at present the monitor works only if using Docker as the container runtime.*
8+
*Note that by default the monitor uses Docker to scan your cluster and requires Docker to be your container runtime.*
9+
*Alternatively, you can enable static analysis, which removes the reliance on Docker completely and works with any container runtime.*
910

1011
The Snyk monitor (`kubernetes-monitor`) requires some minimal configuration items in order to work correctly.
1112

@@ -19,7 +20,7 @@ Notice our namespace is called _snyk-monitor_ and it is used for the following c
1920

2021
The Snyk monitor relies on using your Snyk Integration ID, and using a `dockercfg` file. The `dockercfg` file is necessary to allow the monitor to look up images in private registries. Usually a copy of the `dockercfg` resides in `$HOME/.docker/config.json`.
2122

22-
Both of these items must be provided by a k8s secret. The secret must be called _snyk-monitor_. The steps to create the secret are as such:
23+
Both of these items must be provided by a Kubernetes secret. The secret must be called _snyk-monitor_. The steps to create the secret are as such:
2324

2425
1. Create a file named `dockercfg.json`. Store your `dockercfg` in there; it should look like this:
2526

@@ -40,7 +41,7 @@ abcd1234-abcd-1234-abcd-1234abcd1234
4041
```
4142
The Snyk Integration ID is used in the `--from-literal=integrationId=` parameter in the next step.
4243

43-
3. Finally, create the secret in k8s by running the following command:
44+
3. Finally, create the secret in Kubernetes by running the following command:
4445
```shell
4546
kubectl create secret generic snyk-monitor -n snyk-monitor --from-file=./dockercfg.json --from-literal=integrationId=abcd1234-abcd-1234-abcd-1234abcd1234
4647
```
@@ -69,3 +70,14 @@ For Helm 3, you may run the following:
6970
```shell
7071
helm upgrade --generate-name --install snyk-monitor snyk-charts/snyk-monitor --namespace snyk-monitor --set clusterName="Production cluster"
7172
```
73+
74+
## Enabling static analysis ##
75+
76+
Static analysis works with any container runtime and does not rely on Docker to scan the images in your cluster.
77+
It works by pulling the image, unpacking it and inspecting the files directly. For this process it needs temporary storage, so the Snyk monitor uses 20 GB of storage in the form of [emptyDir](https://kubernetes.io/docs/concepts/storage/volumes/#emptydir).
78+
The Docker socket is _not_ mounted when static analysis is enabled.
79+
80+
To enable static analysis, set the `featureFlags.staticAnalysis` value to `true`:
81+
```shell
82+
helm upgrade --install snyk-monitor snyk-charts/snyk-monitor --namespace snyk-monitor --set clusterName="Production cluster" --set featureFlags.staticAnalysis=true
83+
```

0 commit comments

Comments
 (0)