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
Related Kubernetes job interview questions
How do you change a number of replicas of a Kubernetes deployment dep1 to 3?
Kubernetes SeniorOn which level can you configure securityContext field in Kubernetes?
Kubernetes SeniorHow do you rollback deployment d12 to a specific revision?
Kubernetes SeniorHow do you display a history of Kubernetes deployment d12 in namespace ns2?
Kubernetes SeniorHow do you move a pod between namespaces in Kubernetes?
Kubernetes Senior