kubeval icon indicating copy to clipboard operation
kubeval copied to clipboard

Invalid namespace file passes kubeval

Open jobinjosem1 opened this issue 2 years ago • 2 comments

apiVersion: v1 kind: Namespace metadata: creationTimestamp: null name: Test2 spec: {} status: {}

Trying to validate a namespace YAML file that has an invalid name. If I apply it with dry-run=server flag it throws error "The Namespace "Test2" is invalid: metadata.name: Invalid value: "Test2": a lowercase RFC 1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name', or '123-abc', regex used for validation is 'a-z0-9?')" but kubeval doesn't detect this as an error.

jobinjosem1 avatar Oct 15 '21 12:10 jobinjosem1

just use the --strict flag.

ivan-penchev avatar Oct 25 '21 07:10 ivan-penchev

kubeval --version
Version: 0.16.1
Commit: f5dba6b486fa18b9179b91e15eb6f2b0f7a5a69e
Date: 2021-03-30T15:16:16Z

@ivan-penchev also passes with --strict unfortunately the below namespace is also considered valid, while it's not

apiVersion: v1
kind: Namespace
metadata:
  name: .dummy

PASS - ns.yaml contains a valid Namespace (.dummy)

CC: @hasheddan might be you are also interested in this as well

Moulick avatar Nov 13 '21 17:11 Moulick