-
Notifications
You must be signed in to change notification settings - Fork 166
/
stopper.go
32 lines (24 loc) · 1020 Bytes
/
stopper.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package jobs
import (
"fmt"
"github.com/grafana/k6-operator/api/v1alpha1"
"github.com/grafana/k6-operator/pkg/resources/containers"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
)
// NewStopJob builds a template used for creating a stop job
func NewStopJob(k6 v1alpha1.TestRunI, hostname []string) *batchv1.Job {
// this job is almost identical to the starter so re-use the definitions
job := NewStarterJob(k6, hostname)
job.Name = fmt.Sprintf("%s-stopper", k6.NamespacedName().Name)
image := "ghcr.io/grafana/k6-operator:latest-starter"
if k6.GetSpec().Starter.Image != "" {
image = k6.GetSpec().Starter.Image
}
command, istioEnabled := newIstioCommand(k6.GetSpec().Scuttle.Enabled, []string{"sh", "-c"})
env := newIstioEnvVar(k6.GetSpec().Scuttle, istioEnabled)
job.Spec.Template.Spec.Containers = []corev1.Container{
containers.NewStopContainer(hostname, image, k6.GetSpec().Starter.ImagePullPolicy, command, env, k6.GetSpec().Starter.ContainerSecurityContext),
}
return job
}