Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kubectl YAML config file equivalent of "kubectl run ... -i --tty ..."

Tags:

I've been using "kubectl run" with assorted flags to run Jobs interactively, but have recently outgrown what I can do with those flags, and have graduated to using YAML config files to describe my jobs.

However, I can't find an equivalent to the "-i" and "--tty" flags, to attach to the Job I'm creating.

Is there an equivalent YAML spec for:

kubectl run myjob \             -i \             --tty \             --image=grc.io/myproj/myimg:mytag \             --restart=Never \             --rm \             -- \             my_command 

Or is this maybe not the right approach?

like image 259
garethw Avatar asked Jun 01 '16 04:06

garethw


People also ask

What does kubectl run do?

kubectl run − Run command has the capability to run an image on the Kubernetes cluster. kubectl scale − It will scale the size of Kubernetes Deployments, ReplicaSet, Replication Controller, or job.

How do you run a pod in kubectl?

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

I think you are mentioning these fields. https://github.com/kubernetes/kubernetes/blob/master/pkg/apis/core/types.go#L2081-L2088

You can define stdin and tty in yaml file.

apiVersion: v1  kind: Pod  metadata:    name: test  spec:    containers:      - name: test        image: test        stdin: true        tty: true  
like image 157
Lantao Liu Avatar answered Sep 27 '22 21:09

Lantao Liu