I tried to create a file but ends up with an error saying "Error from server (BadRequest): error when creating "deployment-definition.yml": Deployment in version "v1" cannot be handled as a Deployment: strict decoding error: unknown field "spec.template.metadata.spec" ". Can anyone help me fix this issue? Thanks
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp-deployment
labels:
app: myapp
type: front-end
spec:
template:
metadata:
name: myapp-pod
labels:
app: myapp
type: front-end
spec:
containers:
- name: nginx-container
image: nginx
replicas: 3
selector:
matchLabels:
type: front-end
2
Answers
There is a problem with your yaml format, I have fixed it
Your
spec.template.spec
section is indented under thespec.template.metadata
section.spec.template.spec
should be on the same indentation level asmetadata
.If you are still getting the exact same error,
spec.template.metadata.spec
then:patch
new values into your yaml file before deploying, ensure those aren’t causing the issue. E.g. patching the old error version of the file into your new fileOther than that, we would probably need more information to help troubleshoot more.