TIS1002 - Global Default Sidecar Should Not Have a workloadSelector
The global default Sidecar configuration should not have a workloadSelector.
Sidecar Should Be Generic Without workloadSelectorTo maintain proper global defaults, ensure that the global Sidecar in the istio-system namespace does not include a workloadSelector. Use specific Sidecar resources for configuring individual workloads.
Examples
-
Global
Sidecarwith aworkloadSelectorapiVersion: networking.istio.io/v1beta1
kind: Sidecar
metadata:
name: default-sidecar
namespace: istio-system
spec:
workloadSelector:
labels:
app: my-app
egress:
- hosts:
- "*/*"Explanation: The global
Sidecarresource in theistio-systemnamespace is configured with aworkloadSelector. This is not appropriate for a global default configuration, as theworkloadSelectorshould be used only for specifying configurations for individual workloads. The global default should apply to all workloads in the absence of more specific configurations.
Recommendation
Ensure the global Sidecar resource does not include the workloadSelector. Move specific settings for specific workloads to sidecar resources in application namespaces.
-
Remove
workloadSelectorfrom the GlobalSidecarUpdate the global
Sidecarconfiguration to remove theworkloadSelector, making it apply universally to all workloads without specific sidecar configurations.apiVersion: networking.istio.io/v1beta1
kind: Sidecar
metadata:
name: default-sidecar
namespace: istio-system
spec:
egress:
- hosts:
- "*/*"Explanation: Removing the
workloadSelectorfrom the globalSidecarresource ensures that the configuration applies to all workloads, providing a consistent default configuration for traffic egress. -
Move Specific Settings to Workload-Specific
SidecarResourcesIf specific settings are required for a particular workload, move those settings to a workload-specific
Sidecarresource in the appropriate namespace.apiVersion: networking.istio.io/v1beta1
kind: Sidecar
metadata:
name: my-app-sidecar
namespace: example-namespace
spec:
workloadSelector:
labels:
app: my-app
egress:
- hosts:
- "external-service.com/*"Explanation: By creating a workload-specific
Sidecarresource, the configuration is applied only to the relevant workloads, while the globalSidecarremains generic.