How do I run a module on the command line without deploying to Kubernetes?

I want to debug the module in an easy way, so I want to run the module without deploying.

But it will automatically create a deployment

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

      

So, I need to create a file nginx.yaml

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

And create pod like below, then it only creates pod

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

      

How can I specify on the command line kind:Pod

to avoid deployment

?

// I am running under minikue 0.20.0 and kubernetes 1.7.0 under Windows 7

+11


source to share


4 answers


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

      

--restart=Always

: restart policy for this module. OnFailure

values ​​[ Always

, For OnFailure

, Never

]. If set to Always

create a deployment, when to OnFailure

create a job, if set to Never

create a regular module. For the last two there --replicas

should be 1

. Always

default [...]



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

+24


source


There are now two ways to create a module via the command line.

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

OR



kubectl run --generator=run-pod/v1 nginx1 --image=nginx

See the official documentation. https://kubernetes.io/docs/reference/kubectl/conventions/#generators

+1


source


Do you mean "post a service"? I think this command line will help you do it.

 kubectl expose pod nginx  --type=LoadBalancer --port=80

      

0


source


To do this, use generators, when you run kubectl, a deployment object will be created by default. If you want to override this behavior, use the run-pod / v1 generator .

kubectl run --generator=run-pod/v1 nginx1 --image=nginx

      

You can refer to the link below for a better understanding.

https://kubernetes.io/docs/reference/kubectl/conventions/#generators

0


source







All Articles