How Do You Validate CRDs Before Committing to GitOps?

0
9
Asked By TechWhiz42 On

I've noticed that it's really easy to accidentally commit a faulty YAML file when working with Custom Resource Definitions (CRDs). These files can pass YAML validation but still cause issues when deployed, like adding a field that's not recognized (for example, "oldname" in a certificate resource). I'm curious about the methods you all use to validate your CRDs before pushing them to your GitOps tooling. Are there tools or processes that you find particularly effective?

6 Answers

Answered By DaggerDev77 On

I'm actually building a Dagger module that runs in a GitHub workflow. It creates a kind cluster with the specific Kubernetes version to validate the CRDs against it. It's super powerful and ensures our custom resources can be built correctly from them.

K8sNerd88 -

That's a neat approach! So you’re using GitHub Actions to run these validations, right? But does that only work for PRs and not direct commits?

Answered By TerraformFan44 On

On my end, I rely on Terraform. It validates the configs and if there’s anything missed, it’ll usually crash during the plan phase!

Answered By CRDExpert99 On

We keep all our CRDs as OpenAPI Schemas in a Git repo. When a pull request comes in, we scan all the YAMLs using kubeconform for validation. We also run other checks like kustomize-fix and prettier to keep everything tidy.

Answered By ValidatorGuru66 On

Before I deploy, I use kubeconform, kubelint, and kubectl dry-run. I find that's essential, but honestly, the only way to catch all errors is with a dry-run in a cluster.

Answered By YodaMaster42 On

One thing I do is test everything in non-production clusters. It's a repetitive process, but I find it helps catch issues before they go live. Just a back-and-forth between clusters to ensure everything runs smoothly!

CuriousCoder01 -

Yeah, I totally get that! It does seem like a lot of work just to validate things manually.

Answered By TestPilot27 On

We manage this by having multiple test environments set up. It can be a bit slow with the back-and-forth between clusters, but it ensures that everything is validated correctly before deployment.

SkepticalDev12 -

But wouldn’t that approach take longer than just validating the individual resources?

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.