shubham mandhare:
Hi,
This is a very simple issue but it was very annoying while i was doing the lab. This is from the NodeAffinity lab. I was editing my deployment to add an affinity
to it and i was doing this using vim
. Every-time i tried to save the file it errored out giving the following error:
# deployments.apps "red" was not valid:
# * <nil>: Invalid value: "The edited file failed validation": [yaml: line 42: mapping values are not allowed in this context, invalid character 'a' looking for beginning of value]
This is k8’s complaining about the indentation the file. Vim is not too smart to indent the file by itself like VS Code. But i am pretty sure i had indented the file correctly:
spec:
containers:
- image: nginx
imagePullPolicy: Always
name: nginx
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution
nodeSelectorTerms:
- matchExpressions:
- key: <http://node-role.kubernetes.io/master|node-role.kubernetes.io/master>
operator: Exists
It is complaining about indenting the word affinity
which looks correctly indented to me. Is there a way to avoid this from happening?