Implement k8s instance retrieval
This commit is contained in:
parent
0eb07feeef
commit
c4522e31e8
1 changed files with 20 additions and 0 deletions
|
@ -564,3 +564,23 @@ class ServiceInstance(ServalaModelMixin, models.Model):
|
||||||
raise ValidationError(_("Kubernetes API error: {}").format(str(e)))
|
raise ValidationError(_("Kubernetes API error: {}").format(str(e)))
|
||||||
raise ValidationError(_("Error creating instance: {}").format(str(e)))
|
raise ValidationError(_("Error creating instance: {}").format(str(e)))
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def kubernetes_object(self):
|
||||||
|
"""Fetch the Kubernetes custom resource object"""
|
||||||
|
try:
|
||||||
|
api_instance = client.CustomObjectsApi(
|
||||||
|
self.context.control_plane.get_kubernetes_client()
|
||||||
|
)
|
||||||
|
|
||||||
|
return api_instance.get_namespaced_custom_object(
|
||||||
|
group=self.context.group,
|
||||||
|
version=self.context.version,
|
||||||
|
namespace=self.organization.namespace,
|
||||||
|
plural=self.context.kind_plural,
|
||||||
|
name=self.name,
|
||||||
|
)
|
||||||
|
except ApiException as e:
|
||||||
|
if e.status == 404:
|
||||||
|
return None
|
||||||
|
raise
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue