Hello community I am follow the document <https:/...
# general
d
Hello community I am follow the document https://www.pulumi.com/docs/guides/adopting/from_kubernetes/ and try to Deploying a Single Kubernetes YAML File and get error while load yaml file the command and error as below, any ideas ?
Copy code
❯ poetry show
arpeggio           2.0.0     Packrat parser interpreter
attrs              22.2.0    Classes Without Boilerplate
certifi            2022.12.7 Python package for providing Mozilla's CA Bundle.
charset-normalizer 2.1.1     The Real First Universal Charset Detector. Open, modern and actively mainta...
dill               0.3.6     serialize all of python
grpcio             1.50.0    HTTP/2-based RPC framework
idna               3.4       Internationalized Domain Names in Applications (IDNA)
jmespath           1.0.1     JSON Matching Expressions
parver             0.4       Parse and manipulate version numbers.
protobuf           4.21.12
pulumi             3.52.0    Pulumi's Python SDK
pulumi-aws         5.21.1    A Pulumi package for creating and managing Amazon Web Services (AWS) cloud ...
pulumi-kubernetes  3.23.1    A Pulumi package for creating and managing Kubernetes resources.
pyyaml             6.0       YAML parser and emitter for Python
requests           2.28.1    Python HTTP for Humans.
semver             2.13.0    Python helper for Semantic Versioning (<http://semver.org/>)
six                1.16.0    Python 2 and 3 compatibility utilities
urllib3            1.26.14   HTTP library with thread-safe connection pooling, file post, and more.
❯ python
Python 3.10.7 (main, Oct 17 2022, 11:07:33) [Clang 13.1.6 (clang-1316.0.21.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pulumi
>>> import pulumi_kubernetes as k8s
>>>
>>> guestbook = k8s.yaml.ConfigFile('guestbook', 'guestbook-all-in-one.yaml')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/william/git_repo/k8s_lab/.venv/lib/python3.10/site-packages/pulumi_kubernetes/yaml/yaml.py", line 350, in __init__
    __ret__ = invoke_yaml_decode(text)
  File "/Users/william/git_repo/k8s_lab/.venv/lib/python3.10/site-packages/pulumi_kubernetes/yaml/yaml.py", line 348, in invoke_yaml_decode
    inv = pulumi.runtime.invoke('kubernetes:yaml:decode', {'text': text}, invoke_opts)
  File "/Users/william/git_repo/k8s_lab/.venv/lib/python3.10/site-packages/pulumi/runtime/invoke.py", line 142, in invoke
    invoke_result, invoke_error = _sync_await(asyncio.ensure_future(do_rpc()))
  File "/Users/william/git_repo/k8s_lab/.venv/lib/python3.10/site-packages/pulumi/runtime/sync_await.py", line 54, in _sync_await
    return loop.run_until_complete(fut)
  File "/Users/william/.pyenv/versions/3.10.7/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/Users/william/git_repo/k8s_lab/.venv/lib/python3.10/site-packages/pulumi/runtime/invoke.py", line 137, in do_rpc
    raise exn
  File "/Users/william/git_repo/k8s_lab/.venv/lib/python3.10/site-packages/pulumi/runtime/rpc_manager.py", line 68, in rpc_wrapper
    result = await rpc
  File "/Users/william/git_repo/k8s_lab/.venv/lib/python3.10/site-packages/pulumi/runtime/invoke.py", line 107, in do_invoke
    resp, error = await asyncio.get_event_loop().run_in_executor(None, do_invoke)
  File "/Users/william/.pyenv/versions/3.10.7/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/william/git_repo/k8s_lab/.venv/lib/python3.10/site-packages/pulumi/runtime/invoke.py", line 103, in do_invoke
    return monitor.Invoke(req), None
AttributeError: 'NoneType' object has no attribute 'Invoke'
>>>
It seems cause by no kubernetes provider ?
e
You need to run pulumi programs via the pulumi cli, not via python directly. Put that code:
Copy code
import pulumi
import pulumi_kubernetes as k8s

guestbook = k8s.yaml.ConfigFile('guestbook', 'guestbook-all-in-one.yaml')
in it's own .py file and add a
Pulumi.yaml
file like:
Copy code
name: k8s
runtime: python
and then run
pulumi up
in that directory.