Event recorder for Kluster and routines to handle Objects from Queue | Writing K8S Operator - Part 5

Поделиться
HTML-код
  • Опубликовано: 29 ноя 2024

Комментарии • 24

  • @manibharathi3659
    @manibharathi3659 3 года назад +4

    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!

    • @viveksinghggits
      @viveksinghggits  3 года назад

      Thank you. I really appreciate 🙏 💛 it.

  • @bagulm123
    @bagulm123 3 года назад +2

    Very nice explanation @Vivek as usual. Thanks for creating such videos.

  • @prayagsingh03
    @prayagsingh03 3 года назад +2

    Thanks a lot for creating this series.

  • @simeonpoot19
    @simeonpoot19 2 года назад +1

    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

    • @viveksinghggits
      @viveksinghggits  2 года назад

      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.

  • @abhishrai4079
    @abhishrai4079 3 года назад +2

    Hello Vivek sir, can i use kubernetes on windows machine?

    • @viveksinghggits
      @viveksinghggits  3 года назад

      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.

  • @siqistechroad3434
    @siqistechroad3434 Год назад

    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!

    • @viveksinghggits
      @viveksinghggits  Год назад

      Informers and listeners work just for Kubernetes resources. How would your controller get to know about cloud resource creation?

    • @siqistechroad3434
      @siqistechroad3434 Год назад

      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

  • @sachinshingare9762
    @sachinshingare9762 2 года назад

    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?

    • @viveksinghggits
      @viveksinghggits  2 года назад

      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.

    • @sachinshingare9762
      @sachinshingare9762 2 года назад

      @@viveksinghggits Thank you, Vivek Ji.

  • @jwalitpatel9042
    @jwalitpatel9042 2 года назад

    delete method with finalizer would be dope

  • @oruchovets
    @oruchovets 2 года назад

    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.

    • @viveksinghggits
      @viveksinghggits  2 года назад

      Hi Oleg,
      I didn't watch the video but why do you need cluster ID after the cluster is deleted?

    • @oruchovets
      @oruchovets 2 года назад

      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 ).

    • @viveksinghggits
      @viveksinghggits  2 года назад

      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.

    • @oruchovets
      @oruchovets 2 года назад

      @@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?

    • @viveksinghggits
      @viveksinghggits  2 года назад +1

      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.