Repository: kubernetes
Issue: kubectl apply umbrella issue tracker
Labels: priority/important-soon,area/app-lifecycle,area/kubectl,sig/cli,area/declarative-configuration,lifecycle/frozen

We need to write kubectl apply user documentation, fix bugs, and complete the functionality.

# Work Items


## TBD
- [ ] #35345 Fix server side defaulting of Union Types
- [ ] #34292 Fix server side defaulting for Union types and derived types
  - [x] #35345 Add apply support that work with Unions
  - [ ] #24198 Deployment strategy needs to be a Union
- [ ] #34413 Apply Deployment and HPA in a single config sometimes fails (bug)
  - _Under triage_
  - Known issue caused in csi libs - *out of scope*
- [ ] #35991 Make apply --prune work on old versions of objects
  - _Stretch_
- [ ] #35149 Apply fails to patch ScheduledJob
- [ ] Prevent user error from deleting unintended resources with --prune
- [ ] Specify `apply` options in configuration file that is checked in so the invocation is reproducible
- [ ] #20508 kubectl --record should avoid capturing secrets on the command line
- [ ] #26234 Create fuzz testing for kubectl apply 
- [ ] #25238 Detect issues with HPA instead of causing unexpected behavior

## 1.9
- [ ] Api Open-Api: Include merge information in open-api spec so the client can merge values without statically linking the types (breaks version skew)
  - [ ] Don't erase new fields in kubectl apply when running an old client against a new server
  - [ ] #34292 Values defaulted by the server must remain correct and valid if their sources are changed.  Includes but not limited to mutually exclusive fields.
  - [ ] Fix issue preventing changing the deployment rollout strategy to "Replace"
- [ ] Provide a diff / dry-run option for apply to see what the changes will be before running them.  When I run apply 
- [ ] List resource names that will be updated / created / deleted and prompt for confirmation when running apply,

## DONE
- [x] #35999 Patch using info.VersionedObject
- [x] #13576 kubectl apply conflict detection (feature)
- [x]  Audit Api Resources: Identify the set of defaulted values that will break apply and resolve
  - Requires full audit of all api objects ~days-~weeks
- [x] #16569 kubectl apply --force (feature)
- [x] #34274 Document apply --prune semantics
- [x] kubernetes/kubernetes.github.io#1513 Apply documentation
- [x] #35220 Fix pruning resource types that are no longer referenced
- [x] #29542 ThirdPartyResource support
- [x] Audit Api Resources: Verify merge keys are set correctly for objects and unique within an array (e.g. VolumeMount used a non-unique merge key and it broke patch)
  - Requires full audit of all api objects
- [x] Audit Api Resources: Distinguish optional fields should be able to distinguish unset from set to default (e.g. optional fields must be pointers)
  - Requires full audit of all api objects
- [x] #23564 kubectl apply leaks secret data  (bug)
  - **Merged**
- [x] #35163 Strategic merge should support remove or replace items in a list of primitive type ( bug)
  - _Unforseen complexity as it requires changing the API server PATCH method_
  - **Merged**
- [x] Verify kubectl is able to delete fields and set them to nil (potential bug)
  - _If fixes for anything that is broken are complex, this would be at risk_
  - Fix in #35496
- [x] Make sure imperative operations (set / scale / annotate) don't get overridden by apply. (potential bug)
  - _If fixes for anything that is broken are complex, this would be at risk_