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

Commit

Permalink
Merge pull request #2360 from StrongMonkey/flip-karpenter-annotation
Browse files Browse the repository at this point in the history
Add feature flag to control whether we should add don't evict annotation
  • Loading branch information
StrongMonkey authored Dec 5, 2023
2 parents ea6b20a + cfdb8a1 commit 8691e0d
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 93 deletions.
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),
}
}
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
}

0 comments on commit 8691e0d

Please sign in to comment.