Skip to content

Commit 85db2f4

Browse files
Merge branch 'main' of https://github.com/port-labs/port-docs into r_uoStC8xH6rKv0Y81-add-multi-cert-support-port-agent-3
2 parents 917cc22 + 499212a commit 85db2f4

File tree

1 file changed

+58
-6
lines changed
  • docs/build-your-software-catalog/sync-data-to-catalog/kubernetes-stack/kubernetes

1 file changed

+58
-6
lines changed

docs/build-your-software-catalog/sync-data-to-catalog/kubernetes-stack/kubernetes/advanced.md

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ The following advanced configuration parameters are available:
3232
{label: "Bulk Sync", value: "bulkSync"},
3333
{label: "Event listener type", value: "eventListenerType"},
3434
{label: "CRDs to discover", value: "crdsToDiscover"},
35+
{label: "JQ Configuration", value: "jqConfiguration"},
3536
]} >
3637

3738
<TabItem value="resyncInterval">
@@ -133,6 +134,58 @@ For more information how to use the `crdsToDiscover` parameter, please refer to
133134

134135
</TabItem>
135136

137+
<TabItem value="jqConfiguration">
138+
139+
The K8s exporter supports configuration options to control access to environment variables within JQ queries used in resource mappings.
140+
141+
<h3> `allowAllEnvironmentVariablesInJQ` </h3>
142+
143+
The `allowAllEnvironmentVariablesInJQ` parameter controls whether all environment variables are accessible in JQ queries.
144+
145+
- **Default value**: `true` (all environment variables are accessible within JQ queries)
146+
- **Security implications**: When set to `true`, JQ queries in your resource mappings can access any environment variable available to the exporter pod, including sensitive information like API keys, passwords, and other secrets (if those are mapped to the exporter pod as environment variables).
147+
148+
:::warning Security Risk
149+
Setting `allowAllEnvironmentVariablesInJQ` to `true` can expose sensitive environment variables to JQ queries. This includes:
150+
- Port credentials (`PORT_CLIENT_ID`, `PORT_CLIENT_SECRET`)
151+
- Kubernetes service account tokens.
152+
- Any other environment variables injected into the pod.
153+
- Secrets mounted as environment variables.
154+
155+
Due to the potential security implication, if you have a need to limit the exposure of environment variables in the exporter's JQ, please set this parameter to `false` and explicitly specify the variables that need to be accessed using JQ through the `allowedEnvironmentVariablesInJQ` parameter.
156+
:::
157+
158+
<h3> `allowedEnvironmentVariablesInJQ` </h3>
159+
160+
The `allowedEnvironmentVariablesInJQ` parameter specifies which environment variables are allowed in JQ queries when `allowAllEnvironmentVariablesInJQ` is set to `false`. This parameter accepts a list of JQ expressions that evaluate to environment variable names or patterns.
161+
162+
Each entry in the list is a JQ expression that should return:
163+
- A specific environment variable name (e.g., `"CLUSTER_NAME"`)
164+
- A pattern for matching multiple variables (e.g., `"^CLUSTER_"` to match all cluster-related environment variables)
165+
- An array of environment variable names or patterns.
166+
167+
- **Default value**: `^PORT_, CLUSTER_NAME`
168+
- **Use case**: Restrict access to only specific, safe environment variables in JQ queries for enhanced security. Use JQ expressions to dynamically determine which environment variables should be accessible.
169+
170+
<h3> Configuration Example </h3>
171+
172+
```yaml
173+
allowAllEnvironmentVariablesInJQ: false
174+
allowedEnvironmentVariablesInJQ:
175+
- ^CLUSTER_
176+
- AWS_REGION
177+
- AWS_ACCOUNT_ID
178+
resources:
179+
- kind: v1/namespaces
180+
...
181+
```
182+
183+
This configuration allows:
184+
- All environment variables starting with `CLUSTER_` (e.g., `CLUSTER_NAME`, `CLUSTER_ID`)
185+
- Specific variables: `AWS_REGION` & `AWS_ACCOUNT_ID`
186+
187+
</TabItem>
188+
136189
</Tabs>
137190

138191
## Security Configuration
@@ -155,12 +208,12 @@ By using the `--set` flag, you can override specific exporter configuration para
155208
```bash showLineNumbers
156209
helm upgrade --install k8s-exporter port-labs/port-k8s-exporter \
157210
--create-namespace --namespace port-k8s-exporter \
158-
--set secret.secrets.portClientId="YOUR_PORT_CLIENT_ID" \
159-
--set secret.secrets.portClientSecret="YOUR_PORT_CLIENT_SECRET" \
160-
--set stateKey="k8s-exporter" \
211+
--set secret.secrets.portClientId="YOUR_PORT_CLIENT_ID" \
212+
--set secret.secrets.portClientSecret="YOUR_PORT_CLIENT_SECRET" \
213+
--set stateKey="k8s-exporter" \
161214
# highlight-next-line
162-
--set eventListenerType="KAFKA" \
163-
--set extraEnv=[{"name":"CLUSTER_NAME","value":"my-cluster"}]
215+
--set eventListenerType="KAFKA" \
216+
--set extraEnv=[{"name":"CLUSTER_NAME","value":"my-cluster"}]
164217
```
165218

166219
For example, to set the parameters from the [security configuration](#security-configuration) section:
@@ -175,7 +228,6 @@ For example, to set the parameters from the [security configuration](#security-c
175228
- A complete list of configuration parameters available when using the helm chart is available [here](https://github.com/port-labs/helm-charts/tree/main/charts/port-k8s-exporter#chart);
176229
- An example skeleton `values.yml` file is available [here](https://github.com/port-labs/helm-charts/blob/main/charts/port-k8s-exporter/values.yaml).
177230

178-
179231
## Extra environment variables
180232
To pass extra environment variables to the exporter's runtime, you can use the Helm chart provided with the installation. You can do this in one of two ways:
181233

0 commit comments

Comments
 (0)