I think that there are lots of DevOps engineer realized this issue. Because I am from a software background. Explanations for syntax not enough for me. Below YAML is working for the Azure environment but not working for EKS and AWS.
Error:
error validating data: ValidationError(Deployment.spec): unknown field "spec" in io.k8s.api.apps.v1.DeploymentSpec; if you choose to ignore these errors, turn validation off with --validate=false
My deployment yaml :
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-flask
spec:
selector:
matchLabels:
app: my-flask
replicas: 2
template:
metadata:
labels:
app: my-flask
spec:
containers:
- name: my-flask
image: yusufkaratoprak/awsflaskeks:latest
ports:
- containerPort: 5000
there is some indentation problem with your yamls.
the field secondspec
is under the template.
will also encourage you to see the official docs of kubernetes_deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-flask
spec:
selector:
matchLabels:
app: my-flask
replicas: 2
template:
metadata:
labels:
app: my-flask
spec:
containers:
- name: my-flask
image: yusufkaratoprak/awsflaskeks:latest
ports:
- containerPort: 5000