Skip to content

PVC generation can create invalid helm files. #16504

@cdbrown2018

Description

@cdbrown2018

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Using a typical setup (example documented below), the k8s publisher will generate an invalid PVC file.

Here is an example of the spec block I am getting

spec:
  dataSource: {}
  storageClassName: "aws-efs"
  dataSourceRef: {}
  selector: {}
  accessModes:
    - "ReadWriteMany"
  resources:
    requests:
      storage: "1Gi"

dataSource, dataSourceRef, and selector are all invalid and can be completely omitted from the spec when their details are empty, instead of publishing empty curly braces { }. The current output will result in errors when trying to deploy with helm.

Expected Behavior

Empty dataSource, dataSourceRef, and selector properties should be completely omitted from the PVC yaml file.

Steps To Reproduce

Here is a minimal AppHost that will result in the issue described above.

var builder = DistributedApplication.CreateBuilder(args);

var registry = builder.AddContainerRegistry("registry", "localhost:5000");

builder.AddKubernetesEnvironment("k8s")
.WithContainerRegistry(registry)
    .WithProperties(env =>
    {
        env.DefaultStorageClassName = "aws-efs";
        env.DefaultStorageReadWritePolicy = "ReadWriteMany";
        env.DefaultStorageSize = "1Gi";
        env.DefaultStorageType = "pvc";
    })
    .WithHelm(config =>
    {
        config.WithNamespace("default");
    });

builder.AddContainer("container", "my-image")
.WithVolume("vol", "/my-target");

builder.Build().Run();

Exceptions (if any)

— Helm deployment failed: helm upgrade --install failed: Error: PersistentVolumeClaim "container-vol-pvc" is invalid: [spec.dataSource.name: Required value, spec.dataSource.kind: Required
value, spec.dataSource: Invalid value: "": must be 'PersistentVolumeClaim' when referencing the default apiGroup, spec.dataSourceRef.name: Required value, spec.dataSourceRef.kind: Required value, spec.dataSourceRef: Invalid value: "": must be
'PersistentVolumeClaim' when referencing the default apiGroup]

Aspire doctor output

No response

Anything else?

No response

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions