Skip to content

Commit

Permalink
feat: Improve job labels
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Oct 4, 2023
1 parent 61a9d3a commit 28103f8
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions internal/util/cmd_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package util
import (
"context"
"errors"
"maps"
"strings"
"time"

Expand Down Expand Up @@ -179,29 +180,31 @@ func createJob(cmd *cobra.Command, conf *config.Global, actionName string) error
name += actionName + "-"
}

podLabels := viper.GetStringMapString("kubernetes.job-pod-labels")
podLabels["app.kubernetes.io/name"] = "kubedb"
podLabels["app.kubernetes.io/instance"] = "kubedb"
podLabels["app.kubernetes.io/component"] = actionName
standardLabels := map[string]string{
"app.kubernetes.io/name": "kubedb",
"app.kubernetes.io/instance": "kubedb",
"app.kubernetes.io/component": actionName,
}

podLabels := map[string]string{
"sidecar.istio.io/inject": "false",
}
maps.Copy(podLabels, standardLabels)
maps.Copy(podLabels, viper.GetStringMapString("kubernetes.job-pod-labels"))

job := batchv1.Job{
ObjectMeta: metav1.ObjectMeta{
GenerateName: name,
Namespace: conf.Namespace,
Labels: map[string]string{
"app.kubernetes.io/name": "kubedb",
"app.kubernetes.io/instance": "kubedb",
"app.kubernetes.io/component": actionName,
},
Labels: standardLabels,
},
Spec: batchv1.JobSpec{
ActiveDeadlineSeconds: ptr.To(int64(24 * time.Hour.Seconds())),
BackoffLimit: ptr.To(int32(0)),
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
"sidecar.istio.io/inject": "false",
"linkerd.io/inject": "disabled",
"linkerd.io/inject": "disabled",
},
Labels: podLabels,
},
Expand Down

0 comments on commit 28103f8

Please sign in to comment.