question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RuntimeError when trying to install Calico via YAML

See original GitHub issue

Hello!

  • 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)

Issue details

Trying to install Calico CNI with Pulumi via YAML files fails with: RuntimeError: Set changed size during iteration

Steps to reproduce

  1. Create a Python Pulumi program, trying to install Calico as instructed here: https://projectcalico.docs.tigera.io/getting-started/kubernetes/k3s/multi-node-install
"""A Kubernetes Python Pulumi program"""
import pulumi
from pulumi import ResourceOptions, Output

from pulumi_kubernetes.yaml import ConfigFile

calico_operator = ConfigFile(
    "calico-operator",
    file="https://projectcalico.docs.tigera.io/manifests/tigera-operator.yaml",
)

calico = ConfigFile(
    "calico",
    file="https://projectcalico.docs.tigera.io/manifests/custom-resources.yaml",
    opts=pulumi.ResourceOptions(depends_on=calico_operator)
)
  1. Run pulumi preview
  2. Watch the world burn, no really just Pulumi crashing 😦

Expected: Calico CNI is installed and Pulumi continues to install the rest of the stack.

Actual: Pulumi preview fails pulumi-preview.txt

Pulumi version: v3.24.1 Pulumi Python package: 3.24.1 pulumi-kubernetes version: 3.15.1

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:5
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
AaronFrielcommented, Mar 24, 2022

@pasmon and @betamike thanks for your patience, getting back to this, it looks like there’s an issue with our Kubernetes provider and using ā€œdepends_onā€ with resources that have children. You’re likely to encounter this with ConfigFile, ConfigGroup, and Helm Charts.

A workaround is to use this in the resource options:

calico = ConfigFile(
    "calico",
    file="https://projectcalico.docs.tigera.io/manifests/custom-resources.yaml",
    opts=pulumi.ResourceOptions(
                 # ā¬‡ļø parent resource 
        depends_on=calico_operator.resources.apply(lambda x: list(x.values())),
                                 # ā¬†ļø wait on all child resources 
    )
)

I also noticed that the Calico/Tigera operator manifest sets a field, ā€œstatusā€, we don’t allow in CRDs, so I’ve copied below a full working program with both workarounds:

"""A Kubernetes Python Pulumi program"""
from importlib.resources import Resource
from typing import Any, Dict, List
import pulumi
from pulumi import ResourceOptions, Output

from pulumi_kubernetes.yaml import ConfigFile

def _fix_status(obj: Any, opts: pulumi.ResourceOptions):
    if obj.get("kind") == "CustomResourceDefinition":
        if "status" in obj:
            # Remove status field from CRD, a field we do not permit setting on creating CRDs.
            del obj["status"]

calico_operator = ConfigFile(
    "calico-operator",
    file="https://projectcalico.docs.tigera.io/manifests/tigera-operator.yaml",
    transformations=[_fix_status]
)


calico = ConfigFile(
    "calico",
    file="https://projectcalico.docs.tigera.io/manifests/custom-resources.yaml",
    opts=pulumi.ResourceOptions(
        depends_on=calico_operator.resources.apply(lambda x: list(x.values())),
    )
)
0reactions
pasmoncommented, Sep 2, 2022

I bumped into this issue also with Kyverno ConfigFile, defining the Kyverno policies depending on the actual Kyverno installation. In this case, the depends_on workaround works for me. Thanks @AaronFriel !

Read more comments on GitHub >

github_iconTop Results From Across the Web

Install Calico networking and network policy for on-premises ...
The operator is installed directly on the cluster as a Deployment, and is configured through one or more custom Kubernetes API resources.
Read more >
Quickstart for Calico on Kubernetes - Tigera
This quickstart guide uses the Tigera operator to install Calico. The operator provides lifecycle management for Calico exposed via the Kubernetes API definedĀ ......
Read more >
Migrate Calico to an operator-managed installation - Tigera
For existing clusters using the calico.yaml manifest to install Calico, upon installing the operator, it will detect the existing Calico resources on theĀ ......
Read more >
About Calico
The value of using Calico for networking and network security for workloads and hosts. ... so the only traffic that flows is the...
Read more >
Get started with Calico network policy - Tigera
Create your first Calico network policies. Shows the rich features using sample policies that extend native Kubernetes network policy.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found