Skip to content

Model compute environments as resources in app model #8786

@captainsafia

Description

@captainsafia

We want to improve our current model for interacting with compute environments by modeling more compute targets as resources, specifically Docker Compose and Kubernetes targets in the current scenario.

Things we want to consider as part of this:

  • Introduce new ComputeEnvironmentResource type.
  • Kubernetes and Docker Compose publishers in current implementation should be modeled as ComputeEnvironmentResources.
  • Existing Kubernetes and Docker Compose publishers should be updated to respect ComputeEnvironmentResource implementations associated with each target and wire up DeploymentTargetAnnotation on each compute resource.
  • We need to handle multiple compute environments being initialized in the same environment.
var builder = DistributedApplication.CreateBuilder();

var cae = builder.AddAzureContainerAppEnvironment("cae");
var docker = builder.AddDockerComposeEnvironment("docker-compose");
var ks = builder.AddKubernetesComputeEnvironment("kubernetes");

// Require each service to explicitly indicate what environment it belongs
// to if multiple environments are declared
// If only one `ComputeEnvironmentResource` exists then throw
var api1 = builder.AddProject<Projects.Api1>("api1");
var api2 = builder.AddProject<Projects.Api2>("api2");
  • We need to consider how cross-environment endpoint references will work.
var builder = DistributedApplication.CreateBuilder();

var cae = builder.AddAzureContainerAppEnvironment("cae");
var docker = builder.AddDockerComposeEnvironment("docker-compose");
var ks = builder.AddKubernetesComputeEnvironment("kubernetes");

// Require each service to explicitly indicate what environment it belongs
// to if multiple environments are declared
// If only one `ComputeEnvironmentResource` exists then throw
var api1 = builder.AddProject<Projects.Api1>("api1")
  .WithComputeEnvironment(cae);
var api2 = builder.AddProject<Projects.Api2>("api2")
  .WithComputeEnvironment(ks)
  .WithReference(api1); // How do we handle endpoint references here?

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions