We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Dry Run

Remember, the kubectl get -o yaml command gives you the .yaml that defines a resource... but it can be noisy. It's full of fields that Kubernetes filled in for us, like status, uid, resourceVersion, and creationTimestamp. Those things don't belong in your repo that stores configs, and if you commit a stale resourceVersion, it can actually make kubectl apply fail with a Conflict error.

Instead, you want to have kubectl generate a clean manifest. The --dry-run=client flag tells kubectl not to send anything to the cluster, and -o yaml prints what it would have created:

kubectl create deployment synergychat-web --image=bootdotdev/synergychat-web:latest --replicas=3 --dry-run=client -o yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: synergychat-web
  name: synergychat-web
spec:
  replicas: 3
  selector:
    matchLabels:
      app: synergychat-web
  strategy: {}
  template:
    metadata:
      labels:
        app: synergychat-web
    spec:
      containers:
        - image: bootdotdev/synergychat-web:latest
          name: synergychat-web
          resources: {}
status: {}

--dry-run=client works with kubectl apply too. It checks that your file is valid and tells you what it would do, without actually doing it.

Assignment

  1. kubectl create deployment synergychat-web --image=bootdotdev/synergychat-web:latest --replicas=3 --dry-run=client -o yaml > web-deployment.yaml
  2. kubectl apply -f web-deployment.yaml --dry-run=client

Submit the shell checks.