Skip to content

Commit 617b362

Browse files
committed
Use also label for injecting sidecar
1 parent db72fc4 commit 617b362

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

test/rekt/features/jobsink/jobsink.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func Success(jobSinkName string) *feature.Feature {
6565
}
6666
var opts []func(*batchv1.Job)
6767
if ic := environment.GetIstioConfig(ctx); ic.Enabled {
68-
opts = append(opts, jobsink.WithPodIstioAnnotations())
68+
opts = append(opts, jobsink.WithIstioConfig())
6969
}
7070
jobsink.Install(jobSink, jobsink.WithForwarderJob(sinkURL.String(), opts...))(ctx, t)
7171
})

test/rekt/resources/jobsink/jobsink.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,19 @@ func WithJob(job batchv1.Job) manifest.CfgFn {
106106
}
107107
}
108108

109-
func WithPodIstioAnnotations() func(*batchv1.Job) {
109+
func WithIstioConfig() func(*batchv1.Job) {
110110
return func(job *batchv1.Job) {
111-
job.Spec.Template.Annotations = map[string]string{
112-
"sidecar.istio.io/inject": "true",
113-
"sidecar.istio.io/rewriteAppHTTPProbers": "true",
114-
"proxy.istio.io/config": `{ "holdApplicationUntilProxyStarts": true }`,
111+
if job.Spec.Template.Labels == nil {
112+
job.Spec.Template.Labels = make(map[string]string)
115113
}
114+
job.Spec.Template.Labels["sidecar.istio.io/inject"] = "true"
115+
116+
if job.Spec.Template.Annotations == nil {
117+
job.Spec.Template.Annotations = make(map[string]string)
118+
}
119+
job.Spec.Template.Annotations["sidecar.istio.io/rewriteAppHTTPProbers"] = "true"
120+
job.Spec.Template.Annotations["proxy.istio.io/config"] = `{ "holdApplicationUntilProxyStarts": true }`
121+
job.Spec.Template.Annotations["sidecar.istio.io/inject"] = "true" // For backwards compatibility.
116122
}
117123
}
118124

0 commit comments

Comments
 (0)