Hi Vivek! Just now, I started with part 1 of this segment and you are already here with part 5 :)...Your explanations are on point and precise..kudos man!
Hi @vivek! I wanted to say, Thanks alot for your walkthroughs and explanation of building controllers, also going over the shared informers and so on. Is there a possibility that you can add unit/integration testing to these concepts as well? thanks a bunch
Hi Simeon, Thank you for the valuable comment. It's a good idea to make a video on how we can test these things, I don't have a plan yet but let's see I will create some videos around this in future. Not necessarily testing informers but testing other part of the code test communicates with api server.
I think we can either use docker desktop or Kind to run kubernetes (k8s) on windows. Kind (k8s in docker) is a project to setup development level k8s clusters.
Hi Vivek, may I ask if there is a way to combine the ekspose controller and the kluster controller together? For example, is there a way to detect which cloud resource is created and therefore handle the events accordingly based on the type of the cloud resources? Since I completed your tutorial for ekspose. I am thinking if these two can merge in some way. Thanks!
In the main.go file, is it possible to tell which cloud resources are created and then create controllers based on the created resource? For example, if we can tell a deployment is created, we can create a controller ekspose. If a cluster resource is created, we can create a controller for kluster. @@viveksinghggits
Hi Vivek Ji, can I know how 1. How to get the raw events on create/update/delete service? 2. Is Informar the best way to get those events? 3. On actual object update on API cluster the informer will also update the respective object in cache?
Hi Sachin, What do you mean by raw events? I think the informers are best ways if you want to get them frequently. Yes, object will be updated in the cache as well. Also, just Vivek is perfect. Drop ji.
Hello Vivek. Thank you for the another great explanation. 47:51 min you explains how to delete the cluster from DO. I am trying to implement it - the question is object was deleted then how to get clusterID for passing to DO api. Here is my code snippet: ctx := context.Background() //_, err = c.client.AppsV1().Deployments(ns).Get(ctx, name, metav1.GetOptions{}) _, err = c.klient.ViveksinghV1alpha1().Klusters(ns).Get(ctx, name, metav1.GetOptions{}) if apierrors.IsNotFound(err) { // get the latest version of kluster k, err := c.klient.ViveksinghV1alpha1().Klusters(ns).Get(context.Background(), name, metav1.GetOptions{}) if err != nil { log.Printf("error genning cluster ID %s", err.Error()) return false } log.Printf("Object deleted ... Should call DO delete API for a cluster ID %s !!", k.Status.KlusterID) } Please advise.
Hello @@viveksinghggits . to delete the cluster from DO api required to pass the parameter - ClusterID. We trigger deletion by removing CR. The point is when we are calling the DO api , CR has been deleted . If CR has been deleted , where can I get the Cluster ID to pass it to the DO api? (kind of chicken & egg problem ).
Not really. Have I not covered the deletion part in my video. Once the cr is deleted, you would have cr object in the handleDelete method right? If yes, you can get the cluster ID from cr status. If we don't have cluster ID in cr status, we should/must have that.
@@viveksinghggits , Yeah , this is what I thought. the object we consume from queue should have a ClusterID. Here is the print of the Object: Item &{{Kluster viveksingh.dev/v1alpha1} {kluster-1 default d70af569-5c1e-4385-8114-25fcedebcd71 1419319 %!s(int64=1) 2022-07-11 18:30:53 +0300 IDT %!s(*int64=) map[] map[] [] [] [{kubectl-create Update viveksingh.dev/v1alpha1 2022-07-11 18:30:53 +0300 IDT FieldsV1 {"f:spec":{".":{},"f:name":{},"f:nodePools":{},"f:region":{},"f:tokenSecret":{},"f:version":{}}} } {kluster Update viveksingh.dev/v1alpha1 2022-07-11 18:34:00 +0300 IDT FieldsV1 {"f:status":{".":{},"f:klusterID":{},"f:progress":{}}} status}]} {kluster-1 nyc1 1.21.14-do.0 default/dosecret [{s-2vcpu-2gb dummy-nodepool %!s(int=3)}]} {b74bf273-af92-4994-94e7-bc0ea1a62c54 creating }} clusterID is - b74bf273-af92-4994-94e7-bc0ea1a62c54. how to parse the object to get clusterID? is there a helper function ? I don't know the structure of the object?
You will have to convert the that object into typed kluster type and then you can easily get that field. I have a video on dynamic client as well that might be useful. You can search that in the channel videos.
Hi Vivek! Just now, I started with part 1 of this segment and you are already here with part 5 :)...Your explanations are on point and precise..kudos man!
Thank you. I really appreciate 🙏 💛 it.
Very nice explanation @Vivek as usual. Thanks for creating such videos.
Thanks Mahendra. I appreciate it 🙏.
Thanks a lot for creating this series.
No problem Prayag. Thanks for watching.
Hi @vivek! I wanted to say, Thanks alot for your walkthroughs and explanation of building controllers, also going over the shared informers and so on. Is there a possibility that you can add unit/integration testing to these concepts as well? thanks a bunch
Hi Simeon,
Thank you for the valuable comment. It's a good idea to make a video on how we can test these things, I don't have a plan yet but let's see I will create some videos around this in future. Not necessarily testing informers but testing other part of the code test communicates with api server.
Hello Vivek sir, can i use kubernetes on windows machine?
I think we can either use docker desktop or Kind to run kubernetes (k8s) on windows.
Kind (k8s in docker) is a project to setup development level k8s clusters.
Hi Vivek, may I ask if there is a way to combine the ekspose controller and the kluster controller together? For example, is there a way to detect which cloud resource is created and therefore handle the events accordingly based on the type of the cloud resources? Since I completed your tutorial for ekspose. I am thinking if these two can merge in some way. Thanks!
Informers and listeners work just for Kubernetes resources. How would your controller get to know about cloud resource creation?
In the main.go file, is it possible to tell which cloud resources are created and then create controllers based on the created resource? For example, if we can tell a deployment is created, we can create a controller ekspose. If a cluster resource is created, we can create a controller for kluster. @@viveksinghggits
Hi Vivek Ji, can I know how
1. How to get the raw events on create/update/delete service?
2. Is Informar the best way to get those events?
3. On actual object update on API cluster the informer will also update the respective object in cache?
Hi Sachin,
What do you mean by raw events?
I think the informers are best ways if you want to get them frequently.
Yes, object will be updated in the cache as well.
Also, just Vivek is perfect. Drop ji.
@@viveksinghggits Thank you, Vivek Ji.
delete method with finalizer would be dope
Yeah, lets see if I can make that soon.
Hello Vivek. Thank you for the another great explanation.
47:51 min you explains how to delete the cluster from DO.
I am trying to implement it - the question is object was deleted then how to get clusterID for passing to DO api.
Here is my code snippet:
ctx := context.Background()
//_, err = c.client.AppsV1().Deployments(ns).Get(ctx, name, metav1.GetOptions{})
_, err = c.klient.ViveksinghV1alpha1().Klusters(ns).Get(ctx, name, metav1.GetOptions{})
if apierrors.IsNotFound(err) {
// get the latest version of kluster
k, err := c.klient.ViveksinghV1alpha1().Klusters(ns).Get(context.Background(), name, metav1.GetOptions{})
if err != nil {
log.Printf("error genning cluster ID %s", err.Error())
return false
}
log.Printf("Object deleted ...
Should call DO delete API for a cluster ID %s !!", k.Status.KlusterID)
}
Please advise.
Hi Oleg,
I didn't watch the video but why do you need cluster ID after the cluster is deleted?
Hello @@viveksinghggits . to delete the cluster from DO api required to pass the parameter - ClusterID. We trigger deletion by removing CR. The point is when we are calling the DO api , CR has been deleted . If CR has been deleted , where can I get the Cluster ID to pass it to the DO api? (kind of chicken & egg problem ).
Not really. Have I not covered the deletion part in my video.
Once the cr is deleted, you would have cr object in the handleDelete method right? If yes, you can get the cluster ID from cr status.
If we don't have cluster ID in cr status, we should/must have that.
@@viveksinghggits , Yeah , this is what I thought. the object we consume from queue should have a ClusterID.
Here is the print of the Object:
Item &{{Kluster viveksingh.dev/v1alpha1} {kluster-1 default d70af569-5c1e-4385-8114-25fcedebcd71 1419319 %!s(int64=1) 2022-07-11 18:30:53 +0300 IDT %!s(*int64=) map[] map[] [] [] [{kubectl-create Update viveksingh.dev/v1alpha1 2022-07-11 18:30:53 +0300 IDT FieldsV1 {"f:spec":{".":{},"f:name":{},"f:nodePools":{},"f:region":{},"f:tokenSecret":{},"f:version":{}}} } {kluster Update viveksingh.dev/v1alpha1 2022-07-11 18:34:00 +0300 IDT FieldsV1 {"f:status":{".":{},"f:klusterID":{},"f:progress":{}}} status}]} {kluster-1 nyc1 1.21.14-do.0 default/dosecret [{s-2vcpu-2gb dummy-nodepool %!s(int=3)}]} {b74bf273-af92-4994-94e7-bc0ea1a62c54 creating }}
clusterID is - b74bf273-af92-4994-94e7-bc0ea1a62c54.
how to parse the object to get clusterID? is there a helper function ? I don't know the structure of the object?
You will have to convert the that object into typed kluster type and then you can easily get that field.
I have a video on dynamic client as well that might be useful. You can search that in the channel videos.