Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

<details className="config-field" data-expandable="false" open>
<summary>

#### `generateName` <span className="config-field-required" data-required="false">required</span> <span className="config-field-type">string</span> <span className="config-field-default"></span> <span className="config-field-enum"></span> {#images-kaniko-generateName}

GenerateName will be used as the generateName field of the build pod

</summary>



</details>
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import PartialSkipPullSecretMount from "./kaniko/skipPullSecretMount.mdx"
import PartialNodeSelector from "./kaniko/nodeSelector.mdx"
import PartialTolerationsreference from "./kaniko/tolerations_reference.mdx"
import PartialServiceAccount from "./kaniko/serviceAccount.mdx"
import PartialGenerateName from "./kaniko/generateName.mdx"
import PartialAnnotations from "./kaniko/annotations.mdx"
import PartialLabels from "./kaniko/labels.mdx"
import PartialInitEnv from "./kaniko/initEnv.mdx"
Expand Down Expand Up @@ -72,6 +73,9 @@ Tolerations is a tolerations list to use for the kaniko pod
<PartialServiceAccount />


<PartialGenerateName />


<PartialAnnotations />


Expand Down
17 changes: 17 additions & 0 deletions docs/pages/configuration/images/build-engines/kaniko.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,23 @@ images:

## Build Pod Configuration

### `generateName`
The `generateName` option expects a string that will be used as the generateName field of the build pod

#### Default value for `generateName`
```yaml
generateName: devspace-build-kaniko-
```

#### Example: Add generateName to kaniko build pods
```yaml
images:
backend:
image: 123.456.789.0:5000/john/appbackend
kaniko:
generateName: devspace-build-kaniko-backend-
```

### `annotations`
The `annotations` option expects a key/value map of extra annotations that will be added to the build pod

Expand Down
13 changes: 11 additions & 2 deletions pkg/devspace/build/builder/kaniko/build_pod.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package kaniko

import (
"path/filepath"

"github.com/loft-sh/devspace/pkg/devspace/build/builder/kaniko/util"
devspacecontext "github.com/loft-sh/devspace/pkg/devspace/context"
"path/filepath"

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

// The generateName string for the kaniko pod that we use by default
const podGenerateName = "devspace-build-kaniko-"

type availableResources struct {
CPU resource.Quantity
Memory resource.Quantity
Expand Down Expand Up @@ -74,6 +78,11 @@ func (b *Builder) getBuildPod(ctx devspacecontext.Context, buildID string, optio
kanikoInitImage = kanikoOptions.InitImage
}

kanikoPodGenerateName := podGenerateName
if kanikoOptions.GenerateName != "" {
kanikoPodGenerateName = kanikoOptions.GenerateName
}

// additional options to pass to kaniko
kanikoArgs := []string{
"--dockerfile=" + kanikoContextPath + "/" + filepath.Base(dockerfilePath),
Expand Down Expand Up @@ -213,7 +222,7 @@ func (b *Builder) getBuildPod(ctx devspacecontext.Context, buildID string, optio
// create the build pod
pod := &k8sv1.Pod{
ObjectMeta: metav1.ObjectMeta{
GenerateName: "devspace-build-kaniko-",
GenerateName: kanikoPodGenerateName,
Annotations: map[string]string{},
Labels: map[string]string{
"devspace-build": "true",
Expand Down
3 changes: 3 additions & 0 deletions pkg/devspace/config/versions/latest/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,9 @@ type KanikoConfig struct {
// ServiceAccount the service account to use for the kaniko pod
ServiceAccount string `yaml:"serviceAccount,omitempty" json:"serviceAccount,omitempty"`

// GenerateName is the optional prefix that will be set to the generateName field of the build pod
GenerateName string `yaml:"generateName,omitempty" json:"generateName,omitempty"`

// Annotations are extra annotations that will be added to the build pod
Annotations map[string]string `yaml:"annotations,omitempty" json:"annotations,omitempty"`

Expand Down