-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Kubernetes Lists #53
Comments
Hi @maxbrunet , thanks for the report. Kubeconform should work as a dropin replacement for kubeval and therefore support Lists. I am looking into this 👍 Note from looking at kubeval support: if this requires unmarshalling to detect, it might have a significant impact on performance :( |
WIP: https://github.com/yannh/kubeconform/pull/54/files |
@maxbrunet this should be good to go https://github.com/yannh/kubeconform/pull/54/files Note: Like kubeval, I am assuming noone is weird enough to make recursive lists ;) |
Went ahead and released v0.4.8, lmk if this works for you! |
Wow thank you @yannh, that was fast! I had started doing some work, but not much, mostly tried to get around with a single unmarshall. I had spotted this: kubeconform/pkg/resource/stream.go Line 51 in c4b044f
It works for
Good news, lists cannot be nested, items must be I used to flatten those in my deployment, until I reconfigured it differently and stopped needing them. They have schemas, but I guess |
@maxbrunet the results of the unmarshall to get the signature are cached, so it should save an unmarshall down the line and be ok in the end. The second unmarshall... If you have an idea to remove it go for it :) Thanks! |
Yes, I confirm, as I said it works for an output of less than 4MB. But have you tried to use a default buffer with If you want to reproduce, here's a couple quick and dirty scripts to generate large files: json.gopackage main
import "fmt"
const (
N = 20000
)
func main() {
fmt.Println(
`{
"apiVersion": "v1",
"kind": "List",
"items": [`,
)
for i := 0; i < N; i++ {
fmt.Printf(
` {
"apiVersion": "v1",
"kind": "ConfigMap",
"metadata": {
"name": "yet-another-confimap-%d"
},
"data": {
"key": "value"
}
}`,
i,
)
if i == N - 1 {
fmt.Println()
} else {
fmt.Println(",")
}
}
fmt.Println(` ]
}
`)
} yaml.gopackage main
import "fmt"
func main() {
fmt.Println(
`apiVersion: v1
kind: List
items:`,
)
for i := 0; i < 50000; i++ {
fmt.Printf(
`- apiVersion: v1
kind: ConfigMap
metadata:
name: yet-another-confimap-%d
data:
key: value
`,
i,
)
}
} |
@maxbrunet I think the problem is slightly different - if the support for lists works, would you mind opening a new ticket for large resource files? 🙏 |
Validating
Lists
does not seem to be supported:kubeconform
should recognize the kind and validate items individually.We mostly use it to validate Jsonnet deployments, this format allows the output to be directly passed to
kubectl apply -f -
(since JSON does not have an equivalent to YAML document streams). An example out there if that can clarify:https://github.com/brancz/kubernetes-grafana/blob/master/examples/basic.jsonnet
This is supported in
kubeval
0.15.0+. Here is the initial implementation and follow up fixes if that helps:instrumenta/kubeval#221
instrumenta/kubeval#283
instrumenta/kubeval#284
From a quick look at the code, it seems we can only identify
Kind: List
from this line:kubeconform/pkg/validator/validator.go
Line 115 in fa1cb37
We would probably need to unmarshall before
ValidateResource()
, if we want to benefit of the parallel workers:kubeconform/cmd/kubeconform/main.go
Lines 116 to 124 in fa1cb37
The text was updated successfully, but these errors were encountered: