CanSupportMe.Operator
1.0.0-nightly
Removing non-versioned version of package to avoid confusion.
See the version list below for details.
dotnet add package CanSupportMe.Operator --version 1.0.0-nightly
NuGet\Install-Package CanSupportMe.Operator -Version 1.0.0-nightly
<PackageReference Include="CanSupportMe.Operator" Version="1.0.0-nightly" />
paket add CanSupportMe.Operator --version 1.0.0-nightly
#r "nuget: CanSupportMe.Operator, 1.0.0-nightly"
// Install CanSupportMe.Operator as a Cake Addin #addin nuget:?package=CanSupportMe.Operator&version=1.0.0-nightly&prerelease // Install CanSupportMe.Operator as a Cake Tool #tool nuget:?package=CanSupportMe.Operator&version=1.0.0-nightly&prerelease
CanSupportMe.Operator
Overview
What is this?
This package will allow you to create a simple Kubernetes Operator in .NET.
It can pick up changes to CRDs, ConfigMaps or Secrets and say if it was added, modified or deleted.
It can check if a CRD exists as well as retrieve, create, replace and delete configmaps and secrets.
It can also update the status of any manifest that supports it.
What isn't this?
It is not a full blown Kubernetes Operator SDK. These exist and, if desired, this package can be used in conjunction with them. It has been developed to do what the project required and nothing more however this will likely fit the requirements of many similar projects too.
Getting Started
Prerequisites
- .NET 8 or later
- A Kubernetes cluster (either local or remote)
- Sufficient access to the cluster to read and watch secrets (for the demo)
- The ability to create a service account and cluster role binding with access to the resources you will be watching or creating
Install the package
dotnet add package CanSupportMe.Operator
Create a simple operator
Where you are definting your services in Program.cs
add the following:
services.AddOperator(options =>
{
options.Group = "";
options.Kind = "Secret";
options.Version = "v1";
options.Plural = "secrets";
options.Scope = ResourceScope.Namespaced;
options.OnAdded = async (kind, name, @namespace, item, dataObjectManager) =>
{
Log.Information("A secret called {Name} in {Namespace} of type {Type} with {ItemCount} item(s) was added", name, @namespace, item.Type, item.Data?.Count);
};
# This will normally work for most clusters including Azure Kubernetes Service (AKS)
options.KubeConfigPath = Environment.GetEnvironmentVariable("KUBECONFIG");
# This will work for most clusters including Azure Kubernetes Service (AKS)
options.KubernetesServiceHost = Environment.GetEnvironmentVariable("KUBERNETES_SERVICE_HOST");
options.FailoverToken = FAILOVER_TOKEN; # Note this is only required if pointing at a cluster/user that doesn't contain a token in KUBECONFIG
});
Retrieve service token
export SERVICEACCOUNT="cansupportme-operator"
kubectl apply -f - <<EOF
apiVersion: v1
kind: Secret
metadata:
name: ${SERVICEACCOUNT}-token
namespace: seqapikey-system
annotations:
kubernetes.io/service-account.name: $SERVICEACCOUNT
type: kubernetes.io/service-account-token
EOF
export TOKEN=$(kubectl -n seqapikey-system get secret ${SERVICEACCOUNT}-token -o jsonpath='{.data.token}' | base64 --decode)
echo $TOKEN
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- DateTimeProvider (>= 1.0.106)
- FluentResults (>= 3.15.2)
- KubernetesClient (>= 13.0.1)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.0)
- System.IO.Abstractions (>= 20.0.4)
- Throw (>= 1.4.0)
- YamlDotNet (>= 13.7.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
1.0.0 | 157 | 2/7/2024 | |
1.0.0-nightly.33 | 72 | 2/7/2024 | |
1.0.0-nightly.32 | 71 | 2/7/2024 | |
1.0.0-nightly.31 | 66 | 2/4/2024 | |
1.0.0-nightly.30 | 70 | 2/4/2024 | |
1.0.0-nightly.29 | 64 | 2/4/2024 | |
1.0.0-nightly.28 | 63 | 2/3/2024 | |
1.0.0-nightly.27 | 77 | 1/24/2024 | |
1.0.0-nightly.26 | 65 | 1/23/2024 | |
1.0.0-nightly.25 | 61 | 1/23/2024 | |
1.0.0-nightly.24 | 63 | 1/22/2024 | |
1.0.0-nightly.23 | 57 | 1/22/2024 | |
1.0.0-nightly.22 | 68 | 1/22/2024 | |
1.0.0-nightly.21 | 62 | 1/22/2024 | |
1.0.0-nightly.20 | 65 | 1/21/2024 | |
1.0.0-nightly.19 | 65 | 1/20/2024 | |
1.0.0-nightly.18 | 59 | 1/20/2024 | |
1.0.0-nightly.17 | 65 | 1/20/2024 | |
1.0.0-nightly.16 | 69 | 1/20/2024 | |
1.0.0-nightly.15 | 65 | 1/19/2024 | |
1.0.0-nightly.14 | 58 | 1/19/2024 | |
1.0.0-nightly.13 | 60 | 1/19/2024 | |
1.0.0-nightly.12 | 58 | 1/18/2024 | |
1.0.0-nightly.11 | 71 | 1/17/2024 | |
1.0.0-nightly.10 | 74 | 1/17/2024 | |
1.0.0-nightly.9 | 80 | 1/17/2024 | |
1.0.0-nightly.7 | 65 | 1/16/2024 | |
1.0.0-nightly.6 | 67 | 1/16/2024 | |
1.0.0-nightly | 115 | 1/15/2024 |