apiVersion: v1
kind: ReplicationController
metadata:
name: simple-rc
spec:
replicas: 2
selector:
app: nginx
template:
metadata:
name: simple-rc
labels:
app: simple-rc
version: "1.0"
spec:
containers:
- name: simple-rc
image: nginx
ports:
- containerPort: 80
error:
error validating "sample.yml": error validating data:
ValidationError(ReplicationController.metadata): invalid type for io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta: got "string", expected "map"; if you choose to ignore these errors, turn validation off with --validate=false
Please change
selector:
app: nginx
to
selector:
app: simple-rc
Also, please dont use replication controller it is obsolete, use Deployment instead
The .spec.selector field is a label selector. A ReplicationController manages all the pods with labels that match the selector. It does not distinguish between pods that it created or deleted and pods that another person or process created or deleted. This allows the ReplicationController to be replaced without affecting the running pods.
If specified, the .spec.template.metadata.labels must be equal to the .spec.selector, or it will be rejected by the API. If .spec.selector is unspecified, it will be defaulted to .spec.template.metadata.labels.
spec:
replicas: 2
selector: # Update the selector to match labels
app: simple-rc
version: "1.0"
template:
metadata:
name: simple-rc
labels:
app: simple-rc
version: "1.0"