microsoft / microsoft/aspire

Kubernetes deployment: Support skipping image push for local development (use local images directly)

Open
#18,573 1 comment 0 reactions 0 assignees View on GitHub
needs-area-label triage:bot-seen
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

Problem

When using Aspire.Hosting.Kubernetes to deploy to a local cluster (Docker Desktop, kind, minikube, etc.), the pipeline requires a container registry and forces an
image push:

Resource 'apiservice' requires image push but no container registry is available.
Please add a container registry using 'builder.AddContainerRegistry(...)'
or specify one with '.WithContainerRegistry(registryBuilder)'.

This adds unnecessary friction for local development:

- Must set up and run a local registry (e.g., localhost:5000)
- Must tag and push images for every code change, even though the images already
exist locally
- The registry requirement leaks into the AppHost code, which should be
environment-agnostic

Scenario

I'm developing locally with Docker Desktop Kubernetes. My images are built locally
and available in the Docker daemon. I want to deploy via Helm + Ingress directly,
with imagePullPolicy: IfNotPresent or Never, using local image tags — no registry
involved.

Proposed solution

Allow the Kubernetes publishing pipeline to skip image push when a registry is not
configured, or add an explicit opt-out:

// Option A: No registry at all — works with local images
var k8s = builder.AddKubernetesEnvironment("k8s");
// images are used as-is, imagePullPolicy set to IfNotPresent

// Option B: Explicit opt-out
k8s.WithImagePush(enabled: false);

When image push is disabled:
- Images referenced in K8s manifests use whatever tag the project would produce
locally
- imagePullPolicy defaults to IfNotPresent instead of Always
- No imagePullSecrets or registry references are generated
- The pipeline doesn't fail on missing AddContainerRegistry()

Why this matters

┌────────────────────────────────────────┬────────────────────────────────────┐
│ Today │ Proposed │
├────────────────────────────────────────┼────────────────────────────────────┤
│ AddContainerRegistry(...) + registry │ Optional — only needed when │
│ infrastructure required │ deploying to remote clusters │
├────────────────────────────────────────┼────────────────────────────────────┤
│ Every code change → rebuild → push → │ Rebuild → redeploy (images already │
│ redeploy │ local) │
├────────────────────────────────────────┼────────────────────────────────────┤
│ AppHost code couples to deployment │ AppHost stays environment-agnostic │
│ target (registry URL) │ │
└────────────────────────────────────────┴────────────────────────────────────┘

This is the standard local-dev workflow for tools like Skaffold, Tilt, and
DevSpace — Aspire's K8s hosting should support it too.

Workaround (current)

var registry = builder.AddContainerRegistry("local", "localhost:5000", "");
apiService.WithContainerRegistry(registry);
Plus manually running docker run -d -p 5000:5000 registry:2.

This works but is unnecessary overhead for local development and shouldn't be
mandatory.

Contributor guide

Open the contributing guide

Research direction

Start by tracing the Kubernetes publishing pipeline entered through AddKubernetesEnvironment and the registry validation it performs. Inspect the generated Helm/Kubernetes manifests and image settings; done means a deployment without a configured registry can use local image tags, defaults imagePullPolicy to IfNotPresent, omits registry references and secrets, and no longer fails on the missing registry.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, docker, helm, kubernetes
Domain
cloud, devops, infrastructure
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.