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
source to share
kubectl run nginx --image=nginx --port=80 --restart=Never
--restart=Always
: restart policy for this module.OnFailure
values [Always
, ForOnFailure
,Never
]. If set toAlways
create a deployment, when toOnFailure
create a job, if set toNever
create a regular module. For the last two there--replicas
should be1
.Always
default [...]
see the official doc https://kubernetes.io/docs/user-guide/kubectl-conventions/#generators
source to share
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
source to share
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
source to share