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.

Home Page:https://kube-score.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

missing containerPort not detected

devopsmash opened this issue · comments

Which version of kube-score are you using?
1.13.0

What did you do?
deploy.yaml

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: app
          containerPort: 80
          protocol: TCP
        - name: smtp
          containerPort: 
          protocol: TCP

What did you expect to see?

error when missing values like containerPort on that case

What did you see instead?

No error exist, but when your try to deploy it on k8s cluster you get

Error: Failed to render chart: exit status 1: Error: unable to build kubernetes objects from release manifest: error validating "": error validating data: ValidationError(Deployment.spec.template.spec.containers[0].ports[1]): missing required field "containerPort" in io.k8s.api.core.v1.ContainerPort

Implemented with merge #431