Skip to content

Commit

Permalink
JobSink with Istio config for Job spec
Browse files Browse the repository at this point in the history
  • Loading branch information
mgencur committed Jan 28, 2025
1 parent c636346 commit 2feaf19
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/rekt/features/jobsink/jobsink.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ func Success(jobSinkName string) *feature.Feature {
Scheme: "http",
Host: network.GetServiceHostname(sink, environment.FromContext(ctx).Namespace()),
}
jobsink.Install(jobSink, jobsink.WithForwarderJob(sinkURL.String()))(ctx, t)
var opts []func(*batchv1.Job)
if ic := environment.GetIstioConfig(ctx); ic.Enabled {
opts = append(opts, jobsink.WithIstioConfig())
}
jobsink.Install(jobSink, jobsink.WithForwarderJob(sinkURL.String(), opts...))(ctx, t)
})

f.Setup("jobsink is addressable", jobsink.IsAddressable(jobSink))
Expand Down
16 changes: 16 additions & 0 deletions test/rekt/resources/jobsink/jobsink.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,22 @@ func WithJob(job batchv1.Job) manifest.CfgFn {
}
}

func WithIstioConfig() func(*batchv1.Job) {
return func(job *batchv1.Job) {
if job.Spec.Template.Labels == nil {
job.Spec.Template.Labels = make(map[string]string)
}
job.Spec.Template.Labels["sidecar.istio.io/inject"] = "true"

if job.Spec.Template.Annotations == nil {
job.Spec.Template.Annotations = make(map[string]string)
}
job.Spec.Template.Annotations["sidecar.istio.io/rewriteAppHTTPProbers"] = "true"
job.Spec.Template.Annotations["proxy.istio.io/config"] = `{ "holdApplicationUntilProxyStarts": true }`
job.Spec.Template.Annotations["sidecar.istio.io/inject"] = "true" // For backwards compatibility.
}
}

func WithForwarderJob(sink string, options ...func(*batchv1.Job)) manifest.CfgFn {
return func(cfg map[string]interface{}) {
j := batchv1.Job{
Expand Down

0 comments on commit 2feaf19

Please sign in to comment.