kubeaudit icon indicating copy to clipboard operation
kubeaudit copied to clipboard

kubeaudit autofix add `targetPort: 0` on a `Service` object

Open arthurzenika opened this issue 1 year ago • 1 comments

ISSUE TYPE
  • [ ] Bug Report
  • [ ] Feature Idea
  • [x] Question (not sure it's a bug so far)

BUG REPORT

SUMMARY

For a kind: Service kubeaudit autofix add a targetPort: 0 which I don't understand, and I can't find any documentation on why this is a recommended change.

--- a/tomcat-service.yaml
+++ b/tomcat-service.yaml
@@ -8,7 +8,10 @@ spec:
   ports:
     - name: http
       port: 8080
+      targetPort: 0
     - name: jmx
       port: 1089
+      targetPort: 0
   selector:
     name: tomcat
ENVIRONMENT
  • Kubeaudit version: 0.22.0
  • Kubeaudit install method: Binary
STEPS TO REPRODUCE

launch kubeaudit autofix on

---
apiVersion: v1
kind: Service
metadata:
  name: tomcat
spec:
  ports:
    - name: http
      port: 8080
    - name: jmx
      port: 1089
  selector:
    name: tomcat
EXPECTED RESULTS

If there is a valid reason for this, maybe a comment could be added to the yaml ? Or some documentation in the kubeaudit project ?

arthurzenika avatar May 12 '23 15:05 arthurzenika

Following a discussion with a colleague that knows a bit more about Kubernetes than me, I think this is a bug.

arthurzenika avatar May 17 '23 14:05 arthurzenika