Allow adding additional labels/annotations to kubernetes worker pods (#1510)

Example agent environment configuration using the new value:
```yaml
  - env:
    - name: WOODPECKER_BACKEND
      value: kubernetes
    - name: WOODPECKER_BACKEND_K8S_NAMESPACE
      value: default
    - name: WOODPECKER_BACKEND_K8S_POD_LABELS
      value: '{"sidecar.istio.io/inject":"false"}'
```
This commit is contained in:
Stephen Muth
2022-12-30 19:37:09 -05:00
committed by GitHub
parent 0923aa2624
commit 1816f6c715
5 changed files with 57 additions and 14 deletions

View File

@@ -10,7 +10,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func Pod(namespace string, step *types.Step) *v1.Pod {
func Pod(namespace string, step *types.Step, labels, annotations map[string]string) *v1.Pod {
var (
vols []v1.Volume
volMounts []v1.VolumeMount
@@ -88,13 +88,14 @@ func Pod(namespace string, step *types.Step) *v1.Pod {
},
}
labels["step"] = podName(step)
return &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: podName(step),
Namespace: namespace,
Labels: map[string]string{
"step": podName(step),
},
Name: podName(step),
Namespace: namespace,
Labels: labels,
Annotations: annotations,
},
Spec: v1.PodSpec{
RestartPolicy: v1.RestartPolicyNever,