How do you convert a Kubernetes pod to a deployment?

Experience Level: Senior
Tags: Kubernetes

Answer

Export the pod to a yaml definition using the following command:

kubectl get pod yourpod -o yaml > pod.yaml

Create a new deployment definition using the following command:

kubectl create deployment deploymentname --image=imagename --dry-run=client -o yaml > deployment.yaml

Display the pod yaml:

cat pod.yaml

Copy the spec part

Edit the deployment file:

nano deployment.yaml

Paste the pod .spec block to deployment template .spec, correct indentation, save the file.

Create the deployment using the file:

kubectl apply -f deployment.yaml

Comments

No Comments Yet.
Be the first to tell us what you think.
Kubernetes Certified Application Developer (CKAD) preparation
Kubernetes Certified Application Developer (CKAD) preparation

Are you learning Kubernetes ? Try our test we designed to help you progress faster.

Test yourself
Kubernetes
Kubernetes

Are you learning Kubernetes ? Try our test we designed to help you progress faster.

Test yourself
25 Kubernetes questions that will help you get certified and become more efficient with K8s
25 Kubernetes questions that will help you get certified and become more efficient with K8s

Are you learning Kubernetes ? Try our test we designed to help you progress faster.

Test yourself