You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Introduced generic `RunWithKubernetes<TResource>` overload for
resources exposing kubeconfig as connection string.
- Enhanced CRD management to work seamlessly with
non-`KubernetesEnvironmentResource` clusters.
- Updated tests and documentation to reflect new functionality.
fixes #1170
KubeOps runtime watchers require a Kubernetes API server. Unit tests can replace `IKubernetesClient`, but the normal operator runtime is not an offline simulator.
225
225
226
-
Additional targets can be modeled as Kubernetes environments if they provide Kubernetes API semantics:
226
+
Cluster resources that are not `KubernetesEnvironmentResource`s but expose their kubeconfig path as a connection string — such as the `K3sClusterResource` from the [CommunityToolkit Aspire k3s integration](https://github.com/CommunityToolkit/Aspire) — are supported by the generic `RunWithKubernetes<TResource>` overload (constrained to `IResourceWithConnectionString`):
This overload injects the cluster's `KUBECONFIG` into the operator process (`WithReference`), waits for the cluster (`WaitFor`), starts the operator automatically, and manages CRDs through the same lifecycle as the environment overload — no `KubernetesEnvironmentResource` inheritance required. Publishing still targets a `KubernetesEnvironmentResource`.
236
+
236
237
A mock target would require operator-side runtime support to replace the Kubernetes client and watcher behavior. It should not be represented as a normal Kubernetes environment unless it provides Kubernetes API semantics.
Local development against a k3s cluster from the [CommunityToolkit Aspire k3s integration](https://github.com/CommunityToolkit/Aspire) (or any resource whose connection string is a kubeconfig path):
The generic `RunWithKubernetes<TResource>` overload accepts any `IResourceWithConnectionString` whose connection string is a kubeconfig path. It injects the cluster's `KUBECONFIG` into the operator process, waits for the cluster to become ready, starts the operator automatically, and manages CRDs exactly like the `KubernetesEnvironmentResource` overload. Publishing (`PublishAsKubernetesOperator`) still requires a `KubernetesEnvironmentResource`.
`RunWithKubernetes` also has a generic overload that accepts any `IResourceWithConnectionString` whose connection string is a kubeconfig path — for example a `K3sClusterResource` from the CommunityToolkit Aspire k3s integration. It injects the cluster's `KUBECONFIG` into the operator process, waits for the cluster, starts the operator automatically, and manages CRDs identically:
When the AppHost uses Aspire's Kubernetes publishing support, `PublishAsKubernetesOperator(k8s)` invokes `kubeops generate operator` and appends the generated CRDs, RBAC resources, and service account to the Aspire-generated Helm chart. The operator deployment itself remains Aspire-owned, but KubeOps' generated deployment settings are merged into that workload so the chart deploys one correctly wired operator deployment.
0 commit comments