kubevious/cli

rule service-selector-ref does not handle sidecars correctly

idanyreblaze opened this issue · 1 comments

when the exposed port is not part of the first container the rule does not recognize the port is exposed by the deployment
example yaml:

---
apiVersion: v1
kind: Service
metadata:
  name: app-metrics
  labels:
    app.kubernetes.io/service_name: app-metrics
    app.kubernetes.io/name: app
    app.kubernetes.io/instance: app

spec:
  type: ClusterIP
  ports:
    - port: 9090
      targetPort: 9090
      protocol: TCP
      name: metrics
  selector:
    app.kubernetes.io/name: app
    app.kubernetes.io/instance: app
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: app
  labels:
    app.kubernetes.io/name: app
    app.kubernetes.io/instance: app
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: app
      app.kubernetes.io/instance: app
  template:
    metadata:
      labels:
        app.kubernetes.io/name: app
        app.kubernetes.io/instance: app
    spec:
      containers:
        - name: app1
          image: "app:1"
          ports:
            - name: http
              containerPort: 80
              protocol: TCP
        - name: app2
          image: "app2:1"
          ports:
            - name: metrics
              containerPort: 9090

@idanyreblaze, Thanks for reporting. Fixed here: kubevious/rules-library@9785ccb

It should now work, please retry.