pulumi / pulumi-kubernetes

A Pulumi resource provider for Kubernetes to manage API resources and workloads in running clusters
https://www.pulumi.com/docs/reference/clouds/kubernetes/
Apache License 2.0
404 stars 115 forks source link

v3.Release updates fail "error: cannot re-use a name that is still in use" #2751

Closed awopenphone closed 7 months ago

awopenphone commented 8 months ago

What happened?

Running pulumi up on a v3.Release object is problematic for certain charts like cert-manager:

kubernetes:helm.sh/v3:Release (cert-manager):
error: cannot re-use a name that is still in use
export const _certmanagerNamespace = new k8s.core.v1.Namespace(
  'cert-manager',
  { metadata: { name: 'cert-manager' } },
)
const _certManagerValues = new pulumi.asset.FileAsset('charts/cert-manager/values.yaml')

// get cloudflare key
const cf_api_token = config.requireSecret('cf-api-token')

const cf_secret = new k8s.core.v1.Secret(
  'cloudflare-api-token',
  {
    metadata: {
      name: 'cloudflare-api-token',
      namespace: _certmanagerNamespace.metadata.name,
    },
    type: 'Opaque',
    stringData: {
      'api-token': cf_api_token,
    },
  },
  { provider: k8sProvider, dependsOn: _certmanagerNamespace },
)

const _clusterIssuer = new k8s.yaml.ConfigFile(
  'letsencrypt-op-yaml',
  {
    file: 'charts/cert-manager/letsencrypt-op.yml',
  },
  { provider: k8sProvider, dependsOn: [_certmanagerNamespace, cf_secret] },
)

const _certManagerRelease = new helm.v3.Release(
  'cert-manager',
  {
    name: 'cert-manager',
    namespace: _certmanagerNamespace.metadata.name,
    chart: 'cert-manager',
    repositoryOpts: { repo: 'https://charts.jetstack.io' },
    valueYamlFiles: [_certManagerValues],
    version: '1.13.3',
  },
  { provider: k8sProvider, dependsOn: [_certmanagerNamespace, cf_secret] },
)

Output of pulumi about

pulumi about
CLI
Version 3.101.1 Go Version go1.21.6 Go Compiler gc

Plugins NAME VERSION aws 6.18.0 awsx 2.4.0 docker 4.5.0 docker 3.6.1 kubernetes 4.5.6 nodejs unknown

Host
OS darwin Version 14.2.1 Arch arm64

This project is written in nodejs: executable='/Users/andrew/.nvm/versions/node/v18.18.2/bin/node' version='v18.18.2' Backend
Name pulumi.com privacy snips Token type personal

Dependencies: NAME VERSION @types/node 18.19.6 jest 29.7.0 @pulumi/aws 6.18.0 @pulumi/awsx 2.4.0 @pulumi/kubernetes 4.5.6 @pulumi/pulumi 3.101.1 @swc/jest 0.2.29 @types/jest 29.5.11

Additional context

I can be reached in Slack for troubleshooting or additional questions.

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

awopenphone commented 8 months ago

I am seeing a bunch of more weird stuff like the class failing to clean up resources on replacements and or not creating namespaces that are specified as a dependson statement too.

mjeffryes commented 8 months ago

Looks like #2758 might be the more general formulation of this issue. Any concerns with duping this issue to that one?

awopenphone commented 7 months ago

Duplicate #2758