# istio_sidecar-default-selector.yaml
apiVersion: networking.istio.io/v1
kind: Sidecar
metadata:
  name: no-selector # Since this is the only Sidecar in the namespace without a workload selector, no conflict
  namespace: ns1
spec:
  egress:
  - hosts:
    - "./*"
---
apiVersion: networking.istio.io/v1
kind: Sidecar
metadata:
  name: has-selector
  namespace: ns1
spec:
  workloadSelector: # Since this has a workload selector, it shouldn't conflict with the other Sidecar in the namespace
    labels:
      app: foo
  egress:
  - hosts:
    - "./*"
---
apiVersion: networking.istio.io/v1
kind: Sidecar
metadata:
  name: has-conflict-1 # Both Sidecars in this namespace omit workload selector, so they are in conflict
  namespace: ns2
spec:
  egress:
  - hosts:
    - "./*"
---
apiVersion: networking.istio.io/v1
kind: Sidecar
metadata:
  name: has-conflict-2 # Both Sidecars in this namespace omit workload selector, so they are in conflict
  namespace: ns2
spec:
  egress:
  - hosts:
    - "./*"
---
apiVersion: v1
kind: Namespace
metadata:
  name: ns1
---
apiVersion: v1
kind: Namespace
metadata:
  name: ns2
---
apiVersion: v1
kind: Pod
metadata:
  name: random-pod
  namespace: ns1
  labels:
    app: foo
spec:
  containers:
  - image: proxyv2
---
# some tests for ambient
# pod in ambient mode should throw error for sidecar resource
apiVersion: v1
kind: Namespace
metadata:
  name: ns-ambient
  labels:
    istio.io/dataplane-mode: ambient
---
apiVersion: v1
kind: Pod
metadata:
  name: random-pod-ambient
  namespace: ns-ambient
  labels:
    app: ambient
  annotations:
    ambient.istio.io/redirection: enabled
---
apiVersion: networking.istio.io/v1
kind: Sidecar
metadata:
  name: namespace-scoped
  namespace: ns-ambient
---
apiVersion: networking.istio.io/v1
kind: Sidecar
metadata:
  name: pod-scoped
  namespace: ns-ambient
spec:
  workloadSelector:
    labels:
      app: ambient
---
apiVersion: v1
kind: Namespace
metadata:
  name: ns-not-ambient
  labels:
    istio.io/dataplane-mode: ambient
    istio-injection: enabled
---
apiVersion: v1
kind: Namespace
metadata:
  name: ns-not-ambient-rev
  labels:
    istio.io/dataplane-mode: ambient
    istio.io/rev: canary
---
apiVersion: networking.istio.io/v1
kind: Sidecar
metadata:
  name: namespace-not-ambient
  namespace: ns-not-ambient
---
apiVersion: networking.istio.io/v1
kind: Sidecar
metadata:
  name: namespace-not-ambient
  namespace: ns-not-ambient-rev