Skip to content

Commit debbc24

Browse files
author
jdv
committed
finxing hint about docker and kub
1 parent 2f30748 commit debbc24

File tree

1 file changed

+22
-58
lines changed

1 file changed

+22
-58
lines changed

crowdsec-docs/unversioned/getting_started/health_check.mdx

Lines changed: 22 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ We'll trigger the dummy scenario `crowdsecurity/ssh-generic-test` by attempting
7777
<CodeBlock className="language-bash">docker exec crowdsec cscli alerts list | grep crowdsecurity/ssh-generic-test</CodeBlock>
7878
</TabItem>
7979
<TabItem value="kubernetes" label="Kubernetes">
80+
It's uncommon to have to deal with this scenario in Kubernetes, but if you do:
8081
<CodeBlock className="language-bash">kubectl exec -n crowdsec -it $(kubectl get pods -n crowdsec -l k8s-app=crowdsec -l type=lapi -o name) -- cscli alerts list | grep crowdsecurity/ssh-generic-test</CodeBlock>
8182
</TabItem>
8283
</Tabs>
@@ -88,7 +89,7 @@ We'll trigger the dummy scenario `crowdsecurity/ssh-generic-test` by attempting
8889
<details>
8990
<summary>🛡️ **AppSec** detection test - CrowdSec WAF </summary>
9091

91-
If you've enabled an AppSec-capable bouncer with CrowdSec WAF, you can trigger the `crowdsecurity/appsec-generic-test` dummy scenario.
92+
If you've enabled an AppSec-capable bouncer with CrowdSec WAF with the [Virtual Patching collection](https://app.crowdsec.net/hub/author/crowdsecurity/collections/appsec-virtual-patching), you can trigger the `crowdsecurity/appsec-generic-test` dummy scenario.
9293
It would have triggered along with the HTTP detection test, but it is worth mentioning here as well.
9394

9495
We'll trigger the dummy scenario `crowdsecurity/appsec-generic-test` by accessing a **probe path** on your web server.
@@ -152,11 +153,9 @@ Were all the tests related to your setup successful?
152153
<CodeBlock className="language-bash">docker exec crowdsec cscli metrics show acquisition parsers</CodeBlock>
153154
</TabItem>
154155
<TabItem value="kubernetes" label="Kubernetes">
155-
<CodeBlock className="language-bash">{`# For LAPI pod
156-
kubectl exec -n crowdsec -it $(kubectl get pods -n crowdsec -l k8s-app=crowdsec -l type=lapi -o name) -- cscli metrics show acquisition parsers
157-
158-
# For all agent pods
159-
for i in $(kubectl get pods -n crowdsec -l k8s-app=crowdsec -l type=agent -o name); do kubectl exec -n crowdsec -it $i -- cscli metrics show acquisition parsers; done`}</CodeBlock>
156+
<CodeBlock className="language-bash">
157+
for i in $(kubectl get pods -n crowdsec -l k8s-app=crowdsec -l type=agent -o name); do kubectl exec -n crowdsec -it $i -- cscli metrics show acquisition parsers; done
158+
</CodeBlock>
160159
</TabItem>
161160
</Tabs>
162161

@@ -208,22 +207,19 @@ for i in $(kubectl get pods -n crowdsec -l k8s-app=crowdsec -l type=agent -o nam
208207
In Docker, logs must be accessible to the container through volumes.
209208

210209
**Common issues:**
211-
- **Missing volume mounts**: Ensure log directories are mounted in your container.
210+
- **Missing volume mounts** & **Shared log volumes**: Ensure log directories are mounted in your container and available in multi-container setup.
211+
Example if your service logs are in `/var/log` on the host or in a `logs` shared volume:
212212
```yaml
213213
volumes:
214-
- /var/log:/var/log:ro # Mount logs as read-only
214+
- /var/log:/var/log:ro # Example for mounting logs as read-only
215+
- logs:/logs:ro # Example for shared log volume between containers
215216
```
216-
- **Acquisition configuration**: Your `acquis.yaml` should reference paths inside the container.
217+
- **Acquisition configuration**: Your `acquis.yaml` or `acquis.d/*.yaml` files should reference paths inside the container.
217218
- **Log file permissions**: CrowdSec container user must have read access to log files.
218-
- **Shared log volumes**: For multi-container setups, ensure logs are written to a shared named volume:
219-
```yaml
220-
volumes:
221-
- logs:/var/log/nginx # Shared volume for logs
222-
```
223219

224220
**To check your acquisition config:**
225221
```bash
226-
docker exec crowdsec cat /etc/crowdsec/acquis.yaml
222+
docker exec crowdsec cat /etc/crowdsec/acquis.yaml # or acquis.d/*.yaml
227223
```
228224

229225
</TabItem>
@@ -244,11 +240,6 @@ for i in $(kubectl get pods -n crowdsec -l k8s-app=crowdsec -l type=agent -o nam
244240
- **Wrong namespace or pod names**: Verify pods exist with `kubectl get pods -n <namespace>`
245241
- **Incorrect program name**: The `program` field must match the FILTER of your installed parser (nginx, traefik, apache, etc.)
246242
- **Container runtime mismatch**: Set `container_runtime: containerd` or `container_runtime: docker` in values.yaml
247-
- **RBAC permissions**: CrowdSec needs permissions to read pod logs. Check with:
248-
```bash
249-
kubectl auth can-i list pods --as=system:serviceaccount:crowdsec:crowdsec-agent
250-
kubectl auth can-i get pods/log --as=system:serviceaccount:crowdsec:crowdsec-agent
251-
```
252243

253244
**Note:** Unlike standalone deployments, you use `program:` instead of `type:` in Kubernetes acquisitions.
254245

@@ -292,7 +283,7 @@ for i in $(kubectl get pods -n crowdsec -l k8s-app=crowdsec -l type=agent -o nam
292283
</TabItem>
293284
<TabItem value="docker" label="Docker">
294285

295-
In Docker, collections must be installed via the `COLLECTIONS` environment variable or manually.
286+
In Docker, collections must be installed via the `COLLECTIONS` environment variable.
296287

297288
**🔍 To check what's currently installed:**
298289
```bash
@@ -301,22 +292,11 @@ for i in $(kubectl get pods -n crowdsec -l k8s-app=crowdsec -l type=agent -o nam
301292

302293
**📥 Install collections:**
303294

304-
**Method 1: Environment variable (recommended)**
305295
```yaml
306296
environment:
307297
COLLECTIONS: "crowdsecurity/nginx crowdsecurity/linux"
308298
```
309-
Then restart the container.
310-
311-
**Method 2: Manual installation**
312-
```bash
313-
docker exec crowdsec cscli collections install crowdsecurity/nginx
314-
docker restart crowdsec
315-
```
316-
317-
**Common issues:**
318-
- Collections not persisting: Ensure `/etc/crowdsec/` is mounted as a volume
319-
- Collections installed but not working: Restart the container after installation
299+
Then **restart the container**.
320300

321301
</TabItem>
322302
<TabItem value="kubernetes" label="Kubernetes">
@@ -325,7 +305,7 @@ for i in $(kubectl get pods -n crowdsec -l k8s-app=crowdsec -l type=agent -o nam
325305

326306
**🔍 To check what's currently installed:**
327307
```bash
328-
kubectl exec -n crowdsec -it $(kubectl get pods -n crowdsec -l k8s-app=crowdsec -l type=lapi -o name) -- cscli collections list
308+
for i in $(kubectl get pods -n crowdsec -l k8s-app=crowdsec -l type=agent -o name); do kubectl exec -n crowdsec -it $i -- cscli collections list; done
329309
```
330310

331311
**📥 Install collections:**
@@ -343,11 +323,6 @@ for i in $(kubectl get pods -n crowdsec -l k8s-app=crowdsec -l type=agent -o nam
343323
helm upgrade crowdsec crowdsec/crowdsec -n crowdsec -f values.yaml
344324
```
345325

346-
**Common issues:**
347-
- Collections must match your acquisition `program:` field
348-
- Each agent pod processes different logs, verify on the right pod
349-
- LAPI doesn't need collections, only agents do
350-
351326
</TabItem>
352327
</Tabs>
353328

@@ -403,12 +378,7 @@ for i in $(kubectl get pods -n crowdsec -l k8s-app=crowdsec -l type=agent -o nam
403378
docker logs crowdsec
404379
```
405380

406-
**Start/restart the container:**
407-
```bash
408-
docker start crowdsec
409-
# Or restart
410-
docker restart crowdsec
411-
```
381+
**Make sure your container starts without error**
412382

413383
**Common issues:**
414384
- **Volume mount errors**: Ensure `/etc/crowdsec/` and `/var/lib/crowdsec/data/` are properly mounted
@@ -447,27 +417,21 @@ for i in $(kubectl get pods -n crowdsec -l k8s-app=crowdsec -l type=agent -o nam
447417
```
448418

449419
**Common issues:**
450-
- **Image pull errors**: Check if the CrowdSec image is accessible
451-
- **RBAC permissions**: Agents need permissions to read pod logs
420+
- **ConfigMap errors**: Verify configuration is valid
452421
```bash
453-
kubectl get clusterrole crowdsec-agent
454-
kubectl get clusterrolebinding crowdsec-agent
422+
kubectl get configmap -n crowdsec
455423
```
424+
- **Resource limits**: Check if pods have sufficient CPU/memory
425+
- **Network policies**: Ensure pods can communicate with each other
456426
- **PVC issues**: If using persistent volumes, ensure PVCs are bound
457427
```bash
458428
kubectl get pvc -n crowdsec
459429
```
460-
- **ConfigMap errors**: Verify configuration is valid
461-
```bash
462-
kubectl get configmap -n crowdsec
463-
```
464-
- **Network policies**: Ensure pods can communicate with each other
465-
- **Resource limits**: Check if pods have sufficient CPU/memory
430+
- **Image pull errors**: Check if the CrowdSec image is accessible, could happen if you have registry conflicts
466431

467-
**Restart pods:**
432+
**Upgrade your Helm**
468433
```bash
469-
kubectl rollout restart deployment/crowdsec-lapi -n crowdsec
470-
kubectl rollout restart daemonset/crowdsec-agent -n crowdsec
434+
helm upgrade crowdsec crowdsec/crowdsec -n crowdsec -f values.yaml
471435
```
472436

473437
</TabItem>

0 commit comments

Comments
 (0)