Closed gitkodak closed 6 years ago
Yup:
< self.preferences = dotconf['preferences']
---
> self.preferences = dotconf.get('preferences', '')
Python 2.7.15 (default, May 15 2018, 15:37:31)
[GCC 7.3.1 20180303 (Red Hat 7.3.1-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from kubernetes import K8sConfig
>>> K8sConfig()
<kubernetes.K8sConfig.K8sConfig object at 0x7f545a57ac50>
>>> K8sConfig().preferences
''
>>>
I'm not sure if this is a K8sConfig problem, a rancher problem or a k8s documentation problem.
Rancher (2.x) generates a config file without a "preferences:" section. When trying to use K8sConfig() we get an error due to that key not existing. This is probably easily fixable by using the .get method on the yaml dict with an empty default instead of referencing it directly.
prefs = yaml.get('preferences', '')
It probably wouldn't be a bad idea to do this for everything that's optional -- if we can figure out what that is.
I can't find anything about what's actually required in a k8s config file (neither of the words "required" nor "optional" appear on the documentation page for kubeconfig.) Considering that k8s itself operates just fine without a preferences section then I suspect it safely falls in the "optional" category. If that's the case then K8sConfig() needs to be OK with it being omitted from the config file.