Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to start a pod in command line without deployment in kubernetes?

I want to debug the pod in a simple way, therefore I want to start the pod without deployment.

But it will automatically create a deployment

$ kubectl run nginx --image=nginx --port=80 deployment "nginx" created 

So I have to create the nginx.yaml file

--- apiVersion: v1 kind: Pod metadata:   name: nginx spec:   containers:     - name: nginx       image: nginx       ports:         - containerPort: 80 

And create the pod like below, then it creates pod only

kubectl create -f nginx.yaml pod "nginx" created 

How can I specify in the command line the kind:Pod to avoid deployment?

// I run under minikue 0.20.0 and kubernetes 1.7.0 under Windows 7

like image 731
Larry Cai Avatar asked Jul 24 '17 11:07

Larry Cai


People also ask

Can a pod run without Deployment?

Without a deployment, Pods can still be created and run through unmanaged ReplicaSets. While you will still be able to scale your application you lose out on a lot of base functionality deployments provide and drastically increase your maintenance burden.

How do you make a pod without Deployment?

To create a pod using the nginx image, run the command kubectl run nginx --image=nginx --restart=Never . This will create a pod named nginx, running with the nginx image on Docker Hub. And by setting the flag --restart=Never we tell Kubernetes to create a single pod rather than a Deployment.


Video Answer


1 Answers

kubectl run nginx --image=nginx --port=80 --restart=Never 

--restart=Always: The restart policy for this Pod. Legal values [Always, OnFailure, Never]. If set to Always a deployment is created, if set to OnFailure a job is created, if set to Never, a regular pod is created. For the latter two --replicas must be 1. Default Always [...]

see official document https://kubernetes.io/docs/user-guide/kubectl-conventions/#generators

like image 85
Janos Lenart Avatar answered Oct 12 '22 22:10

Janos Lenart