I tried to create replicaset application file in the terminal but ends up with an error saying Error from server (BadRequest): error when creating "replicaset-definition.yaml": ReplicaSet in version "v1" cannot be handled as a ReplicaSet: strict decoding error: unknown field "replicas", unknown field "selector". Can anyone help me fix this issue? Thanks
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: myapp-replicaset
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
You can type
to get a description for the
ReplicaSet
type.Your fields
replicas
andselector
needs one more indentation level.E.g.
Like this:
In your case it should looks like:
You can use one of k8s syntax validation tools, for example kubeval, for checking yaml files for this kind of issues.