简体   繁体   中英

Kubernetes yml selector select with two app name

I am new to Kubernetes. I created a server monitor and the selector select two services:

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  labels:
    app: servicemonitor-sms-services
    release: kube-prom-stack
  name: servicemonitor-sms-config-services
  namespace: metrics
spec:
  selector:
    matchLabels:
      app: a-service
      app: b-service

I want the monitor watches both a-service and b-service . The last above doesn't work because I defined duplicated key. I am wondering how should I change it to?

Thanks!

You can use matchExpressions

...
selector:
  matchExpressions:
    - {key: app, operator: In, values: [a-service,b-service]}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM