https://pulumi.com logo
#kubernetes
Title
# kubernetes
c

chilly-garage-80867

09/18/2020, 7:27 PM
Howdy, I am trting to use python to deploy some istio crds and I get this issue
Copy code
Exception: invocation of kubernetes:yaml:decode returned an error: error converting YAML to JSON: yaml: line 128: mapping values are not allowed in this context
b

broad-dog-22463

09/18/2020, 8:02 PM
@gorgeous-egg-16927 can you help @chilly-garage-80867 here?
g

gorgeous-egg-16927

09/18/2020, 8:06 PM
I’d guess that the YAML is malformed somehow. I can take a look if you send it along
g

gorgeous-egg-16927

09/18/2020, 8:33 PM
I’m not sure how you have your program set up, but this works for me:
Copy code
import pulumi_kubernetes as k8s


# Omit a resource from the Chart by transforming the specified resource definition to an empty List.
def omit_namespace(obj, opts):
    if obj["kind"] == "Namespace" and obj["metadata"]["name"] == "istio-system":
        obj["apiVersion"] = "v1"
        obj["kind"] = "List"


k8s.yaml.ConfigFile(
    "istio-crd",
    file="<https://raw.githubusercontent.com/knative-sandbox/net-istio/master/third_party/istio-stable/istio-crds.yaml>"
)
k8s.yaml.ConfigFile(
    "istio-minimal",
    file="<https://raw.githubusercontent.com/knative-sandbox/net-istio/master/third_party/istio-stable/istio-minimal.yaml>",
    transformations=[omit_namespace]
)
Copy code
$ pip3 freeze
pulumi==2.10.1
pulumi-kubernetes==2.6.1
c

chilly-garage-80867

09/18/2020, 8:52 PM
Ihaven’t tried the omit, let me give it a shot
g

gorgeous-egg-16927

09/18/2020, 8:58 PM
Yeah, that
istio-system
namespace is present in both manifests, so I omitted it from the second one
c

chilly-garage-80867

09/18/2020, 9:16 PM
Thanks. Still learning Pulumi
so I used this
Copy code
## Omit Namespaces
def omit_istio_namespace(obj, opts):
    if obj["kind"] == "Namespace" and obj["metadata"]["name"] == "istio-system":
        obj["apiVersion"] = "v1"
        obj["kind"] = "List"

# Istio

istio_crd = ConfigFile(
    "istio_crd",
    file="<https://raw.githubusercontent.com/knative-sandbox/net-istio/master/third_party/istio-stable/istio-crds.yaml>",
)

istio_minimal = ConfigFile(
    "istio_minimal",
    file="<https://raw.githubusercontent.com/knative-sandbox/net-istio/master/third_party/istio-stable/istio-minimal.yaml>",
    opts=ResourceOptions(provider=k8s_provider),
    transformations=[omit_istio_namespace],
)
and got this
Copy code
Exception: invocation of kubernetes:yaml:decode returned an error: error converting YAML to JSON: yaml: line 128: mapping values are not allowed in this context
    error: an unhandled error occurred: Program exited with non-zero exit code: 1
g

gorgeous-egg-16927

09/18/2020, 9:50 PM
What versions are you using of
pulumi
and
pulumi-kubernetes
?
c

chilly-garage-80867

09/18/2020, 10:04 PM
Copy code
$ pulumi plugin ls
NAME        KIND      VERSION  SIZE    INSTALLED     LAST USED
gcp         resource  3.24.0   101 MB  22 hours ago  22 hours ago
gcp         resource  3.23.0   100 MB  3 days ago    3 days ago
gcp         resource  3.13.0   93 MB   2 months ago  2 months ago
gcp         resource  3.11.0   92 MB   2 months ago  2 months ago
kubernetes  resource  2.6.1    68 MB   22 hours ago  22 hours ago
random      resource  2.3.1    42 MB   22 hours ago  22 hours ago
random      resource  2.2.0    39 MB   2 months ago  2 months ago
random      resource  1.7.0    38 MB   2 months ago  2 months ago
g

gorgeous-egg-16927

09/18/2020, 10:29 PM
Hmm…that error appears to be coming from the Kubernetes YAML parser, but I’m not sure why it’s working for me and not for you.
What’s the output if you run
pip3 freeze
?
c

chilly-garage-80867

09/18/2020, 10:54 PM
$ venv/bin/pip3 freeze Arpeggio==1.9.2 attrs==20.2.0 certifi==2020.6.20 chardet==3.0.4 dill==0.3.2 grpcio==1.32.0 idna==2.10 parver==0.3.0 protobuf==3.13.0 pulumi==2.10.1 pulumi-gcp==3.24.0 pulumi-kubernetes==2.6.1 pulumi-random==2.3.1 PyYAML==5.3.1 requests==2.24.0 semver==2.10.2 six==1.15.0 urllib3==1.25.10
g

gorgeous-egg-16927

09/18/2020, 11:05 PM
🤔 I’m out of ideas on this. I searched that error message and it’s definitely related to malformed YAML, but I have no idea what would be different between our setups since the deps look identical
What platform are you running on? (Mac, Windows, Linux?)
c

chilly-garage-80867

09/18/2020, 11:37 PM
Mac
I’ll email my main.py if it helps
g

gorgeous-egg-16927

09/18/2020, 11:40 PM
Sure, sounds good
c

chilly-garage-80867

09/18/2020, 11:43 PM
sent
👍 1
g

gorgeous-egg-16927

09/21/2020, 4:00 PM
Update: this error turned out to be unrelated to the Istio CRDs — it was from a different yaml.ConfigGroup that was pointing to an HTML GitHub page rather than the raw YAML file.
4 Views