Skip to content

Commit

Permalink
add update-strategy=skip
Browse files Browse the repository at this point in the history
  • Loading branch information
cppforlife committed Jul 23, 2020
1 parent 9b80193 commit 1b0b1e4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/apply.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ Possible values `` (default), `fallback-on-update`. In some cases creation of a

`kapp.k14s.io/update-strategy` annotation controls update behaviour

Possible values: `` (default), `fallback-on-replace`, `always-replace`. In some cases entire resources or subset resource fields are immutable which forces kapp users to specify how to apply wanted update.
Possible values: `` (default), `fallback-on-replace`, `always-replace`, `skip`. In some cases entire resources or subset resource fields are immutable which forces kapp users to specify how to apply wanted update.

- `` means to issue plain update call
- `fallback-on-replace` causes kapp to fallback to resource replacement if update call results in `Invalid` error. Note that if resource is replaced (= delete + create), it may be negatively affected (loss of persistent data, loss of availability, etc.). For example, if Deployment or DaemonSet is first deleted and then created then associated Pods will be recreated as well, but all at the same time (even if rolling update is enabled), which likely causes an availability gap.
- `always-replace` causes kapp to always delete and then create resource (See note above as well.)
- `skip` causes kapp to not apply update (it will show up in a diff next time)

#### kapp.k14s.io/delete-strategy

Expand Down
14 changes: 14 additions & 0 deletions pkg/kapp/clusterapply/add_or_update_change.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
updateStrategyPlainAnnValue ClusterChangeApplyStrategyOp = ""
updateStrategyFallbackOnReplaceAnnValue ClusterChangeApplyStrategyOp = "fallback-on-replace"
updateStrategyAlwaysReplaceAnnValue ClusterChangeApplyStrategyOp = "always-replace"
updateStrategySkipAnnValue ClusterChangeApplyStrategyOp = "skip"
)

type AddOrUpdateChangeOpts struct {
Expand Down Expand Up @@ -74,6 +75,9 @@ func (c AddOrUpdateChange) ApplyStrategy() (ApplyStrategy, error) {
case updateStrategyAlwaysReplaceAnnValue:
return UpdateAlwaysReplaceStrategy{c}, nil

case updateStrategySkipAnnValue:
return UpdateSkipStrategy{c}, nil

default:
return nil, fmt.Errorf("Unknown update strategy: %s", strategy)
}
Expand Down Expand Up @@ -338,3 +342,13 @@ func (c UpdateAlwaysReplaceStrategy) Op() ClusterChangeApplyStrategyOp {
func (c UpdateAlwaysReplaceStrategy) Apply() error {
return c.aou.replace()
}

type UpdateSkipStrategy struct {
aou AddOrUpdateChange
}

func (c UpdateSkipStrategy) Op() ClusterChangeApplyStrategyOp {
return updateStrategySkipAnnValue
}

func (c UpdateSkipStrategy) Apply() error { return nil }

0 comments on commit 1b0b1e4

Please sign in to comment.