/dotnet-kubernetes-validator

Simple .NET libraries for various Kubernetes client-side and runtime validators.

Primary LanguageC#Apache License 2.0Apache-2.0

✅ .NET Kubernetes Validator

License Test codecov

Simple validators for client-side validation and server-side validation of Kubernetes resources.

Show/hide folder structure
.
├── .github
│   └── workflows
├── src
│   ├── Devantler.KubernetesValidator.ClientSide.Core
│   ├── Devantler.KubernetesValidator.ClientSide.Schemas
│   ├── Devantler.KubernetesValidator.ClientSide.YamlSyntax
│   └── Devantler.KubernetesValidator.ServerSide.Core
└── tests
    ├── Devantler.KubernetesValidator.ClientSide.Schemas.Tests
    │   ├── SchemaValidatorTests
    │   └── assets
    │       ├── k8s-invalid
    │       │   ├── apps
    │       │   ├── clusters
    │       │   │   └── ksail-default
    │       │   │       └── flux-system
    │       │   └── infrastructure
    │       │       └── controllers
    │       └── k8s-valid
    │           ├── apps
    │           ├── clusters
    │           │   └── ksail-default
    │           │       └── flux-system
    │           └── infrastructure
    │               └── controllers
    └── Devantler.KubernetesValidator.ClientSide.YamlSyntax.Tests
        ├── YamlSyntaxValidatorTests
        └── assets
            ├── k8s-invalid
            │   ├── apps
            │   ├── clusters
            │   │   └── ksail-default
            │   │       └── flux-system
            │   └── infrastructure
            │       └── controllers
            └── k8s-valid
                ├── apps
                ├── clusters
                │   └── ksail-default
                │       └── flux-system
                └── infrastructure
                    └── controllers

43 directories

Prerequisites

🚀 Getting Started

To get started, you can install the packages from NuGet.

dotnet add package Devantler.KubernetesValidator.ClientSide.YamlSyntax
dotnet add package Devantler.KubernetesValidator.ClientSide.Schemas
dotnet add package Devantler.KubernetesValidator.ClientSide.Polaris

dotnet add package Devantler.KubernetesValidator.ServerSide.Polaris

📝 Usage

Client-side validation

To use the client-side validators, all you need to do is to create an instance of the validator and call the Validate method with the directory path to the resources you want to validate.

using Devantler.KubernetesValidator.ClientSide.YamlSyntax;

var validator = new YamlSyntaxValidator("path/to/resources");
var isValid = validator.Validate();

Server-side validation

To use the server-side validators, all you need to do is to create an instance of the validator and call the Validate method with the kubeconfig file path and the context name.

using Devantler.KubernetesValidator.ServerSide.Polaris;

var validator = new PolarisValidator("path/to/kubeconfig", "context-name");
var isValid = validator.Validate();