Repository: kubernetes
Issue: Add field-level warnings for deprecated / known bad values
Labels: priority/important-soon,sig/api-machinery,kind/feature,lifecycle/frozen

- Determine approach and format for warnings:
  - [x] determine when to emit warnings: on creation, on update that would change generation / spec
  - [x] Use field.Path format
  - [x] for deprecated values, indicate replacement, deprecation and target removal release
- Add warnings for deprecated fields
  - Pod templates
    - [x] beta os/arch/zone/region labels in node selectors / affinity - https://github.com/kubernetes/kubernetes/pull/101688
    - [x] alpha seccomp annotations (#94365) - https://github.com/kubernetes/kubernetes/pull/101688
    - [x] alpha sysctl annotations (https://github.com/kubernetes/kubernetes/pull/63717) - https://github.com/kubernetes/kubernetes/pull/101688
  - PersistentVolumeSpec
    - [x] deprecated node labels in volume node affinity - https://github.com/kubernetes/kubernetes/pull/108554
  - StorageClass
    - [x] deprecated node labels - https://github.com/kubernetes/kubernetes/pull/108554
  - CSIStorageCapacity
    - [x] deprecated node labels - https://github.com/kubernetes/kubernetes/pull/108554
  - RuntimeClass
    - [x] deprecated node labels - https://github.com/kubernetes/kubernetes/pull/108554
- Add warnings for known bad values
  - PVC, PV, PVC template in statefulset and inline ephemeral volume
    - [ ] fractional byte storage requests (#94313)
  - Pod templates
    - [x] fractional byte requests/limits - https://github.com/kubernetes/kubernetes/pull/101688
    - [x] duplicate hostAliases (#91670, #58477) - https://github.com/kubernetes/kubernetes/pull/101688
    - [x] duplicate imagePullSecrets (#91629, #58477) - https://github.com/kubernetes/kubernetes/pull/101688
    - [x] duplicate containers[*].env (this issue, #86163, #93266, #58477) - https://github.com/kubernetes/kubernetes/pull/101688
    - [x] duplicate volumes (#78266, #58477) - https://github.com/kubernetes/kubernetes/pull/101688
    - [ ] duplicate containers[*].ports (#86273, #93952, #58477)
    - [ ] ~~pods setting both linux and windows options? (if multi-OS images are not possible. xref https://github.com/kubernetes/kubernetes/pull/92355#discussion_r487214449)~~
    - [ ] imagePullSecrets or volume source entries with empty secret or configmap name (https://github.com/kubernetes/kubernetes/issues/99454#issuecomment-787838112)
  - Service
    - [ ] duplicate `{port,protocol}` items in ports list (#59119, #58477, #47249)
  - ... issues linked from https://github.com/kubernetes/kubernetes/issues/64841#issuecomment-395141013



See:
* https://github.com/kubernetes/enhancements/issues/1693
* https://github.com/kubernetes/enhancements/tree/master/keps/sig-api-machinery/1693-warnings
* https://kubernetes.io/blog/2020/09/03/warnings/#future-possibilities
* https://github.com/kubernetes/kubernetes/issues/58477

/assign
/sig api-machinery
/milestone v1.20
See:
* https://github.com/kubernetes/enhancements/issues/1693
* https://github.com/kubernetes/enhancements/tree/master/keps/sig-api-machinery/1693-warnings
* https://kubernetes.io/blog/2020/09/03/warnings/#future-possibilities
* https://github.com/kubernetes/kubernetes/issues/58477

/assign
/sig api-machinery
/milestone v1.20
See:
* https://github.com/kubernetes/enhancements/issues/1693
* https://github.com/kubernetes/enhancements/tree/master/keps/sig-api-machinery/1693-warnings
* https://kubernetes.io/blog/2020/09/03/warnings/#future-possibilities
* https://github.com/kubernetes/kubernetes/issues/58477

/assign
/sig api-machinery
/milestone v1.20