Closed garethr closed 7 years ago
@surajnarwade would you mind providing the document which failed? Having a test case I can work against would be appreciated.
@garethr sure, here's my kubernetes service file:
$ cat frontend-service.yaml
apiVersion: v1
kind: Service
metadata:
annotations:
kompose.service.type: LoadBalancer
creationTimestamp: null
labels:
io.kompose.service: frontend
name: frontend
spec:
ports:
- name: "80"
port: 80
targetPort: 80
selector:
io.kompose.service: frontend
type: LoadBalancer
status:
loadBalancer: {}
When I run following command,
$ kubeval frontend-service.yaml
The document frontend-service.yaml contains an invalid Service
--> metadata.creationTimestamp: Invalid type. Expected: string, given: null
I've posted an enquiry to sig-api-machinery to clarify the cause of this. https://groups.google.com/forum/#!topic/kubernetes-sig-api-machinery/89MuGn3Er4g
I think it's probably going to be that Kubernetes is fine with nulls, but can't describe that because of limitations in OpenAPI 2. If so I can patch the schemas and this will work correctly.
Yeah, I think this is the same as the array issue and my opinion is the same for this one too. You tool that extracts json schema from OpenAPI should automatically add null type to optional fields.
I'm updating the schemas to add the null type to optional fields. I'll add the above to the test suite.
The change to the schemas in https://github.com/garethr/kubernetes-json-schema/commit/7b7dbcc22fa158f2e512f59db4d7c8d7cc1caa7f should have resolved this. I've added an acceptance test using the service definition above to check as well in https://github.com/garethr/kubeval/commit/845e3c4884872aa442ec077af9bfb0c7a76dec4b.
@garethr , It's working now :)
For instance in deployment: https://github.com/garethr/kubernetes-json-schema/blob/master/master-standalone/deployment.json#L3511-L3514
Reported here for further context. https://github.com/kubernetes/kompose/issues/717
Other useful links: https://kubernetes.io/docs/api-reference/v1.7/#objectmeta-v1-meta https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata