Skip to content

Commit d243b91

Browse files
authored
JobSink with Istio config for Job spec (#8430)
1 parent c636346 commit d243b91

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

test/rekt/features/jobsink/jobsink.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ func Success(jobSinkName string) *feature.Feature {
6363
Scheme: "http",
6464
Host: network.GetServiceHostname(sink, environment.FromContext(ctx).Namespace()),
6565
}
66-
jobsink.Install(jobSink, jobsink.WithForwarderJob(sinkURL.String()))(ctx, t)
66+
var opts []func(*batchv1.Job)
67+
if ic := environment.GetIstioConfig(ctx); ic.Enabled {
68+
opts = append(opts, jobsink.WithIstioConfig())
69+
}
70+
jobsink.Install(jobSink, jobsink.WithForwarderJob(sinkURL.String(), opts...))(ctx, t)
6771
})
6872

6973
f.Setup("jobsink is addressable", jobsink.IsAddressable(jobSink))

test/rekt/resources/jobsink/jobsink.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,22 @@ func WithJob(job batchv1.Job) manifest.CfgFn {
106106
}
107107
}
108108

109+
func WithIstioConfig() func(*batchv1.Job) {
110+
return func(job *batchv1.Job) {
111+
if job.Spec.Template.Labels == nil {
112+
job.Spec.Template.Labels = make(map[string]string)
113+
}
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.
122+
}
123+
}
124+
109125
func WithForwarderJob(sink string, options ...func(*batchv1.Job)) manifest.CfgFn {
110126
return func(cfg map[string]interface{}) {
111127
j := batchv1.Job{

0 commit comments

Comments
 (0)