Pulumi-kubernetes: pulumi_kubernetes.yaml.ConfigFile with CRD raises TypeError

Created on 12 Sep 2019  路  5Comments  路  Source: pulumi/pulumi-kubernetes

I've tried to apply the Elastic Cloud on Kubernetes (ECK) YAML using ConfigFile and got TypeError: unexpected keyword argument 'status'.

pulumi_kubernetes.yaml.ConfigFile(
    name='eck',
    file_id='https://download.elastic.co/downloads/eck/0.9.0/all-in-one.yaml',
    opts=pulumi.ResourceOptions(
        provider=k8s_provider,
    ),
)

Trackback:

Diagnostics:
  pulumi:pulumi:Stack (tip-logserver-dev):
    error: Program failed with an unhandled exception:
    error: Traceback (most recent call last):
      File "/home/adir/.pulumi/bin/pulumi-language-python-exec", line 85, in <module>
        loop.run_until_complete(coro)
      File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
        return future.result()
      File "/home/adir/.virtualenvs/pulumi/lib/python3.7/site-packages/pulumi/runtime/stack.py", line 72, in run_in_stack
        raise RPC_MANAGER.unhandled_exception.with_traceback(RPC_MANAGER.exception_traceback)
      File "/home/adir/.virtualenvs/pulumi/lib/python3.7/site-packages/pulumi/runtime/rpc_manager.py", line 67, in rpc_wrapper
        result = await rpc_function(*args, **kwargs)
      File "/home/adir/.virtualenvs/pulumi/lib/python3.7/site-packages/pulumi/runtime/resource.py", line 414, in do_register_resource_outputs
        serialized_props = await rpc.serialize_properties(outputs, {})
      File "/home/adir/.virtualenvs/pulumi/lib/python3.7/site-packages/pulumi/runtime/rpc.py", line 67, in serialize_properties
        result = await serialize_property(v, deps, input_transformer)
      File "/home/adir/.virtualenvs/pulumi/lib/python3.7/site-packages/pulumi/runtime/rpc.py", line 159, in serialize_property
        value = await serialize_property(value.future(), deps, input_transformer)
      File "/home/adir/.virtualenvs/pulumi/lib/python3.7/site-packages/pulumi/runtime/rpc.py", line 147, in serialize_property
        future_return = await asyncio.ensure_future(value)
      File "/home/adir/.virtualenvs/pulumi/lib/python3.7/site-packages/pulumi/output.py", line 149, in run
        value = await self._future
      File "/home/adir/.virtualenvs/pulumi/lib/python3.7/site-packages/pulumi/output.py", line 311, in gather_futures
        return await asyncio.gather(*value_futures)
      File "/home/adir/.virtualenvs/pulumi/lib/python3.7/site-packages/pulumi/output.py", line 149, in run
        value = await self._future
      File "/home/adir/.virtualenvs/pulumi/lib/python3.7/site-packages/pulumi/output.py", line 161, in run
        transformed: Input[U] = func(value)
      File "/home/adir/.virtualenvs/pulumi/lib/python3.7/site-packages/pulumi_kubernetes/yaml.py", line 218, in <lambda>
        CustomResourceDefinition(f"{x}", opts, **obj)))]
    TypeError: __init__() got an unexpected keyword argument 'status'
    error: an unhandled error occurred: Program exited with non-zero exit code: 1

I'm using Pulumi 1.1.0 and pulumi-kubernetes 1.0.1.

Most helpful comment

This happens if the CRD YAML is setting the .status field, which isn't technically a valid input. We could probably add a workaround to ignore status if it's set in the code generators, but in the meantime, you can fix the error with a transformation to remove the erroneous status field.

Something along these lines should do the trick:

# Remove the .status field from CRDs
def remove_status(obj, opts):
    if obj["kind"] == "CustomResourceDefinition":
        del obj["status"]

example = ConfigFile(
    "example",
    files=["cert-manager.yaml"],
    transformations=[remove_status],
)

All 5 comments

I'm getting comparable TypeError for status on pulumi-kubernetes v2.3.1 and v2.6.1 trying to deploy cert-manager v0.15, v0.16, and v1.0.3. This is with pulumi CLI v2.10.2.

This happens if the CRD YAML is setting the .status field, which isn't technically a valid input. We could probably add a workaround to ignore status if it's set in the code generators, but in the meantime, you can fix the error with a transformation to remove the erroneous status field.

Something along these lines should do the trick:

# Remove the .status field from CRDs
def remove_status(obj, opts):
    if obj["kind"] == "CustomResourceDefinition":
        del obj["status"]

example = ConfigFile(
    "example",
    files=["cert-manager.yaml"],
    transformations=[remove_status],
)

Ah, that's a good workaround. I was able to deploy with the above transformation. Appreciate the suggestion!

Similar issue #1226

For a Helm chart, you can use the same transformation function as shown above, and connect it in the ChartOps:

Chart("myChart",
  config=ChartOpts(
    transformations=[remove_status],
  ),
)

However, I applied it to the kube-prometheus-stack Helm chart and it makes a pulumi up very slow (Python CPU usage too 100%).

_Edit: It seems to be related to (my?) MacOS, when I run it in Docker (for Mac) it is fast._

Was this page helpful?
0 / 5 - 0 ratings