TIS1002 - Global Default Sidecar Should Not Have a workloadSelector
The global default Sidecar
configuration should not have a workloadSelector
.
Sidecar
Should Be Generic Without workloadSelector
To 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
Sidecar
with aworkloadSelector
apiVersion: networking.istio.io/v1beta1
kind: Sidecar
metadata:
name: default-sidecar
namespace: istio-system
spec:
workloadSelector:
labels:
app: my-app
egress:
- hosts:
- "*/*"Explanation: The global
Sidecar
resource in theistio-system
namespace is configured with aworkloadSelector
. This is not appropriate for a global default configuration, as theworkloadSelector
should 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
workloadSelector
from the GlobalSidecar
Update the global
Sidecar
configuration 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
workloadSelector
from the globalSidecar
resource ensures that the configuration applies to all workloads, providing a consistent default configuration for traffic egress. -
Move Specific Settings to Workload-Specific
Sidecar
ResourcesIf specific settings are required for a particular workload, move those settings to a workload-specific
Sidecar
resource 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
Sidecar
resource, the configuration is applied only to the relevant workloads, while the globalSidecar
remains generic.