I’m attempting to use Pulumi’s Automation API to update a Digital Ocean Kubernetes Node Pool node co...
f
I’m attempting to use Pulumi’s Automation API to update a Digital Ocean Kubernetes Node Pool node count. I’m running into a few issues. When I use
resource_name="pool-testing-0",
I get Duplicate resource URN What should i be using here?
Copy code
node_pool = digitalocean.KubernetesNodePool.get("pool-testing-0", existing_node_pool_id)
    node_pool_update = digitalocean.KubernetesNodePool(
        resource_name="pool-testing-0", # Duplicate resource URN, but what should it be?
        cluster_id=digital_ocean_cluster_id,
        name=node_pool.name,
        size=node_pool.size,
        # node_count=desired_node_count,
        auto_scale=False,
        min_nodes=node_pool.min_nodes,
        max_nodes=desired_node_count,
        opts=pulumi.ResourceOptions(import_=existing_node_pool_id)
    )
If I set a unique
resource_name
I get the dreaded “inputs to import do not match the existing resource”.
Copy code
azure
Updating (Staging)

    pulumi:pulumi:Stack testing-0-Testing running
    pulumi:pulumi:Stack testing-0-Testing running read digitalocean:index:KubernetesNodePool pool-testing-0
    pulumi:pulumi:Stack testing-0-Testing running read digitalocean:index:KubernetesNodePool pool-testing-0
@ Updating....
 =  digitalocean:index:KubernetesNodePool pool-testing-1 importing (0s)
@ Updating....
 =  digitalocean:index:KubernetesNodePool pool-testing-1 importing (0s) error: inputs to import do not match the existing resource
 =  digitalocean:index:KubernetesNodePool pool-testing-1 **importing failed** error: inputs to import do not match the existing resource
    pulumi:pulumi:Stack testing-0-Testing running error: update failed
@ Updating......
    pulumi:pulumi:Stack testing-0-Testing **failed** 1 error
Diagnostics:
  pulumi:pulumi:Stack (testing-0-Testing):
    error: update failed

  digitalocean:index:KubernetesNodePool (pool-testing-1):
    error: inputs to import do not match the existing resource

Resources:
    1 unchanged

Duration: 3s

Traceback (most recent call last):
  File "/Code/pulumi/automation/dagster-node-count/main.py", line 53, in <module>
    up = stack.up(on_output=print)
  File "/Code/pulumi/automation/dagster-node-count/venv/lib/python3.9/site-packages/pulumi/automation/_stack.py", line 308, in up
    up_result = self._run_pulumi_cmd_sync(args, on_output)
  File "/Code/pulumi/automation/dagster-node-count/venv/lib/python3.9/site-packages/pulumi/automation/_stack.py", line 747, in _run_pulumi_cmd_sync
    result = _run_pulumi_cmd(args, self.workspace.work_dir, envs, on_output)
  File "/Code/pulumi/automation/dagster-node-count/venv/lib/python3.9/site-packages/pulumi/automation/_cmd.py", line 78, in _run_pulumi_cmd
    raise create_command_error(result)
pulumi.automation.errors.CommandError: 
 code: 255
 stdout: Updating (Staging)
d
When importing, they have to match. Pulumi doesn't support importing and updating in a single operation
With the kubernetes provider being the exception, pulumi is designed for owning infrastructure, not updating existing infrastructure owned by something else
f
Pulumi owns/manages the K8s cluster in question. I’m attempting to adjust the node pool’s node count via the Automation API, but I’m running into constant issues, so it seems like my plan isn’t feasible.
When importing, they have to match. Pulumi doesn’t support importing and updating in a single operation
When I adjust the resource name to match, I get a duplicate URN error. 🤷
d
The resource names need to be unique across the stack, so it's conflicting with the
.get()
resource
Sorry, unique for each type across the stack
If pulumi created the kubernetes node pool, then you could scale it from the stack it's in. But it looks like you'll need to use the digital ocean api to scale it if you're wanting it to be a separate process
f
I don’t want HPA, I’m trying to add and remove nodes based on time of day, due to the schedule of the workload on the node pool.