{"id":13531542,"url":"https://github.com/falox/csharp-operator-sdk","last_synced_at":"2025-09-13T01:53:58.973Z","repository":{"id":56324820,"uuid":"298021415","full_name":"falox/csharp-operator-sdk","owner":"falox","description":"Build Kubernetes operators with C# and .NET Core","archived":false,"fork":false,"pushed_at":"2020-11-14T10:40:05.000Z","size":141,"stargazers_count":16,"open_issues_count":5,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-08-01T05:23:43.533Z","etag":null,"topics":["csharp","dotnet-core","dotnetcore","kubernetes","kubernetes-operator"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/falox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-23T15:56:13.000Z","updated_at":"2023-02-16T09:08:12.000Z","dependencies_parsed_at":"2022-08-15T16:40:37.323Z","dependency_job_id":null,"html_url":"https://github.com/falox/csharp-operator-sdk","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/falox/csharp-operator-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/falox%2Fcsharp-operator-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/falox%2Fcsharp-operator-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/falox%2Fcsharp-operator-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/falox%2Fcsharp-operator-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/falox","download_url":"https://codeload.github.com/falox/csharp-operator-sdk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/falox%2Fcsharp-operator-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274907856,"owners_count":25371822,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-12T02:00:09.324Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","dotnet-core","dotnetcore","kubernetes","kubernetes-operator"],"created_at":"2024-08-01T07:01:03.849Z","updated_at":"2025-09-13T01:53:58.929Z","avatar_url":"https://github.com/falox.png","language":"C#","funding_links":[],"categories":["Operator Frameworks"],"sub_categories":[],"readme":"[![.NET Core](https://github.com/falox/csharp-operator-sdk/workflows/.NET%20Core/badge.svg?branch=master)](https://github.com/falox/csharp-operator-sdk/actions?query=workflow%3A%22.NET+Core%22)\n[![Nuget (with prereleases)](https://img.shields.io/nuget/vpre/k8s.Operators)](https://www.nuget.org/packages/k8s.Operators)\n[![Coverage Status](https://coveralls.io/repos/github/falox/csharp-operator-sdk/badge.svg?branch=master)](https://coveralls.io/github/falox/csharp-operator-sdk?branch=master)\n\n# C# Operator SDK\n\nThe C# Operator SDK is a framework to build [Kubernetes operators](https://kubernetes.io/docs/concepts/extend-kubernetes/operator/) with C# and .NET Core.\n\n## Features\n\n- Easy custom resource and controller definition as C# classes\n- Custom resource event watchers at namespace and cluster scope\n- [Configurable retry-on-failure](https://github.com/falox/csharp-operator-sdk/blob/f989ab3ad5fdf322f681c863052338c982680bc5/samples/basic/deploy/operator.yaml#L27) policy\n- Smart concurrent event queues (inspired by [Container Solution](https://blog.container-solutions.com/a-deep-dive-into-the-java-operator-sdk)'s article)\n- Kubernetes [graceful termination policy](https://github.com/falox/csharp-operator-sdk/blob/f989ab3ad5fdf322f681c863052338c982680bc5/samples/basic/Program.cs#L89) support\n\n## Usage\n\nSetup a new [.NET Core 3.1](https://dotnet.microsoft.com/download/dotnet-core/3.1) project and add the [C# Operator SDK package](https://www.nuget.org/packages/k8s.Operators):\n\n```bash\ndotnet new console\ndotnet add package k8s.Operators\n```\n\nAssuming that you have already added a custom resource definition for `MyResource` in your Kubernetes cluster, define a class deriving from `CustomResource` for the custom resource schema:\n\n```csharp\n// Set the CRD attributes\n[CustomResourceDefinition(\"example.com\", \"v1\", \"myresources\")]\npublic class MyResource : CustomResource\u003cMyResource.MyResourceSpec, MyResource.MyResourceStatus\u003e\n{\n    // Define spec\n    public class MyResourceSpec\n    {\n        public int property1 { get; set; }\n        // :\n    }\n\n    // Define status\n    public class MyResourceStatus\n    {\n        public int property2 { get; set; }\n        // :\n    }\n}\n```\n\nDefine a class deriving from `Controller` for the controller logic:\n\n```csharp\npublic class MyResourceController : Controller\u003cMyResource\u003e\n{\n    public MyResourceController(OperatorConfiguration configuration, IKubernetes client, ILoggerFactory loggerFactory = null) \n        : base(configuration, client, loggerFactory)\n    {\n    }\n\n    protected override async Task AddOrModifyAsync(MyResource resource, CancellationToken cancellationToken)\n    {\n        Console.WriteLine($\"Add/Modify {resource}\");\n        // :\n        // Handle Add/Modify event\n    }\n\n    protected override async Task DeleteAsync(MyResource resource, CancellationToken cancellationToken)\n    {\n        Console.WriteLine($\"Delete {resource}\");\n        // :\n        // Handle Delete event\n    }\n}\n```\n\nSetup the operator in `Main()`:\n\n```csharp\nstatic async Task\u003cint\u003e Main(string[] args)\n{\n    // Create the Kubernetes client\n    using var client = new Kubernetes(KubernetesClientConfiguration.BuildConfigFromConfigFile());\n\n    // Setup the operator\n    var @operator = new Operator(OperatorConfiguration.Default, client);\n    @operator.AddControllerOfType\u003cMyResourceController\u003e();\n\n    // Start the operator\n    return await @operator.StartAsync();\n}\n```\n\n\u003e Curiosity: Since `operator` is a reserved keyword in C#, it has been escaped with `@operator`.\n\nStart the operator with:\n\n```bash\ndotnet run\n```\n\nIn the `/samples/basic` directory you find a [sample operator](./samples/basic/README.md) that simulates the interaction with an external service and can be used as a template for real-world operators. \n\n[Follow the instructions](./samples/basic/README.md) to run it locally and deploy it to Kubernetes.\n\n## Compiling the source code\n\n```bash\ngit clone https://github.com/falox/csharp-operator-sdk.git\ncd csharp-operator-sdk\ndotnet restore\ndotnet build\n```\n\nRunning the tests:\n\n```bash\ndotnet test\n```\n\n## References\n\n- Jason Dobies and Joshua Wood, [Kubernetes Operators](https://www.oreilly.com/library/view/kubernetes-operators/9781492048039/), O'Reilly, 2020\n- Radu Matei, [Writing controllers for Kubernetes CRDs with C#](https://radu-matei.com/blog/kubernetes-controller-csharp/), 2019\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffalox%2Fcsharp-operator-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffalox%2Fcsharp-operator-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffalox%2Fcsharp-operator-sdk/lists"}