kubectl edit interactively modifies a Kubernetes object definition through the Kubernetes API. It is useful when an existing object needs a targeted change without first editing a local manifest. section 7.2.2
Use kubectl edit when you need to:
- Add or change labels directly on an existing object, although kubectl label is simpler for label-only changes. section 7.2.2
- Change a Service field while preserving related settings, such as changing port from 8080 to 80 while leaving targetPort at 8080. section 11.1.2
- Choose between direct API editing and updating a manifest followed by kubectl apply. section 7.2.2 section 11.1.2
Change a Service port
Run `kubectl edit svc quiz`, change the Service's `port` from `8080` to `80`, and leave `targetPort: 8080` unchanged because the quiz Pod listens on that port. The Service then exposes port 80 while forwarding to port 8080. section 11.1.2

