Skip to content

Commit a0ceba9

Browse files
committed
feat: add generateName option for kaniko build pod to enable custom kaniko pod names
1 parent 4ea6bc6 commit a0ceba9

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

pkg/devspace/build/builder/kaniko/build_pod.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package kaniko
22

33
import (
4+
"path/filepath"
5+
46
"github.com/loft-sh/devspace/pkg/devspace/build/builder/kaniko/util"
57
devspacecontext "github.com/loft-sh/devspace/pkg/devspace/context"
6-
"path/filepath"
78

89
"github.com/docker/distribution/reference"
910
jsonyaml "github.com/ghodss/yaml"
@@ -38,6 +39,9 @@ const devspaceQuota = "devspace-quota"
3839
// DevspaceLimitRange is the limit range name of the space limit range in the devspace cloud
3940
const devspaceLimitRange = "devspace-limit-range"
4041

42+
// The generateName string for the kaniko pod that we use by default
43+
const podGenerateName = "devspace-build-kaniko-"
44+
4145
type availableResources struct {
4246
CPU resource.Quantity
4347
Memory resource.Quantity
@@ -74,6 +78,11 @@ func (b *Builder) getBuildPod(ctx devspacecontext.Context, buildID string, optio
7478
kanikoInitImage = kanikoOptions.InitImage
7579
}
7680

81+
kanikoPodGenerateName := podGenerateName
82+
if kanikoOptions.GenerateName != "" {
83+
kanikoPodGenerateName = kanikoOptions.GenerateName
84+
}
85+
7786
// additional options to pass to kaniko
7887
kanikoArgs := []string{
7988
"--dockerfile=" + kanikoContextPath + "/" + filepath.Base(dockerfilePath),
@@ -213,7 +222,7 @@ func (b *Builder) getBuildPod(ctx devspacecontext.Context, buildID string, optio
213222
// create the build pod
214223
pod := &k8sv1.Pod{
215224
ObjectMeta: metav1.ObjectMeta{
216-
GenerateName: "devspace-build-kaniko-",
225+
GenerateName: kanikoPodGenerateName,
217226
Annotations: map[string]string{},
218227
Labels: map[string]string{
219228
"devspace-build": "true",

pkg/devspace/config/versions/latest/schema.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,9 @@ type KanikoConfig struct {
432432
// ServiceAccount the service account to use for the kaniko pod
433433
ServiceAccount string `yaml:"serviceAccount,omitempty" json:"serviceAccount,omitempty"`
434434

435+
// GenerateName is the optional prefix that will be set to the generateName field of the build pod
436+
GenerateName string `yaml:"generateName,omitempty" json:"generateName,omitempty"`
437+
435438
// Annotations are extra annotations that will be added to the build pod
436439
Annotations map[string]string `yaml:"annotations,omitempty" json:"annotations,omitempty"`
437440

0 commit comments

Comments
 (0)