instrumenta / instrumenta/kubeval

Namespace name isn't validated

Open
#85 4 comments 0 reactions 0 assignees View on GitHub
bug upstream
Dominant language
Go
Stars
3.2k
Forks
227
PR merge metrics
No merged PRs in 30d

Description

Thanks for this useful tool.

I noticed Namespace names aren't validated. Here's my Namespace manifest.

```yaml
apiVersion: v1
kind: Namespace
metadata:
name: example.com/dxia-test
```

```
kubectl apply -f namespace.yaml

error: error when retrieving current configuration of:
&{0xc4204e1140 0xc4203be0e0 namespace.yaml 0xc420d52458 false}
from server for: "namespace.yaml": invalid resource name "example.com/dxia-test": [may not contain '/']
```

## Expected behavior

The validator gives me the same error as kubectl

## Actual behavior

But when I run the validator on that file I get an OK.

```
docker run -t --rm \
-v parent-dir-of-namespace-yaml:ro \
garethr/kubeval \
--kubernetes-version=1.10.4

The document namespace.yaml contains a valid Namespace
```

## More info

I think these are the [k8s validation rules](https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/util/validation/validation.go). So I think it's 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]([-a-z0-9]*[a-z0-9])?`).

```
kubectl version

Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.7", GitCommit:"dd5e1a2978fd0b97d9b78e1564398aeea7e7fe92", GitTreeState:"clean", BuildDate:"2018-04-19T00:05:56Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"10+", GitVersion:"v1.10.5-gke.3", GitCommit:"6265b9797fc8680c8395abeab12c1e3bad14069a", GitTreeState:"clean", BuildDate:"2018-07-19T23:02:51Z", GoVersion:"go1.9.3b4", Compiler:"gc", Platform:"linux/amd64"}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.