Imperative programming instructs Kubernetes to perform one operational action at a time. A command creates, exposes, updates, or scales an object instead of describing the complete desired state in configuration. section 3.3
Imperative commands can deploy an application quickly, but configuration-based declarative operation is generally preferred for workplace use. Reproducing an imperative deployment requires remembering or storing the command sequence, while configuration can be reapplied across environments. section 3.3
Typical imperative operations include:
- Create a Deployment from a container image with kubectl create deployment. section 3.3
- Expose the Deployment through a LoadBalancer Service with kubectl expose. section 3.3
- Change a running image with kubectl set image or scale replicas with kubectl scale. section 3.3 section 11.1.2
- Create a Secret directly, or generate YAML without creating it by adding --dry-run=client -o yaml. section 11.4.3
Deploying and updating a timeserver
Run kubectl create deployment timeserver --image=docker.io/wdenniss/timeserver:1, expose it with a LoadBalancer Service, then update the image using kubectl set image deployment timeserver timeserver=wdenniss/timeserver:2. Each command changes the cluster directly. section 3.3
$ kubectl create deployment timeserver \ --image=docker.io/wdenniss/timeserver:1 deployment.apps/timeserver created
Inspect the concrete kubectl command that creates a Deployment imperatively; related listings show exposure, status, and image updates. section 3.3













