I am trying to create a service for a set of pods based on certain selectors. For example, the below get pods
command retrieves the right pods for my requirement -
kubectl get pods --selector property1=dev,property2!=admin
Below is the extract of the service definition yaml where I am attempting to using the same selectors as above -
apiVersion: v1
kind: Service
metadata:
name: service1
spec:
type: NodePort
ports:
- name: port1
port: 30303
targetPort: 30303
selector:
property1: dev
<< property2: ???? >>>
I have tried matchExpressions
without realizing that service is not among the resources that support set-based filters. It resulted in the following error -
error: error validating "STDIN": error validating data: ValidationError(Service.spec.selector.matchExpressions): invalid type for io.k8s.api.core.v1.ServiceSpec.selector: got "array", expected "string"; if you choose to ignore these errors, turn validation off with --validate=false
I am running upstream Kubernetes 1.12.5
pod
YAML ? Also what kubernetes version are you using 1.16 or older? – Archedpod.yaml
. Two reasons, 1. The above question is an abridged version of my environment. 2. The pods are not created by an yaml definition. But some other mechanism. So, the best I can do is run adescribe pod
and provide you the details you are interested in. k8s version 1.12.5. I will update version information in the question also. – Bronwynbronx