Skip to content

Issue in kubectl scale dry-run output #1806

@KubeHawk

Description

@KubeHawk

What happened:

When I ran:

kubectl scale deployment -n test my-pod --replicas 3  --dry-run=client -o yaml

or

kubectl scale deployment -n test my-pod --replicas 3  --dry-run=client -o yaml

the generated manifest did match the number of replicas desired:

spec:
  progressDeadlineSeconds: 600
  replicas: 1

What you expected to happen:

The generated YAML should include the spec.replicas expected after the apply at least in --dry-run=server because kubectl sends a PATCH request to the API server and the API server returns the patched object:

spec:
  progressDeadlineSeconds: 600
  replicas: 3

How to reproduce it (as minimally and precisely as possible):

  1. Create a namespace:
kubectl create ns test
  1. Create a deployment in that namespace:
kubectl create deployment my-pod --image=nginx -n test
  1. Generate the new deployment manifest with --dry-run=client:
kubectl scale deployment -n test my-pod --replicas=3  --dry-run=client -o yaml

or

kubectl scale deployment -n test my-pod --replicas=3  --dry-run=server -o yaml
  1. Inspect the output:
    The generated YAML does not include the right number of replicas.

Anything else we need to know?:

I faced this issue while preparing for the CKAD with kubectl v1.34.1

Environment:

  • Kubernetes client and server versions (use kubectl version): v1.34.1 - v1.34.1
  • Cloud provider or hardware configuration: Local
  • OS (e.g: cat /etc/os-release): Ubuntu 24.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.priority/backlogHigher priority than priority/awaiting-more-evidence.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions