zegl / kube-score

Kubernetes object analysis with recommendations for improved reliability and security. kube-score actively prevents downtime and bugs in your Kubernetes YAML and Charts. Static code analysis for Kubernetes.
https://kube-score.com
MIT License
2.68k stars 175 forks source link

Feature request: fail if port name is longer than 15 characters #465

Closed devopsmash closed 1 year ago

devopsmash commented 2 years ago

in case that you have Deployment.yaml with port name that contains more than 15 character, the k8s will fail the deployment with the following error

Error: Deployment.apps "my-app" is invalid: spec.template.spec.containers[0].ports[0].name: Invalid value: "my-old-app-legacy": must be no more than 15 characters

it will be awesome if kube-score will be able to detect cases like that before the Deployment

example:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: app
  labels:
    app: app
spec:
  selector:
    matchLabels:
      app: app
  template:
    metadata:
      labels:
        app: app
    spec:
      nodeSelector:
        beta.kubernetes.io/os: linux
      containers:
      - name: app
        image: app:dev
        imagePullPolicy: "Always"
        ports:
        - name: my-old-app-legacy
          containerPort: 80
          protocol: TCP
kmarteaux commented 2 years ago

@dsaydon90 and @zegl, I will fix this

kmarteaux commented 1 year ago

@zegl -- This issue can be closed. Fix delivered and merged last May.