Skip to content

Commit

Permalink
fix: Kaniko builder resource limit (#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
mojtaba-esk authored May 14, 2024
1 parent 7933b89 commit 4358db5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
8 changes: 4 additions & 4 deletions e2e/basic/build_from_git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ func TestBuildFromGit(t *testing.T) {
instance, err := knuu.NewInstance("my-instance")
require.NoError(t, err, "Error creating instance")

ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
ctx, cancel := context.WithTimeout(context.Background(), 45*time.Minute)
defer cancel()

// This is a blocking call which builds the image from git repo
err = instance.SetGitRepo(ctx, builder.GitContext{
Repo: "https://github.com/celestiaorg/celestia-app.git",
Branch: "main",
Commit: "",
Repo: "https://github.com/celestiaorg/celestia-app.git",
Branch: "main",
// Commit: "5ce94f4f010e366df301d25cd5d797c3147ff884",
Username: "",
Password: "",
})
Expand Down
1 change: 1 addition & 0 deletions pkg/builder/kaniko/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ var (
ErrMinioNotConfigured = &Error{Code: "MinioNotConfigured", Message: "Minio service is not configured"}
ErrMinioDeploymentFailed = &Error{Code: "MinioDeploymentFailed", Message: "Minio deployment failed"}
ErrDeletingMinioContent = &Error{Code: "DeletingMinioContent", Message: "error deleting Minio content"}
ErrParsingQuantity = &Error{Code: "ParsingQuantity", Message: "error parsing quantity"}
)
14 changes: 13 additions & 1 deletion pkg/builder/kaniko/kaniko.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/celestiaorg/knuu/pkg/names"
batchv1 "k8s.io/api/batch/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
)
Expand All @@ -24,7 +25,8 @@ const (
DefaultParallelism = int32(1)
DefaultBackoffLimit = int32(5)

MinioBucketName = "kaniko"
MinioBucketName = "kaniko"
EphemeralStorage = "10Gi"
)

type Kaniko struct {
Expand Down Expand Up @@ -171,6 +173,11 @@ func (k *Kaniko) prepareJob(ctx context.Context, b *builder.BuilderOptions) (*ba
return nil, ErrGeneratingUUID.Wrap(err)
}

ephemeralStorage, err := resource.ParseQuantity(EphemeralStorage)
if err != nil {
return nil, ErrParsingQuantity.Wrap(err)
}

parallelism := DefaultParallelism
backoffLimit := DefaultBackoffLimit
job := &batchv1.Job{
Expand All @@ -195,6 +202,11 @@ func (k *Kaniko) prepareJob(ctx context.Context, b *builder.BuilderOptions) (*ba
"--destination=" + b.Destination,
// "--verbosity=debug", // log level
},
Resources: v1.ResourceRequirements{
Requests: v1.ResourceList{
v1.ResourceEphemeralStorage: ephemeralStorage,
},
},
},
},
RestartPolicy: "Never", // Ensure that the Pod does not restart
Expand Down

0 comments on commit 4358db5

Please sign in to comment.