manukumar:
kubectl create -f manu.yaml -l color=blue
error: no objects passed to create
Ramkumar Nagaraj:
you cant pass labels in create argument
Ramkumar Nagaraj:
can you paste manu.yaml here
Ramkumar Nagaraj:
need to understand which resource you are trying to create
manukumar:
i tried to deploy pod at a particular node using labels through the command line
Ramkumar Nagaraj:
to deploy pod to particular node you need to use nodeSelector
Ramkumar Nagaraj:
you can refer this - https://kubernetes.io/docs/tasks/configure-pod-container/assign-pods-nodes/
manukumar:
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: blue
name: blue
spec:
replicas: 3
selector:
matchLabels:
app: blue
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: blue
spec:
containers:
- image: nginx
name: nginx
resources: {}
status: {}
~ this is my yaml file
Ramkumar Nagaraj:
this has both combinations
• scheduling pods with node labels
• scheduling pod with designated node
manukumar:
i try to deployed on node01
Ramkumar Nagaraj:
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: blue
name: blue
spec:
replicas: 3
selector:
matchLabels:
app: blue
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: blue
spec:
nodeName: node01
containers:
- image: nginx
name: nginx
resources: {}
status: {}
Ramkumar Nagaraj:
in pod-spec you have to specify nodeName
as shown above
manukumar:
ya this is through the YAML file but i know how can deploy through the command line?
Ramkumar Nagaraj:
you dont have that option specifying nodeName
imperatively while creating deployment
Ramkumar Nagaraj:
kubectl create deploy --help
-> this will say list of available options
manukumar:
ho ok thank you
Ramkumar Nagaraj:
imperative way you can create yaml file with dry-run flag, edit yaml and then create/apply using command line after adding the nodeName
field
Ramkumar Nagaraj:
• kubectl create deploy nginx --image=nginx --dry-run=client -o yaml > nginx.yaml
• edit nginx.yaml to include nodeName
in pod.spec
• kubectl apply -f nginx.yaml
Ramkumar Nagaraj:
this is the way you can create through imperative fashion
manukumar:
ya thanks lot