-
Notifications
You must be signed in to change notification settings - Fork 297
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
Is it possible to create a CRD controller? #241
Comments
Yes, you can definitely write a CRD controller in csharp. ListWatch and Informer are higher-level constructs/utilities that are built into the golang client. Equivalent capabilities haven't been built into the dotnet client (yet) but that doesn't mean that you can't build a CRD controller, it just means you'll have to do a little more work. There's a ListWatch cache that has been built for Javascript here: https://github.com/kubernetes-client/javascript/blob/master/src/cache.ts It wouldn't be hard to implement something similar for csharp (and we'd love a PR), or you can just use List and Watch directly. |
So just to make sure I understand - I need to write a listWatch CRD using the function |
Ah, I looked, you want Apologies! |
Thank you! I need also advice on a design: Is there a doc on how to write HA controller? I understand I need to listen for CLI events, so I guess it means having one pod listening for events on the cluster. How can I handle pod stopping/starting and ensuring I'm losing events? |
Find my answer (regarding the controller) on the docs:
|
One finall update - I managed to understand how to do it by hand using:
But recevied the following execption:
I guess it's somewhere inside the watch but I couldn't understand where... |
It's going to try to deserialize the objects into a JSON parsed object here: csharp/src/KubernetesClient/Watcher.cs Line 120 in 9372e32
So instead of passing Hope that helps. This is definitely harder than it should be... |
Got the same exception, trying: await kubernetes.WatchObjectAsync<KamusSecret>("apis/soluto.com/alpha/kamussecrets"); This is class KamusSecret : KubernetesObject
{
public Dictionary<string,string> Data { get; set; }
public string Type { get; set; }
public V1ObjectMeta Metadata { get; set; }
} And when trying the following URL {"type":"ADDED","object":{"apiVersion":"soluto.com/alpha","data":{"key":"J9NYLzTC/O44DvlCEZ+LfQ==:Cc9O5zQzFOyxwTD5ZHseqg=="},"kind":"KamusSecret","metadata":{"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"soluto.com/alpha\",\"data\":{\"key\":\"J9NYLzTC/O44DvlCEZ+LfQ==:Cc9O5zQzFOyxwTD5ZHseqg==\"},\"kind\":\"KamusSecret\",\"metadata\":{\"annotations\":{},\"name\":\"my-drupal-site\",\"namespace\":\"default\"},\"type\":\"TlsSecret\"}\n"},"clusterName":"","creationTimestamp":"2019-02-12T06:58:09Z","generation":1,"name":"my-drupal-site","namespace":"default","resourceVersion":"1162182","selfLink":"/apis/soluto.com/alpha/namespaces/default/kamussecrets/my-drupal-site","uid":"8e3f5bac-2e93-11e9-9566-025000000001"},"type":"TlsSecret"}}
{"type":"DELETED","object":{"apiVersion":"soluto.com/alpha","data":{"key":"J9NYLzTC/O44DvlCEZ+LfQ==:Cc9O5zQzFOyxwTD5ZHseqg=="},"kind":"KamusSecret","metadata":{"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"soluto.com/alpha\",\"data\":{\"key\":\"J9NYLzTC/O44DvlCEZ+LfQ==:Cc9O5zQzFOyxwTD5ZHseqg==\"},\"kind\":\"KamusSecret\",\"metadata\":{\"annotations\":{},\"name\":\"my-drupal-site\",\"namespace\":\"default\"},\"type\":\"TlsSecret\"}\n"},"clusterName":"","creationTimestamp":"2019-02-12T06:58:09Z","generation":1,"name":"my-drupal-site","namespace":"default","resourceVersion":"1162511","selfLink":"/apis/soluto.com/alpha/namespaces/default/kamussecrets/my-drupal-site","uid":"8e3f5bac-2e93-11e9-9566-025000000001"},"type":"TlsSecret"}} |
Yeah, it looks like you need to add There's a comment here: That explains why. But honestly, looking at the code (I didn't write most of it) I feel like there are two competing watch implementations... Anyway, I think that what you need to do is parse out that "object" field and that will be your KamusSecret. Alteranately you could create:
|
I tried adding the query param:
But the requests failed with NotFound error from Kuberentes. Which is weird, because
Hang because there are no objects right now. So it exists. I have no idea why it's not working. I looked on the URL in the exception and it looks valid... |
Hrm, ok at this point I think I just need to reproduce the error on my local box and debug more :) Apologies! |
Sure, thanks! |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Rotten issues close after 30d of inactivity. Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
@fejta-bot: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
I'm using the dotnet client in Kamus, and I really enjoyed it so far. I want to add a CRD (see Soluto/kamus#13), and ideally, I'll be able to write it in dotnet like the rest of the service. By looking at golang samples, look like I need to be able to listen to CLI events. I couldn't find the relevant methods in the SDK - am I missing something? I find only
WatchCustomResourceDefinitionAsync
, but I'm not sure this is the same asNewListWatchFromClient
orNewInformer
that are used on this sample.Can you please help me and point me in the right direction?
The text was updated successfully, but these errors were encountered: