I am testing to deploy two pods one on master and on one worker node for learning purpose.
I have the following yaml file to deploy a pod on a cluster on Master node.
apiVersion: v1
kind: Pod
metadata:
name: edge-server
labels:
app: edge-server
spec:
containers:
- name: tensor-keras
image: tensor-keras:latest
command: ["sleep"]
args: ["infinity"]
imagePullPolicy: Never
ports:
- containerPort: 31700
nodeSelector:
node_type: "kmaster" #also tried without quotes
I have labelled the master node as node_type kmaster, I am retrieving the below error
"error parsing line 15 didnot find expected key"
Thank you very much for your help
It may not like your indentation. It is kind of out of wack. You have multiple levels of indentation in one document. I see single, double, and 4-space indentation. YAML indentation is very important otherwise the wrong JSON is generated. Try this:
apiVersion: v1
kind: Pod
metadata:
name: edge-server
labels:
app: edge-server
spec:
containers:
- name: tensor-keras
image: tensor-keras:latest
command: ["sleep"]
args: ["infinity"]
imagePullPolicy: Never
ports:
- containerPort: 31700
nodeSelector:
node_type: kmaster
Try this, Verified it in http://www.yamllint.com/ also
apiVersion: v1
kind: Pod
metadata:
name: edge-server
labels:
app: edge-server
spec:
containers:
- name: tensor-keras
image: tensor-keras:latest
command: ["sleep"]
args: ["infinity"]
imagePullPolicy: Never
ports:
- containerPort: 31700
nodeSelector:
node_type: "kmaster"
nodeSelector
should be at the same level as containers
. We can use this K8s API reference to confirm the structure always.
apiVersion: v1
kind: Pod
metadata:
name: edge-server
labels:
app: edge-server
spec:
containers:
- name: tensor-keras
image: tensor-keras:latest
command: ["sleep"]
args: ["infinity"]
imagePullPolicy: Never
ports:
- containerPort: 31700
nodeSelector:
node_type: "kmaster" #also tried without quotes