Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Enable server-side-apply on direct applier #399

Merged
merged 2 commits into from
Sep 9, 2024
Merged
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
14 changes: 11 additions & 3 deletions pkg/patterns/declarative/pkg/applier/direct.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,20 @@ import (
)

type DirectApplier struct {
inner directApplierSite
// Whether to apply the KRM resources using server-side apply. https://kubernetes.io/docs/reference/using-api/server-side-apply/
// Note: The server-side apply is stable in Kubernetes v1.22, users should take the responsibility to make sure the cluster
// server can support this feature.
serverSideApplyPreferred bool
inner directApplierSite
}

func (d *DirectApplier) UseServerSideApply() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Use a dedicated function to make the flag more discoverable.

d.serverSideApplyPreferred = true
}

var _ Applier = &DirectApplier{}

type directApplier struct {
}
type directApplier struct{}

type directApplierSite interface {
Run(a *apply.ApplyOptions) error
Expand Down Expand Up @@ -170,6 +177,7 @@ func (d *DirectApplier) Apply(ctx context.Context, opt ApplierOptions) error {
applyOpts.PruneResources = append(applyOpts.PruneResources, r...)
}

applyOpts.ServerSideApply = d.serverSideApplyPreferred
applyOpts.ForceConflicts = opt.Force
applyOpts.Namespace = opt.Namespace
applyOpts.SetObjects(infos)
Expand Down
Loading