Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Add feature flag to control whether we should add don't evict annotation #2360

Merged
merged 1 commit into from
Dec 5, 2023
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
111 changes: 56 additions & 55 deletions docs/docs/100-reference/01-command-line/acorn_install.md

Large diffs are not rendered by default.

73 changes: 37 additions & 36 deletions pkg/apis/api.acorn.io/v1/types.go

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions pkg/apis/api.acorn.io/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ func complete(ctx context.Context, c *apiv1.Config, getter kclient.Reader, inclu
if c.CertManagerIssuer == nil {
c.CertManagerIssuer = profile.CertManagerIssuer
}
if c.AutoConfigureKarpenterDontEvictAnnotations == nil {
c.AutoConfigureKarpenterDontEvictAnnotations = profile.AutoConfigureKarpenterDontEvictAnnotations
}
return nil
}

Expand Down Expand Up @@ -453,6 +456,9 @@ func merge(oldConfig, newConfig *apiv1.Config) *apiv1.Config {
if newConfig.APIServerCPU != nil {
mergedConfig.APIServerCPU = newConfig.APIServerCPU
}
if newConfig.AutoConfigureKarpenterDontEvictAnnotations != nil {
mergedConfig.AutoConfigureKarpenterDontEvictAnnotations = newConfig.AutoConfigureKarpenterDontEvictAnnotations
}

return &mergedConfig
}
Expand Down
8 changes: 7 additions & 1 deletion pkg/controller/appdefinition/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,13 @@ func toDeployment(req router.Request, appInstance *v1.AppInstance, tag name.Refe

// Set karpenter do-not-evict annotation if scale is nil or 1. This prevents karpenter from evicting the pod if deployment is not running with more than 1 replica.
if dep.Spec.Replicas == nil || *dep.Spec.Replicas == 1 {
dep.Spec.Template.Annotations["karpenter.sh/do-not-evict"] = "true"
cfg, err := config.Get(req.Ctx, req.Client)
if err != nil {
return nil, err
}
if z.Dereference(cfg.AutoConfigureKarpenterDontEvictAnnotations) {
dep.Spec.Template.Annotations["karpenter.sh/do-not-evict"] = "true"
}
}

return dep, nil
Expand Down
8 changes: 7 additions & 1 deletion pkg/openapi/generated/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/profiles/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,6 @@ func defaultProfile() apiv1.Config {
ControllerCPU: new(string),
APIServerMemory: new(string),
APIServerCPU: new(string),
AutoConfigureKarpenterDontEvictAnnotations: z.Pointer(true),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: go fmt

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, still give me the same ouput 🤷‍♂️

}
}
1 change: 1 addition & 0 deletions pkg/profiles/production.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func productionProfile() apiv1.Config {
conf.ControllerCPU = z.Pointer("100m")
conf.APIServerMemory = z.Pointer("256Mi")
conf.APIServerCPU = z.Pointer("100m")
conf.AutoConfigureKarpenterDontEvictAnnotations = z.Pointer(true)

return conf
}