Skip to content

Commit 1155942

Browse files
authored
Use istio.sidecar.inject label instead of annotation (#2887)
* Use istio.sidecar.inject label instead of annotation * Run `make generated-files`
1 parent 23d69e6 commit 1155942

File tree

17 files changed

+97
-59
lines changed

17 files changed

+97
-59
lines changed

docs/full-mesh.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,19 @@ spec:
7777
enabled: true
7878
deployments:
7979
- name: activator
80-
annotations:
80+
labels:
8181
"sidecar.istio.io/inject": "true"
82+
annotations:
8283
"sidecar.istio.io/rewriteAppHTTPProbers": "true"
8384
- name: autoscaler
84-
annotations:
85+
labels:
8586
"sidecar.istio.io/inject": "true"
87+
annotations:
8688
"sidecar.istio.io/rewriteAppHTTPProbers": "true"
8789
EOF
8890
```
8991

90-
Then, create KnativeService with `sidecar.istio.io/inject: "true"`, `sidecar.istio.io/rewriteAppHTTPProbers: "true"` and `serving.knative.openshift.io/enablePassthrough: "true"` annotations in your namespace,
92+
Then, create KnativeService with the `sidecar.istio.io/inject: "true"` label and `sidecar.istio.io/rewriteAppHTTPProbers: "true"`, `serving.knative.openshift.io/enablePassthrough: "true"` annotations in your namespace,
9193
which is one of the namespaces in the `ServiceMeshMemberRoll`.
9294

9395
```sh
@@ -103,8 +105,9 @@ spec:
103105
template:
104106
metadata:
105107
name: hello-example-1
106-
annotations:
108+
labels:
107109
sidecar.istio.io/inject: "true"
110+
annotations:
108111
sidecar.istio.io/rewriteAppHTTPProbers: "true"
109112
spec:
110113
containers:

docs/service-mesh/eventing/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ kubectl get all -n serverless-tests
3434
Run the custom source with Istio's proxy injected:
3535

3636
```shell
37-
kubectl -n serverless-tests run curl --annotations=sidecar.istio.io/inject=true --image=radial/busyboxplus:curl -i --tty --rm
37+
kubectl -n serverless-tests run curl --labels=sidecar.istio.io/inject=true --image=radial/busyboxplus:curl -i --tty --rm
3838
```
3939

4040
Send an event to a broker address:

docs/service-mesh/eventing/resources/kafka-broker-example.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,9 @@ apiVersion: v1
4545
kind: Pod
4646
metadata:
4747
name: event-display
48-
annotations:
49-
sidecar.istio.io/inject: 'true'
5048
labels:
5149
app: event-display
50+
sidecar.istio.io/inject: 'true'
5251
spec:
5352
containers:
5453
- name: event-display

docs/service-mesh/eventing/resources/ping-source-kservice.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ metadata:
77
spec:
88
template:
99
metadata:
10-
annotations:
10+
labels:
1111
sidecar.istio.io/inject: "true"
12+
annotations:
1213
sidecar.istio.io/rewriteAppHTTPProbers: "true"
1314
spec:
1415
containers:

docs/service-mesh/eventing/resources/ping-source.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,9 @@ apiVersion: v1
6767
kind: Pod
6868
metadata:
6969
name: event-display
70-
annotations:
71-
sidecar.istio.io/inject: 'true'
7270
labels:
7371
app: event-display
72+
sidecar.istio.io/inject: 'true'
7473
spec:
7574
containers:
7675
- name: event-display

docs/service-mesh/serving/mesh.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ spec:
5151
- Ingress
5252
```
5353

54-
Then, create Knative Service with `sidecar.istio.io/inject: "true"` annotation in your namespace,
54+
Then, create Knative Service with `sidecar.istio.io/inject: "true"` label in your namespace,
5555
which is one of the namespaces in the `ServiceMeshMemberRoll`.
5656

5757
```sh
@@ -64,7 +64,7 @@ spec:
6464
template:
6565
metadata:
6666
name: hello-example-1
67-
annotations:
67+
labels:
6868
sidecar.istio.io/inject: "true"
6969
spec:
7070
containers:

hack/lib/serverless.bash

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,14 @@ spec:
210210
istio:
211211
enabled: true
212212
deployments:
213-
- annotations:
213+
- labels:
214214
sidecar.istio.io/inject: "true"
215+
annotations:
215216
sidecar.istio.io/rewriteAppHTTPProbers: "true"
216217
name: activator
217-
- annotations:
218+
- labels:
218219
sidecar.istio.io/inject: "true"
220+
annotations:
219221
sidecar.istio.io/rewriteAppHTTPProbers: "true"
220222
name: autoscaler
221223
EOF
@@ -241,24 +243,28 @@ spec:
241243
istio: "enabled"
242244
delivery-timeout: "enabled"
243245
workloads:
244-
- annotations:
245-
sidecar.istio.io/logLevel: "debug"
246+
- labels:
246247
sidecar.istio.io/inject: "true"
248+
annotations:
249+
sidecar.istio.io/logLevel: "debug"
247250
sidecar.istio.io/rewriteAppHTTPProbers: "true"
248251
name: pingsource-mt-adapter
249-
- annotations:
250-
sidecar.istio.io/logLevel: "debug"
252+
- labels:
251253
sidecar.istio.io/inject: "true"
254+
annotations:
255+
sidecar.istio.io/logLevel: "debug"
252256
sidecar.istio.io/rewriteAppHTTPProbers: "true"
253257
name: mt-broker-ingress
254-
- annotations:
255-
sidecar.istio.io/logLevel: "debug"
258+
- labels:
256259
sidecar.istio.io/inject: "true"
260+
annotations:
261+
sidecar.istio.io/logLevel: "debug"
257262
sidecar.istio.io/rewriteAppHTTPProbers: "true"
258263
name: mt-broker-filter
259-
- annotations:
260-
sidecar.istio.io/logLevel: "debug"
264+
- labels:
261265
sidecar.istio.io/inject: "true"
266+
annotations:
267+
sidecar.istio.io/logLevel: "debug"
262268
sidecar.istio.io/rewriteAppHTTPProbers: "true"
263269
name: imc-dispatcher
264270
EOF
@@ -300,39 +306,46 @@ function enable_istio_eventing_kafka {
300306
cat - << EOF > "${istio_patch}"
301307
spec:
302308
workloads:
303-
- annotations:
304-
sidecar.istio.io/logLevel: "debug"
309+
- labels:
305310
sidecar.istio.io/inject: "true"
311+
annotations:
312+
sidecar.istio.io/logLevel: "debug"
306313
sidecar.istio.io/rewriteAppHTTPProbers: "true"
307314
name: kafka-broker-receiver
308-
- annotations:
309-
sidecar.istio.io/logLevel: "debug"
315+
- labels:
310316
sidecar.istio.io/inject: "true"
317+
annotations:
318+
sidecar.istio.io/logLevel: "debug"
311319
sidecar.istio.io/rewriteAppHTTPProbers: "true"
312320
name: kafka-broker-dispatcher
313-
- annotations:
314-
sidecar.istio.io/logLevel: "debug"
321+
- labels:
315322
sidecar.istio.io/inject: "true"
323+
annotations:
324+
sidecar.istio.io/logLevel: "debug"
316325
sidecar.istio.io/rewriteAppHTTPProbers: "true"
317326
name: kafka-channel-receiver
318-
- annotations:
319-
sidecar.istio.io/logLevel: "debug"
327+
- labels:
320328
sidecar.istio.io/inject: "true"
329+
annotations:
330+
sidecar.istio.io/logLevel: "debug"
321331
sidecar.istio.io/rewriteAppHTTPProbers: "true"
322332
name: kafka-channel-dispatcher
323-
- annotations:
324-
sidecar.istio.io/logLevel: "debug"
333+
- labels:
325334
sidecar.istio.io/inject: "true"
335+
annotations:
336+
sidecar.istio.io/logLevel: "debug"
326337
sidecar.istio.io/rewriteAppHTTPProbers: "true"
327338
name: kafka-sink-receiver
328-
- annotations:
329-
sidecar.istio.io/logLevel: "debug"
339+
- labels:
330340
sidecar.istio.io/inject: "true"
341+
annotations:
342+
sidecar.istio.io/logLevel: "debug"
331343
sidecar.istio.io/rewriteAppHTTPProbers: "true"
332344
name: kafka-source-dispatcher
333-
- annotations:
334-
sidecar.istio.io/logLevel: "debug"
345+
- labels:
335346
sidecar.istio.io/inject: "true"
347+
annotations:
348+
sidecar.istio.io/logLevel: "debug"
336349
sidecar.istio.io/rewriteAppHTTPProbers: "true"
337350
name: kafka-controller
338351
EOF

hack/lib/tracing.bash

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ spec:
7575
metadata:
7676
labels:
7777
app: zipkin
78-
annotations:
7978
sidecar.istio.io/inject: "false"
8079
spec:
8180
securityContext:

olm-catalog/serverless-operator/manifests/serverless-operator.clusterserviceversion.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -819,11 +819,10 @@ spec:
819819
serverless.openshift.io/is: webhook
820820
template:
821821
metadata:
822-
annotations:
823-
sidecar.istio.io/inject: "false"
824822
labels:
825823
name: knative-operator
826824
serverless.openshift.io/is: webhook
825+
sidecar.istio.io/inject: "false"
827826
spec:
828827
serviceAccountName: knative-operator
829828
containers:

serving/metadata-webhook/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,7 @@ EOF
4343

4444
```
4545
$ kubectl get -n serving-tests deploy hello-1-deployment -o=jsonpath='{.spec.template.metadata.annotations}' \
46-
| grep '"sidecar.istio.io/inject":"true","sidecar.istio.io/rewriteAppHTTPProbers":"true"'
46+
| grep '"sidecar.istio.io/rewriteAppHTTPProbers":"true"'
47+
$ kubectl get -n serving-tests deploy hello-1-deployment -o=jsonpath='{.spec.template.metadata.labels}' \
48+
| grep '"sidecar.istio.io/inject":"true"'
4749
```

serving/metadata-webhook/pkg/defaults/config_defaults.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ func (r *TargetConfiguration) SetDefaults(_ context.Context) {
2626
if r.Spec.Template.Annotations == nil {
2727
r.Spec.Template.Annotations = make(map[string]string)
2828
}
29+
if r.Spec.Template.Labels == nil {
30+
r.Spec.Template.Labels = make(map[string]string)
31+
}
2932

30-
r.Spec.Template.Annotations[sidecarInject] = "true"
3133
r.Spec.Template.Annotations[sidecarrewriteAppHTTPProbers] = "true"
34+
r.Spec.Template.Labels[sidecarInject] = "true"
3235
}
3336

3437
// Validate returns nil due to no need for validation

serving/metadata-webhook/pkg/defaults/config_defaults_test.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ func TestTargetConfigurationDefaulting(t *testing.T) {
2323
Spec: servingv1.ConfigurationSpec{
2424
Template: servingv1.RevisionTemplateSpec{
2525
ObjectMeta: metav1.ObjectMeta{
26+
Labels: map[string]string{
27+
sidecarInject: "true",
28+
},
2629
Annotations: map[string]string{
27-
sidecarInject: "true",
2830
sidecarrewriteAppHTTPProbers: "true",
2931
},
3032
},
@@ -39,8 +41,10 @@ func TestTargetConfigurationDefaulting(t *testing.T) {
3941
Spec: servingv1.ConfigurationSpec{
4042
Template: servingv1.RevisionTemplateSpec{
4143
ObjectMeta: metav1.ObjectMeta{
44+
Labels: map[string]string{
45+
sidecarInject: "false",
46+
},
4247
Annotations: map[string]string{
43-
sidecarInject: "false",
4448
sidecarrewriteAppHTTPProbers: "false",
4549
},
4650
},
@@ -53,8 +57,10 @@ func TestTargetConfigurationDefaulting(t *testing.T) {
5357
Spec: servingv1.ConfigurationSpec{
5458
Template: servingv1.RevisionTemplateSpec{
5559
ObjectMeta: metav1.ObjectMeta{
60+
Labels: map[string]string{
61+
sidecarInject: "true",
62+
},
5663
Annotations: map[string]string{
57-
sidecarInject: "true",
5864
sidecarrewriteAppHTTPProbers: "true",
5965
},
6066
},

serving/metadata-webhook/pkg/defaults/ksvc_defaults.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,11 @@ func (r *TargetKService) SetDefaults(_ context.Context) {
4040
if r.Spec.Template.Annotations == nil {
4141
r.Spec.Template.Annotations = make(map[string]string)
4242
}
43+
if r.Spec.Template.Labels == nil {
44+
r.Spec.Template.Labels = make(map[string]string)
45+
}
4346

44-
r.Spec.Template.Annotations[sidecarInject] = "true"
47+
r.Spec.Template.Labels[sidecarInject] = "true"
4548
r.Spec.Template.Annotations[sidecarrewriteAppHTTPProbers] = "true"
4649
r.Spec.Template.Annotations[proxyIstioConfig] = holdApplicationUntilProxyStarts
4750
}

serving/metadata-webhook/pkg/defaults/ksvc_defaults_test.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ func TestTargetKServiceDefaulting(t *testing.T) {
2929
ConfigurationSpec: servingv1.ConfigurationSpec{
3030
Template: servingv1.RevisionTemplateSpec{
3131
ObjectMeta: metav1.ObjectMeta{
32+
Labels: map[string]string{
33+
sidecarInject: "true",
34+
},
3235
Annotations: map[string]string{
3336
proxyIstioConfig: holdApplicationUntilProxyStarts,
34-
sidecarInject: "true",
3537
sidecarrewriteAppHTTPProbers: "true",
3638
},
3739
},
@@ -53,8 +55,10 @@ func TestTargetKServiceDefaulting(t *testing.T) {
5355
ConfigurationSpec: servingv1.ConfigurationSpec{
5456
Template: servingv1.RevisionTemplateSpec{
5557
ObjectMeta: metav1.ObjectMeta{
58+
Labels: map[string]string{
59+
sidecarInject: "false",
60+
},
5661
Annotations: map[string]string{
57-
sidecarInject: "false",
5862
sidecarrewriteAppHTTPProbers: "false",
5963
},
6064
},
@@ -74,9 +78,11 @@ func TestTargetKServiceDefaulting(t *testing.T) {
7478
ConfigurationSpec: servingv1.ConfigurationSpec{
7579
Template: servingv1.RevisionTemplateSpec{
7680
ObjectMeta: metav1.ObjectMeta{
81+
Labels: map[string]string{
82+
sidecarInject: "true",
83+
},
7784
Annotations: map[string]string{
7885
proxyIstioConfig: holdApplicationUntilProxyStarts,
79-
sidecarInject: "true",
8086
sidecarrewriteAppHTTPProbers: "true",
8187
},
8288
},

templates/csv.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,11 +827,10 @@ spec:
827827
serverless.openshift.io/is: webhook
828828
template:
829829
metadata:
830-
annotations:
831-
sidecar.istio.io/inject: "false"
832830
labels:
833831
name: knative-operator
834832
serverless.openshift.io/is: webhook
833+
sidecar.istio.io/inject: "false"
835834
spec:
836835
serviceAccountName: knative-operator
837836
containers:

test/extensione2e/kafka/utils.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,11 @@ func DeployKsvcWithEventInfoStoreOrFail(ctx *test.Context, t *testing.T, namespa
6262
// Setup a knative service for the wathola-forwarder
6363
ksvc, err := test.WithServiceReady(ctx, name, namespace, pkgTest.ImagePath(test.WatholaForwarderImg), func(service *servingv1.Service) {
6464
service.Spec.Template.Annotations = map[string]string{
65-
"sidecar.istio.io/inject": "true",
6665
"sidecar.istio.io/rewriteAppHTTPProbers": "true",
6766
}
67+
service.Spec.Template.Labels = map[string]string{
68+
"sidecar.istio.io/inject": "true",
69+
}
6870
service.Spec.Template.Spec.Volumes = []corev1.Volume{
6971
{Name: "config", VolumeSource: corev1.VolumeSource{
7072
ConfigMap: &corev1.ConfigMapVolumeSource{

0 commit comments

Comments
 (0)