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

Feature request: Want optional test annotation into manifest

ryo-yamaoka opened this issue · comments

Optional tests can currently only be enabled by command line options --enable-optional-test.
However, it would be more effective for CI if they could be defined in the manifest.

Propose format and behavior

apiVersion: apps/v1
kind: Deployment
metadata:
  name: optional-test-manifest-deployment
  labels:
    app: optional-test-manifest
  annotations:
    kube-score/ignore: pod-networkpolicy,container-resources,container-image-pull-policy,container-security-context-privileged,container-security-context-user-group-id,container-security-context-readonlyrootfilesystem,container-ephemeral-storage-request-and-limit
    kube-score/optional: container-ports-check
spec:
  replicas: 1
  selector:
    matchLabels:
      app: optional-test-manifest
  template:
    metadata:
      labels:
        app: optional-test-manifest
    spec:
      containers:
      - name: optional-test-manifest
        image: busybox:1.34
        command:
        - /bin/sh
        - -c
        - date; env; tail -f /dev/null
        ports:
        - name: app
          containerPort: 80
          protocol: TCP
        - name: app 
          containerPort: 8080
          protocol: TCP
$ kube-score score manifest.yaml 
apps/v1/Deployment optional-test-manifest-deployment                          💥
    [CRITICAL] Container Ports Check
        · optional-test-manifest -> Container Port Check
            Container ports.containerPort named ports must be unique

And if want to ignore annotation --disable-optional-checks-annotations flag.

Assignees

I want to implement this!