As a cluster administrator, you may have a need to limit, or restrict, logging activities only to certain namespaces. Kommander allows you to do this by creating an override configMap that modifies the logging configuration created in the Create AppDeployment for Workspace Logging procedure.
Prerequisites
-
Implement each of the steps listed in Enable Workspace-level Logging.
-
Ensure that log data is available before you execute this procedure.
Create and use the override entries
To create and use the override configMap entries, follow these steps:
-
Identify one or more namespaces to which you want to restrict logging.
-
Create a file named
logging-operator-logging-overrides.yaml
and paste the following YAML code into it to create the overrides configMap:apiVersion: v1 kind: ConfigMap metadata: name: logging-operator-logging-overrides namespace: <your-workspace-namespace> data: values.yaml: | --- clusterFlows: - name: cluster-containers spec: globalOutputRefs: - loki match: - exclude: namespaces: - <your-namespace> - <your-other-namespace>
-
Add the relevant namespace values for
metadata.namespace
and theclusterFlows[0].spec.match[0].exclude.namespaces
values at the end of the file, and save the file. -
Use the following command to apply the YAML file:
kubectl apply -f logging-operator-logging-overrides.yaml
-
Edit the logging-operator AppDeployment to replace the
spec.configOverrides.name
value withlogging-operator-logging-overrides
. (You can use the steps in the procedure, Deploy a service with a custom configuration as a guide.) When your editing is complete, the AppDeployment will resemble this code sample:apiVersion: apps.kommander.d2iq.io/v1alpha2 kind: AppDeployment metadata: name: logging-operator namespace: ${WORKSPACE_NAMESPACE} spec: appRef: name: logging-operator-3.15.0 kind: ClusterApp configOverrides: name: logging-operator-logging-overrides
-
Perform actions that generate log data, both in the specified namespaces and the namespaces you mean to exclude.
-
Verify that the log data contains only the data you expected to receive.