kubeval
kubeval copied to clipboard
Check length limitation (63 characters)
Example invalid manifest (see overlong label):
apiVersion: v1
kind: Service
metadata:
name: mysvc
labels:
toolong: abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde77
spec:
ports:
- name: whatever
port: 10000
targetPort: 10000
protocol: TCP
selector:
app: does-not-matter
Unfortunately, kubectl's dry run also doesn't verify this, but maybe you can find a way to check length and character limitations.
$ kubectl apply -f /tmp/toolong.yml --dry-run
service/mysvc created (dry run)
$ kubectl apply -f /tmp/toolong.yml
The Service "mysvc" is invalid: metadata.labels: Invalid value: "abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde77": must be no more than 63 characters
$ kubeval /tmp/toolong.yml
The file /tmp/toolong.yml contains a valid Service
$ kubeval --version
Version: 0.13.0
Commit: 635b3c3604ec2d287b0f7e74cb1835df273dcb65
Date: 2019-08-10T09:30:32Z
Looks like metadata.name is also not caught for cronjobs