liveBook · Manning

Client dry run

As explained in Kubernetes in Action, Second Edition

A client dry run is a command mode that renders the requested object locally without creating it through the API.

A client dry run makes kubectl render an object definition locally without creating the object through the Kubernetes API. It is useful for starting a manifest that you can inspect and edit before applying it. section 5.2.1 section 15.1.1

Generate a Pod manifest

kubectl run kiada --image=luksa/kiada:0.1 --dry-run=client -o yaml > mypod.yaml The command writes YAML to mypod.yaml instead of creating the Pod. You can then inspect or edit the manifest before using it. section 5.2.1

Generate a Deployment manifest

kubectl create deployment my-app --image=my-image \ --dry-run=client -o yaml > deploy.yaml The resulting file is a rough Deployment manifest that can be modified with fields such as containers, volumes, or other configuration before creation. section 15.1.1

Listing 5.1 A basic pod manifest file
apiVersion: v1      #1
kind: Pod      #2
metadata:     
  name: kiada     #3
spec: 
  containers:
  - name: kiada      #4
    image: luksa/kiada:0.1     #5
    ports: 
    - containerPort: 8080      #6

Inspect a basic Pod manifest produced for a client-side dry run, including its API version, kind, metadata, container image, and port. section 5.2.1

How Kubernetes in Action, Second Edition covers it

How deep it goes
Defines local rendering and demonstrates commands, but stops short of explaining kubectl implementation internals.
Examples
Demonstrates generating Pod and Deployment YAML files with kubectl run and kubectl create deployment.
What it assumes
Assumes familiarity with kubectl commands and YAML objects while demonstrating manifest generation through concrete Pod and Deployment examples.
What you can do after
Build it from scratch by rendering an editable Kubernetes manifest without creating the requested object.
How it connects
Connects kubectl commands with YAML manifests, Pods, Deployments, and the Kubernetes API.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kubernetes in Action, Second Edition. The section links point to the parts of the book it draws on.