kubeconform
kubeconform is a tool that validates Kubernetes resources against the Kubernetes OpenAPI specification. It can be used to check if Kubernetes manifests (YAML or JSON files containing Kubernetes resources) are valid according to the specification.What does this module exactly do?:
Directory specification: The module takes as input a directory containing Kubernetes manifests. This could be a single directory or a hierarchy of directories with multiple manifest files.
Manifest validation: For each manifest file in the specified directory, the module runs kubeconform to validate the resources in the file. This includes checking if the resources are valid Kubernetes resources, if they have all required fields, if the fields have valid values, etc.
Kustomization support: If the --kustomize option is provided, the module uses kustomize build to process kustomization files before validating them. Kustomization is a template-free way to customize application configuration, which simplifies the management of configuration files.
Exclusion of directories or files: The module supports excluding directories or files from validation using the --exclude option. This is useful if you have directories or files that you don't want to validate, such as test files, temporary files, etc.
Additional schemas: The module supports additional schemas located in the /schemas directory. This is useful if you have custom resources that are not part of the standard Kubernetes API. You can add schemas for these resources to the /schemas directory, and kubeconform will use them during validation.
Error handling: If kubeconform finds invalid resources, the module prints an error message and exits with a non-zero status. This allows the module to be used in scripts and CI/CD pipelines that need to fail when invalid resources are found.
Installation
dagger install github.com/Smana/daggerverse/kubeconform@v0.0.2
Entrypoint
Return Type
Kubeconform
Example
dagger -m github.com/Smana/daggerverse/kubeconform@98af039dec822c24eae239cd1c3ff6df3a4d1828 call \
func (m *myModule) example() *Kubeconform {
return dag.
Kubeconform()
}
@function
def example() -> dag.Kubeconform:
return (
dag.kubeconform()
)
@func()
example(): Kubeconform {
return dag
.kubeconform()
}
Types
Kubeconform 🔗
version() 🔗
Kubeconform version to use for validation.
Return Type
String !
Example
dagger -m github.com/Smana/daggerverse/kubeconform@98af039dec822c24eae239cd1c3ff6df3a4d1828 call \
version
func (m *myModule) example(ctx context.Context) string {
return dag.
Kubeconform().
Version(ctx)
}
@function
async def example() -> str:
return await (
dag.kubeconform()
.version()
)
@func()
async example(): Promise<string> {
return dag
.kubeconform()
.version()
}
validate() 🔗
Validate the Kubernetes manifests in the provided directory and optional source CRDs directories
Return Type
String !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
version | String | "v0.6.6" | Kubeconform version to use for validation. |
manifests | Directory ! | - | Base directory to walk through in order to validate Kubernetes manifests. |
kustomize | Boolean | - | kustomize if set to true it will look for kustomization.yaml files and validate them otherwise it will validate all the YAML files in the directory. |
exclude | String | - | exclude is string listing directories or files to exclude from the validation separated by commas (example: "./terraform,.gitignore"). |
schemasDirs | [Directory ! ] | - | schemaDirs is a list of directories containing the CRDs to validate against. |
Example
dagger -m github.com/Smana/daggerverse/kubeconform@98af039dec822c24eae239cd1c3ff6df3a4d1828 call \
validate --manifests DIR_PATH
func (m *myModule) example(ctx context.Context, manifests *Directory) string {
return dag.
Kubeconform().
Validate(ctxmanifests)
}
@function
async def example(manifests: dagger.Directory) -> str:
return await (
dag.kubeconform()
.validate(manifests)
)
@func()
async example(manifests: Directory): Promise<string> {
return dag
.kubeconform()
.validate(manifests)
}