Skip to content

Commit

Permalink
Operator can limit ephemeral disk used during staging
Browse files Browse the repository at this point in the history
- these limits are set on the kpack image/build.
- `api.stagingRequirements.diskMB` from helm value is now considered as limits set by the platform operator.
- updates the description of `StagingDiskMB` in the CFBuild CRD to say its a "request" instead of "limit".
  • Loading branch information
akrishna90 committed Jul 7, 2023
1 parent b473e57 commit 5fc5bff
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.helm.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Here are all the values that can be set for the chart:
- `stack` (_String_): Stack.
- `stagingRequirements`:
- `buildCacheMB` (_Integer_): Persistent disk in MB for caching staging artifacts across builds.
- `diskMB` (_Integer_): Disk in MB for staging.
- `diskMB` (_Integer_): Ephemeral Disk limit in MB for staging apps.
- `memoryMB` (_Integer_): Memory in MB for staging.
- `type` (_String_): Lifecycle type (only `buildpack` accepted currently).
- `replicas` (_Integer_): Number of replicas.
Expand Down
2 changes: 1 addition & 1 deletion controllers/api/v1alpha1/cfbuild_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type CFBuildSpec struct {

// The memory limit for the pod that will stage the image
StagingMemoryMB int `json:"stagingMemoryMB"`
// The disk limit for the pod that will stage the image
// The ephemeral-disk size request for the pod that will stage the image
StagingDiskMB int `json:"stagingDiskMB"`

// Specifies the buildpacks and stack for the build
Expand Down
1 change: 1 addition & 0 deletions controllers/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type ControllerConfig struct {
ContainerRepositoryPrefix string `yaml:"containerRepositoryPrefix"`
ContainerRegistryType string `yaml:"containerRegistryType"`
BuildCacheMB int `yaml:"buildCacheMB"`
DiskMB int `yaml:"diskMB"`
}

type CFProcessDefaults struct {
Expand Down
2 changes: 2 additions & 0 deletions controllers/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ var _ = Describe("LoadFromPath", func() {
LogLevel: zapcore.DebugLevel,
SpaceFinalizerAppDeletionTimeout: tools.PtrTo(int64(42)),
BuildCacheMB: 1024,
DiskMB: 512,
}
})

Expand Down Expand Up @@ -82,6 +83,7 @@ var _ = Describe("LoadFromPath", func() {
LogLevel: zapcore.DebugLevel,
SpaceFinalizerAppDeletionTimeout: tools.PtrTo(int64(42)),
BuildCacheMB: 1024,
DiskMB: 512,
}))
})

Expand Down
1 change: 1 addition & 0 deletions helm/korifi/controllers/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ data:
containerRepositoryPrefix: {{ .Values.global.containerRepositoryPrefix | quote }}
builderServiceAccount: kpack-service-account
buildCacheMB: {{ .Values.api.lifecycle.stagingRequirements.buildCacheMB }}
diskMB: {{ .Values.api.lifecycle.stagingRequirements.diskMB }}
{{- if .Values.global.eksContainerRegistryRoleARN }}
containerRegistryType: "ECR"
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ spec:
type: object
x-kubernetes-map-type: atomic
stagingDiskMB:
description: The disk limit for the pod that will stage the image
description: The ephemeral-disk size request for the pod that will
stage the image
type: integer
stagingMemoryMB:
description: The memory limit for the pod that will stage the image
Expand Down
2 changes: 1 addition & 1 deletion helm/korifi/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
"type": "integer"
},
"diskMB": {
"description": "Disk in MB for staging.",
"description": "Ephemeral Disk limit in MB for staging apps.",
"type": "integer"
},
"buildCacheMB": {
Expand Down
5 changes: 5 additions & 0 deletions kpack-image-builder/controllers/buildworkload_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,11 @@ func (r *BuildWorkloadReconciler) reconcileKpackImage(
Build: &buildv1alpha2.ImageBuild{
Services: buildWorkload.Spec.Services,
Env: buildWorkload.Spec.Env,
Resources: corev1.ResourceRequirements{
Limits: corev1.ResourceList{
corev1.ResourceEphemeralStorage: *resource.NewScaledQuantity(int64(r.controllerConfig.DiskMB), resource.Mega),
},
},
},
Cache: &buildv1alpha2.ImageCacheConfig{
Volume: &buildv1alpha2.ImagePersistentVolumeCache{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ var _ = Describe("BuildWorkloadReconciler", func() {
g.Expect(kpackImage.Spec.Source.Registry.ImagePullSecrets).To(BeEquivalentTo(source.Registry.ImagePullSecrets))
g.Expect(kpackImage.Spec.Build.Env).To(Equal(env))
g.Expect(kpackImage.Spec.Build.Services).To(BeEquivalentTo(services))
g.Expect(kpackImage.Spec.Build.Resources.Limits.StorageEphemeral().String()).To(Equal(fmt.Sprintf("%dM", 2048)))

g.Expect(kpackImage.Spec.Builder.Kind).To(Equal("ClusterBuilder"))
g.Expect(kpackImage.Spec.Builder.Name).To(Equal("cf-kpack-builder"))
Expand Down
1 change: 1 addition & 0 deletions kpack-image-builder/controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ var _ = BeforeSuite(func() {
ContainerRepositoryPrefix: "image/registry/tag",
BuilderServiceAccount: "builder-service-account",
BuildCacheMB: 1024,
DiskMB: 2048,
}

imageRepoCreator = new(fake.RepositoryCreator)
Expand Down

0 comments on commit 5fc5bff

Please sign in to comment.