Skip to content

Commit

Permalink
Change default diff strategy to server in server-side applies
Browse files Browse the repository at this point in the history
  • Loading branch information
smuth4 authored and julienduchesne committed Jan 28, 2022
1 parent 9efac04 commit dfbd174
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/docs/server-side-apply.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ To enable server-side diff in tanka, add the following field to `spec.json`:
}
```

This also has the effect of changing the default [diff strategy](/diff-strategy)
to `server`, but this can be overridden via command line flags or `spec.json`.

While server-side apply doesn't have any effect on the resources being applied
and is intended to be a general in-place upgrade to client-side apply, there are
differences in how fields are managed that can make converting existing cluster
Expand Down
6 changes: 5 additions & 1 deletion pkg/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ func New(env v1alpha1.Environment) (*Kubernetes, error) {

// setup diffing
if env.Spec.DiffStrategy == "" {
env.Spec.DiffStrategy = "native"
if env.Spec.ApplyStrategy == "server" {
env.Spec.DiffStrategy = "server"
} else {
env.Spec.DiffStrategy = "native"
}

if ctl.Info().ServerVersion.LessThan(semver.MustParse("1.13.0")) {
env.Spec.DiffStrategy = "subset"
Expand Down
5 changes: 5 additions & 0 deletions pkg/tanka/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ func Apply(baseDir string, opts ApplyOpts) error {
return ErrorApplyStrategyUnknown{Requested: opts.ApplyStrategy}
}

// Default to `server` diff in server apply mode
if opts.ApplyStrategy == "server" && opts.DiffStrategy == "" && l.Env.Spec.DiffStrategy == "" {
l.Env.Spec.DiffStrategy = "server"
}

kube, err := l.Connect()
if err != nil {
return err
Expand Down

0 comments on commit dfbd174

Please sign in to comment.