@@ -58,6 +58,28 @@ If CrowdSec is already deployed with Helm in this cluster, the repository entry
5858
5959### Update CrowdSec configuration
6060
61+ Store the nginx bouncer key in a Kubernetes secret, following the same pattern
62+ used by the Envoy quickstart.
63+
64+ Create or update the secret used by CrowdSec LAPI:
65+
66+ ``` yaml title="crowdsec-keys.yaml"
67+ apiVersion : v1
68+ kind : Secret
69+ metadata :
70+ name : crowdsec-keys
71+ namespace : crowdsec
72+ type : Opaque
73+ stringData :
74+ BOUNCER_KEY_nginx_ingress_waf : " <choose-a-long-random-key>"
75+ ` ` `
76+
77+ Apply it:
78+
79+ ` ` ` bash
80+ kubectl apply -f crowdsec-keys.yaml
81+ ```
82+
6183Add this to the CrowdSec ` values.yaml ` with the AppSec acquisition datasource (see the [ AppSec datasource] ( /log_processor/data_sources/appsec.md ) ) and the default [ AppSec configuration] ( /appsec/configuration.md ) :
6284
6385``` yaml title="values.yaml"
@@ -74,13 +96,42 @@ appsec:
7496 env :
7597 - name : COLLECTIONS
7698 value : crowdsecurity/appsec-virtual-patching crowdsecurity/appsec-generic-rules
99+ lapi :
100+ env :
101+ - name : BOUNCER_KEY_nginx_ingress_waf
102+ valueFrom :
103+ secretKeyRef :
104+ name : crowdsec-keys
105+ key : BOUNCER_KEY_nginx_ingress_waf
106+ ` ` `
107+
108+ :::warning
109+ The Helm chart still enables the CrowdSec agent by default. If you do not want
110+ the agent, disable it explicitly.
111+ :::
112+
113+ <details>
114+ <summary>Snippet to disable the agent</summary>
115+
116+ ` ` ` yaml title="values.yaml"
117+ agent :
118+ enabled : false
77119` ` `
78120
121+ </details>
122+
123+ :::note
124+ Although this is the same bouncer key value, you need two ` Secret` objects here:
125+ one in `crowdsec` and one in `ingress-nginx`. Kubernetes secrets are
126+ namespace-scoped, so the ingress controller cannot read a secret from the
127+ ` crowdsec` namespace.
128+ :: :
129+
79130This YAML configuration snippet exposes the important configuration items :
80131 * `listen_addr: 0.0.0.0:7422` exposes the AppSec API inside the cluster.
81132 * `appsec_configs` loads the [AppSec configuration(s)](/appsec/configuration.md) that define which rules are evaluated (in-band vs out-of-band).
82133 * The two collections provide virtual patching and generic rule coverage.
83- * The chart bootstraps a bouncer named `nginx_ingress_waf` using the key you export locally .
134+ * `lapi.env` forces the `nginx_ingress_waf` bouncer key from the `crowdsec-keys` Secret .
84135
85136And now we apply the new configuration with :
86137
@@ -98,6 +149,26 @@ You should see `crowdsec-agent` pods, the `crowdsec-lapi` pod and the `crowdsec-
98149
99150# # Enable the CrowdSec Lua plugin on NGINX Ingress
100151
152+ Create the secret holding the same CrowdSec bouncer key in the
153+ `ingress-nginx` namespace :
154+
155+ ` ` ` yaml title="crowdsec-ingress-bouncer-secret.yaml"
156+ apiVersion: v1
157+ kind: Secret
158+ metadata:
159+ name: crowdsec-ingress-bouncer-secrets
160+ namespace: ingress-nginx
161+ type: Opaque
162+ stringData:
163+ api-key: "<same-value-as-BOUNCER_KEY_nginx_ingress_waf>"
164+ ` ` `
165+
166+ Apply it :
167+
168+ ` ` ` bash
169+ kubectl apply -f crowdsec-ingress-bouncer-secret.yaml
170+ ` ` `
171+
101172To extend the ingress controller with the CrowdSec plugin and point it to the
102173AppSec API, create the file named `ingress-values.yaml`. You can read the entire
103174file in the snippet below.
@@ -107,8 +178,8 @@ controller:
107178 image:
108179 registry: docker.io
109180 image: crowdsecurity/controller
110- tag: v1.13.2
111- digest: sha256:4575be24781cad35f8e58437db6a3f492df2a3167fed2b6759a6ff0dc3488d56
181+ tag: v1.14.3
182+ digest: sha256:9ab8791635f4cde9964ab2562fb8b15faf72fe0205f0fe288089a87e1455675d
112183 extraVolumes:
113184 - name: crowdsec-bouncer-plugin
114185 emptyDir: {}
@@ -120,7 +191,10 @@ controller:
120191 - name: API_URL
121192 value: "http://crowdsec-service.crowdsec.svc.cluster.local:8080"
122193 - name: API_KEY
123- value: privateKey-foo
194+ valueFrom:
195+ secretKeyRef:
196+ name: crowdsec-ingress-bouncer-secrets
197+ key: api-key
124198 - name: BOUNCER_CONFIG
125199 value: "/crowdsec/crowdsec-bouncer.conf"
126200 - name: APPSEC_URL
@@ -153,13 +227,13 @@ controller:
153227 plugins: "crowdsec"
154228 lua-shared-dicts: "crowdsec_cache: 50m"
155229 server-snippet: |
156- lua_ssl_trusted_certificate "/etc/ssl/certs/ca-certificates.crt"
230+ lua_ssl_trusted_certificate "/etc/ssl/certs/ca-certificates.crt";
157231 resolver local=on ipv6=off;
158232` ` `
159233
160234
161235- ` API_URL` targets the Local API service exposed by the Helm chart.
162- - ` API_KEY` defines the key for the bouncer to be able to connect to CrowdSec LAPI
236+ - ` API_KEY` is read from the `crowdsec-ingress- bouncer-secrets` Secret in the `ingress-nginx` namespace.
163237- ` APPSEC_URL` points to the AppSec service; keep the namespace in sync with your CrowdSec release.
164238- The plugin copies the Lua files from the init container into an `emptyDir` that is mounted at runtime.
165239
@@ -184,8 +258,8 @@ controller:
184258 image:
185259 registry: docker.io
186260 image: crowdsecurity/controller
187- tag: v1.13.2
188- digest: sha256:...
261+ tag: v1.14.3
262+ digest: sha256:9ab8791635f4cde9964ab2562fb8b15faf72fe0205f0fe288089a87e1455675d
189263` ` `
190264
191265The controller image is replaced with a CrowdSec-enabled build that includes the
@@ -212,7 +286,10 @@ extraInitContainers:
212286 - name: API_URL
213287 value: "http://crowdsec-service.crowdsec.svc.cluster.local:8080"
214288 - name: API_KEY
215- value: privateKey-foo
289+ valueFrom:
290+ secretKeyRef:
291+ name: crowdsec-ingress-bouncer-secrets
292+ key: api-key
216293 - name: BOUNCER_CONFIG
217294 value: "/crowdsec/crowdsec-bouncer.conf"
218295 - name: APPSEC_URL
0 commit comments