mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-09-06 13:56:43 +00:00
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:
@@ -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,
|
||||
|
Reference in New Issue
Block a user