Open chainhead opened 4 years ago
@chainhead Is it a cluster-scoped CRD or namespace-scoped? Can you please show the CRD's YAML and pod.yaml
?
In any case, it seems like an issue with kubernetes
client library, not Kopf. The only way how Kopf can affect it, is namespace=None
for cluster-scoped CRDs. But the error message should be different: the parameter is passed, it is just "wrong" (pod's namespace cannot be None
).
My CRD has a scope of Cluster
and pod.yaml
does not have namespace
. Isn't the namespace
passed in via the kubectl create -f example-yaml -n someNamespace
command?
For custom resources — yes (when it is namespace-scoped). But here, you create a pod, and this pod needs its own namespace specified. Pods cannot be cluster-scoped, they must be namespaced. It can be a namespace of the custom resource, or any other (depends on the domain logic).
kopf.adopt(data)
partially solves that task of parent-child relations — see https://kopf.readthedocs.io/en/latest/hierarchies/ — but only if the custom resource itself were namespaced. Your way would also work (namespace=namespace
pass-through kwarg). BUT:
When your CR is cluster-scoped, there is no namespace
(technically, namespace is None
) in the handler's kwargs, and you have to specify the pod's namespace explicitly from some other source. That is by design of the CR scopes (cluster vs. namespaces).
Thanks for your response; let me run some experiments.
Long story short
create_namespaced_pod
fails with messageValueError: Missing the required parameter namespace when calling create_namespaced_pod
Description
Environment
macOS
I havepython2.7
andpython3.7
installed. I work with Python usingpython3
orpip3
. I can see the traceback originate frompython3.7
.Python packages installed
``` aiohttp==3.6.2 aiojobs==0.2.2 async-timeout==3.0.1 attrs==19.3.0 autopep8==1.4.4 cachetools==4.0.0 certifi==2019.11.28 chardet==3.0.4 Click==7.0 google-auth==1.10.1 idna==2.8 iso8601==0.1.12 kopf==0.24 kubernetes==10.0.1 multidict==4.7.4 oauthlib==3.1.0 pip==19.3.1 pyasn1==0.4.8 pyasn1-modules==0.2.8 pycodestyle==2.5.0 pykube-ng==20.1.0 python-dateutil==2.8.1 PyYAML==5.1.2 requests==2.22.0 requests-oauthlib==1.3.0 rsa==4.0 setuptools==42.0.2 six==1.14.0 typing-extensions==3.7.4.1 urllib3==1.25.7 websocket-client==0.57.0 wheel==0.33.6 yarl==1.4.2 ```