I am looking for different set of commands for kubectl run to generate yaml file.
Pod
Deployment
Daemonset
Service (different options)
I checked Kubectl Reference Docs
but I am unable to figure out which command need to run for which option
$ run NAME --image=image [–env=“key=value”] [–port=port] [–replicas=replicas] [–dry-run=bool] [–overrides=inline-json] [–command] – [COMMAND] [args…]
For example :
$ kubectl run NAME --image=IMAGE-NAME --labels=run=LABLE --dry-run -o yaml > test.yaml
It creates deployment but I dont know what needs to be change to create other types of yaml.
Thanks for your comment, with the help of above link I figure out way to create pod and deployment yaml files
kubectl run --restart=Never NAME-pod --image=IMAGE-NAME --labels=run=LABLE --dry-run -o yaml > pod.yaml
kubectl run --restart=Always NAME-deployment --image=IMAGE-NAME --labels=run=LABLE --dry-run --replicas=REPLICAS -o yaml > deployment.yaml
Still I am unable to find how to create yaml files for Deamonset, service (node port, cluster ip and loadbalancer).
With the help of “kubectl expose -h” I am able to identify below mentioned parameters
Possible resources include (case insensitive):
pod (po), service (svc), replicationcontroller (rc), deployment (deploy), replicaset (rs)
–dry-run=false: If true, only print the object that would be sent, without sending it.
-o, --output=’’: Output format. One of:
json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-file.
–type=’’: Type for this service: ClusterIP, NodePort, LoadBalancer, or ExternalName. Default is ‘ClusterIP’.
For example :
kubectl expose deployment Deployment-Name --name=Service-Name --port=80 --target-port=80 --type=NodePort --dry-run -o yaml >deploy-service.yaml