Add option to configure tolerations in kubernetes backend (#2249)

This code add a feature to support tolerations in Kubernetes Backend

---------

Signed-off-by: Kleber Rocha <klinux@gmail.com>
This commit is contained in:
Kleber Rocha
2023-08-22 17:34:59 -03:00
committed by GitHub
parent 3954d85a5b
commit 61b5672051
5 changed files with 89 additions and 0 deletions

View File

@@ -125,6 +125,22 @@ func Pod(namespace string, step *types.Step, labels, annotations map[string]stri
}
}
var tolerations []v1.Toleration
beTolerations := step.BackendOptions.Kubernetes.Tolerations
if len(beTolerations) > 0 {
for _, t := range step.BackendOptions.Kubernetes.Tolerations {
toleration := v1.Toleration{
Key: t.Key,
Operator: v1.TolerationOperator(t.Operator),
Value: t.Value,
Effect: v1.TaintEffect(t.Effect),
TolerationSeconds: t.TolerationSeconds,
}
tolerations = append(tolerations, toleration)
}
log.Trace().Msgf("Tolerations that will be used in the backend options: %v", beTolerations)
}
pod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: podName,
@@ -136,6 +152,7 @@ func Pod(namespace string, step *types.Step, labels, annotations map[string]stri
RestartPolicy: v1.RestartPolicyNever,
HostAliases: hostAliases,
NodeSelector: nodeSelector,
Tolerations: tolerations,
ServiceAccountName: serviceAccountName,
Containers: []v1.Container{{
Name: podName,