-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add object relationships #2
Comments
We need to deal with Relationship Resource CRUD operations. I have two ideas.
If we adopt the first, Kubernetes will help us deal with garbage collection. but cross-namespace owner references are disallowed. |
Maybe we could have both ? @pykorm.k8s_custom_object
class Server(pykorm.NamespacedModel):
pass
@pykorm.k8s_custom_object
class User(pykorm.NamespacedModel):
# Many-to-one or one-to-one
server = pykorm.fields.Relationship(field=pykorm.fields.Spec('server'), relationship=Server, lookup_field='name') In this case, behind the scenes, the user CRD would have their This is easy when having references in the same namespace (for a Namespaced resource) or for the whole cluster (cluster resource). However we could, at first, disallow inter-namespace references for the sake of clarity. What do you think ? |
Hey @Frankkkkk, i'm currently looking into using pykorm as i've been writing way to much boilerplate for my liking with pykube.
as of now i'm just requesting the k8s api & then filtering in my code but it would be nice to use the relationships estabilished in i'd like to help with this feature if you can give me some guidance on how to contribute |
Maybe we should decide whether we want lazy loading or not. I'd think that its not a bad idea to load on the fly so we have less "circular" checking to do. With lazy loading, we could handle the relationship loading on the model's On #2 (comment) I thought that sqlalchemy-like relationships sounded neat, but if you've got another idea I'm all for it ! Maybe we could start with many-to-one (or one-to-one as it's the same from the "father" object) relationships ? Would you like to do a POC MR @Roni1993 and then we can improve on it ? Cheers |
I think lazy loading sounds like a good idea. Regarding the custom relationships I'm thinking that it might be a good idea to build on a similar approach like the labels are used with service selectors Labels allow more efficient requests as the k8s API already provides special filters & it would also align with the standard approach. What do you think about this? |
I know it's been a while but this soft dependency pattern has a lot of benefits though I appreciate it doesn't solve all the issues. |
We should add a
Relationship
field whose role is to reference another resource.However, how to deal with references to other namespaces ? We could support:
The text was updated successfully, but these errors were encountered: